From 0ca95bc4103381e9bb5e1f8b05aca447394180de Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 4 Jul 2023 10:11:26 +0200 Subject: [PATCH] De-duplicate code within functional tests (#28) --- Documentation/Changelog/3.4.0.rst | 2 +- .../DestinationDataTest/AbstractTest.php | 9 +++++ .../ImportCleansTransientFilesTest.php | 6 +--- .../ImportDoesNotUseUploadsFolderTest.php | 12 ++----- ...ImportDoesntBreakWithLongFileTitleTest.php | 11 +----- ...rtDoesntEndUpInEndlessDateCreationTest.php | 11 +----- .../ImportHandlesImagesTest.php | 36 ++++--------------- .../ImportsAllConfigurationTest.php | 12 ++----- .../ImportsExampleAsExpectedTest.php | 12 ++----- .../ImportsFeaturesTest.php | 6 +--- .../ImportsFirstDateOfDatesTest.php | 18 ++-------- .../ImportsSingleConfigurationTest.php | 12 ++----- .../ImportsTicketsTest.php | 11 +----- .../ImportsWithConfiguredRepeatUntilTest.php | 12 ++----- .../ImportsWithLocationsTest.php | 23 +++++------- ...mportsWithoutCategoryIfNotProvidedTest.php | 12 ++----- .../ImportsWithoutLocationTest.php | 11 +----- .../ImportsWithoutRegionIfNotProvidedTest.php | 12 ++----- 18 files changed, 48 insertions(+), 180 deletions(-) diff --git a/Documentation/Changelog/3.4.0.rst b/Documentation/Changelog/3.4.0.rst index 32fd3d5..b417110 100644 --- a/Documentation/Changelog/3.4.0.rst +++ b/Documentation/Changelog/3.4.0.rst @@ -72,7 +72,7 @@ Fixes Tasks ----- -Nothing +* De-duplicate code within functional tests. Deprecation ----------- diff --git a/Tests/Functional/Import/DestinationDataTest/AbstractTest.php b/Tests/Functional/Import/DestinationDataTest/AbstractTest.php index 1648764..43e804c 100644 --- a/Tests/Functional/Import/DestinationDataTest/AbstractTest.php +++ b/Tests/Functional/Import/DestinationDataTest/AbstractTest.php @@ -16,4 +16,13 @@ abstract class AbstractTest extends AbstractFunctionalTestCase $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/Structure.php'); } + + protected function assertEmptyLog(): void + { + self::assertFileEquals( + __DIR__ . '/Assertions/EmptyLogFile.txt', + $this->getInstancePath() . '/typo3temp/var/log/typo3_0493d91d8e.log', + 'Logfile was not empty.' + ); + } } diff --git a/Tests/Functional/Import/DestinationDataTest/ImportCleansTransientFilesTest.php b/Tests/Functional/Import/DestinationDataTest/ImportCleansTransientFilesTest.php index b2ef113..4672bc7 100644 --- a/Tests/Functional/Import/DestinationDataTest/ImportCleansTransientFilesTest.php +++ b/Tests/Functional/Import/DestinationDataTest/ImportCleansTransientFilesTest.php @@ -59,10 +59,6 @@ class ImportCleansTransientFilesTest extends AbstractTest self::assertIsArray($transientFiles, 'Failed to retrieve transient files from filesystem.'); self::assertCount(0, $transientFiles, 'Got unexpected number of files'); - self::assertFileEquals( - __DIR__ . '/Assertions/EmptyLogFile.txt', - $this->getInstancePath() . '/typo3temp/var/log/typo3_0493d91d8e.log', - 'Logfile was not empty.' - ); + $this->assertEmptyLog(); } } diff --git a/Tests/Functional/Import/DestinationDataTest/ImportDoesNotUseUploadsFolderTest.php b/Tests/Functional/Import/DestinationDataTest/ImportDoesNotUseUploadsFolderTest.php index 59e1b72..282fc84 100644 --- a/Tests/Functional/Import/DestinationDataTest/ImportDoesNotUseUploadsFolderTest.php +++ b/Tests/Functional/Import/DestinationDataTest/ImportDoesNotUseUploadsFolderTest.php @@ -16,10 +16,6 @@ class ImportDoesNotUseUploadsFolderTest extends AbstractTest */ public function doesNotUseUploadsFolder(): void { - $fileImportPathConfiguration = 'staedte/beispielstadt/events/'; - $fileImportPath = $this->getInstancePath() . '/fileadmin/' . $fileImportPathConfiguration; - GeneralUtility::mkdir_deep($fileImportPath); - $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/DefaultImportConfiguration.php'); $this->setUpConfiguration([ 'restUrl = https://example.com/some-path/', @@ -46,7 +42,7 @@ class ImportDoesNotUseUploadsFolderTest extends AbstractTest self::assertSame('https://dam.destination.one/828118/f13bbf5602ffc406ebae2faa3527654dea84194666bce4925a1ca8bd3f50c5e9/tueftlerzeit-sfz-rudolstadt-jpg.jpg', (string)$requests[2]['request']->getUri()); self::assertSame('https://dam.destination.one/853436/109ac1cf87913e21b5e2b0ef0cc63d223a14374364952a855746a8e7c3fcfc36/lutherkirche-jpg.jpg', (string)$requests[3]['request']->getUri()); - $importedFiles = GeneralUtility::getFilesInDir($fileImportPath); + $importedFiles = GeneralUtility::getFilesInDir($this->fileImportPath); self::assertIsArray($importedFiles, 'Failed to retrieve imported files from filesystem.'); self::assertSame( [ @@ -60,10 +56,6 @@ class ImportDoesNotUseUploadsFolderTest extends AbstractTest self::assertFalse(file_exists(Environment::getPublicPath() . '/uploads/tx_events/'), 'Uploads folder exists.'); - self::assertFileEquals( - __DIR__ . '/Assertions/EmptyLogFile.txt', - $this->getInstancePath() . '/typo3temp/var/log/typo3_0493d91d8e.log', - 'Logfile was not empty.' - ); + $this->assertEmptyLog(); } } diff --git a/Tests/Functional/Import/DestinationDataTest/ImportDoesntBreakWithLongFileTitleTest.php b/Tests/Functional/Import/DestinationDataTest/ImportDoesntBreakWithLongFileTitleTest.php index 09799da..5aafb5f 100644 --- a/Tests/Functional/Import/DestinationDataTest/ImportDoesntBreakWithLongFileTitleTest.php +++ b/Tests/Functional/Import/DestinationDataTest/ImportDoesntBreakWithLongFileTitleTest.php @@ -3,7 +3,6 @@ namespace Wrm\Events\Tests\Functional\Import\DestinationDataTest; use GuzzleHttp\Psr7\Response; -use TYPO3\CMS\Core\Utility\GeneralUtility; class ImportDoesntBreakWithLongFileTitleTest extends AbstractTest { @@ -12,10 +11,6 @@ class ImportDoesntBreakWithLongFileTitleTest extends AbstractTest */ public function importsExampleAsExpected(): void { - $fileImportPathConfiguration = 'staedte/beispielstadt/events/'; - $fileImportPath = $this->getInstancePath() . '/fileadmin/' . $fileImportPathConfiguration; - GeneralUtility::mkdir_deep($fileImportPath); - $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleImportConfigurationWithCategories.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleRegion.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleCategory.php'); @@ -38,10 +33,6 @@ class ImportDoesntBreakWithLongFileTitleTest extends AbstractTest self::assertSame(0, $tester->getStatusCode()); $this->assertCSVDataSet('EXT:events/Tests/Functional/Import/DestinationDataTest/Assertions/ImportDoesntBreakWithLongFileTitle.csv'); - self::assertFileEquals( - __DIR__ . '/Assertions/EmptyLogFile.txt', - $this->getInstancePath() . '/typo3temp/var/log/typo3_0493d91d8e.log', - 'Logfile was not empty.' - ); + $this->assertEmptyLog(); } } diff --git a/Tests/Functional/Import/DestinationDataTest/ImportDoesntEndUpInEndlessDateCreationTest.php b/Tests/Functional/Import/DestinationDataTest/ImportDoesntEndUpInEndlessDateCreationTest.php index 2e3bd04..69b4722 100644 --- a/Tests/Functional/Import/DestinationDataTest/ImportDoesntEndUpInEndlessDateCreationTest.php +++ b/Tests/Functional/Import/DestinationDataTest/ImportDoesntEndUpInEndlessDateCreationTest.php @@ -3,7 +3,6 @@ namespace Wrm\Events\Tests\Functional\Import\DestinationDataTest; use GuzzleHttp\Psr7\Response; -use TYPO3\CMS\Core\Utility\GeneralUtility; class ImportDoesntEndUpInEndlessDateCreationTest extends AbstractTest { @@ -12,10 +11,6 @@ class ImportDoesntEndUpInEndlessDateCreationTest extends AbstractTest */ public function importsExampleAsExpected(): void { - $fileImportPathConfiguration = 'staedte/beispielstadt/events/'; - $fileImportPath = $this->getInstancePath() . '/fileadmin/' . $fileImportPathConfiguration; - GeneralUtility::mkdir_deep($fileImportPath); - $this->setDateAspect(new \DateTimeImmutable('2022-07-01'), new \DateTimeZone('Europe/Berlin')); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/DefaultImportConfiguration.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleRegion.php'); @@ -38,10 +33,6 @@ class ImportDoesntEndUpInEndlessDateCreationTest extends AbstractTest self::assertSame(0, $tester->getStatusCode()); $this->assertCSVDataSet('EXT:events/Tests/Functional/Import/DestinationDataTest/Assertions/ImportDoesntEndUpInEndlessDateCreationTest.csv'); - self::assertFileEquals( - __DIR__ . '/Assertions/EmptyLogFile.txt', - $this->getInstancePath() . '/typo3temp/var/log/typo3_0493d91d8e.log', - 'Logfile was not empty.' - ); + $this->assertEmptyLog(); } } diff --git a/Tests/Functional/Import/DestinationDataTest/ImportHandlesImagesTest.php b/Tests/Functional/Import/DestinationDataTest/ImportHandlesImagesTest.php index d7930c4..2f7815b 100644 --- a/Tests/Functional/Import/DestinationDataTest/ImportHandlesImagesTest.php +++ b/Tests/Functional/Import/DestinationDataTest/ImportHandlesImagesTest.php @@ -57,11 +57,7 @@ class ImportHandlesImagesTest extends AbstractTest 'Got unexpected number of files' ); - self::assertFileEquals( - __DIR__ . '/Assertions/EmptyLogFile.txt', - $this->getInstancePath() . '/typo3temp/var/log/typo3_0493d91d8e.log', - 'Logfile was not empty.' - ); + $this->assertEmptyLog(); } /** @@ -90,11 +86,7 @@ class ImportHandlesImagesTest extends AbstractTest 'Got unexpected number of files' ); - self::assertFileEquals( - __DIR__ . '/Assertions/EmptyLogFile.txt', - $this->getInstancePath() . '/typo3temp/var/log/typo3_0493d91d8e.log', - 'Logfile was not empty.' - ); + $this->assertEmptyLog(); } /** @@ -126,11 +118,7 @@ class ImportHandlesImagesTest extends AbstractTest 'Got unexpected number of files' ); - self::assertFileEquals( - __DIR__ . '/Assertions/EmptyLogFile.txt', - $this->getInstancePath() . '/typo3temp/var/log/typo3_0493d91d8e.log', - 'Logfile was not empty.' - ); + $this->assertEmptyLog(); } /** @@ -163,11 +151,7 @@ class ImportHandlesImagesTest extends AbstractTest 'Got unexpected number of files' ); - self::assertFileEquals( - __DIR__ . '/Assertions/EmptyLogFile.txt', - $this->getInstancePath() . '/typo3temp/var/log/typo3_0493d91d8e.log', - 'Logfile was not empty.' - ); + $this->assertEmptyLog(); } /** @@ -202,11 +186,7 @@ class ImportHandlesImagesTest extends AbstractTest 'Got unexpected number of files' ); - self::assertFileEquals( - __DIR__ . '/Assertions/EmptyLogFile.txt', - $this->getInstancePath() . '/typo3temp/var/log/typo3_0493d91d8e.log', - 'Logfile was not empty.' - ); + $this->assertEmptyLog(); } /** @@ -239,10 +219,6 @@ class ImportHandlesImagesTest extends AbstractTest 'Got unexpected number of files' ); - self::assertFileEquals( - __DIR__ . '/Assertions/EmptyLogFile.txt', - $this->getInstancePath() . '/typo3temp/var/log/typo3_0493d91d8e.log', - 'Logfile was not empty.' - ); + $this->assertEmptyLog(); } } diff --git a/Tests/Functional/Import/DestinationDataTest/ImportsAllConfigurationTest.php b/Tests/Functional/Import/DestinationDataTest/ImportsAllConfigurationTest.php index e0ec73a..7ed2ed6 100644 --- a/Tests/Functional/Import/DestinationDataTest/ImportsAllConfigurationTest.php +++ b/Tests/Functional/Import/DestinationDataTest/ImportsAllConfigurationTest.php @@ -18,10 +18,6 @@ class ImportsAllConfigurationTest extends AbstractTest { $this->setDateAspect(new \DateTimeImmutable('2021-07-13', new \DateTimeZone('Europe/Berlin'))); - $fileImportPathConfiguration1 = 'staedte/beispielstadt/events/'; - $fileImportPath1 = $this->getInstancePath() . '/fileadmin/' . $fileImportPathConfiguration1; - GeneralUtility::mkdir_deep($fileImportPath1); - $fileImportPathConfiguration2 = 'staedte/anderestadt/events/'; $fileImportPath2 = $this->getInstancePath() . '/fileadmin/' . $fileImportPathConfiguration2; GeneralUtility::mkdir_deep($fileImportPath2); @@ -78,7 +74,7 @@ class ImportsAllConfigurationTest extends AbstractTest ); $this->assertCSVDataSet('EXT:events/Tests/Functional/Import/DestinationDataTest/Assertions/ImportsAllConfigurationTest.csv'); - $importedFiles = GeneralUtility::getFilesInDir($fileImportPath1); + $importedFiles = GeneralUtility::getFilesInDir($this->fileImportPath); self::assertIsArray($importedFiles, 'Failed to retrieve imported files from filesystem.'); self::assertSame( [ @@ -102,10 +98,6 @@ class ImportsAllConfigurationTest extends AbstractTest 'Got unexpected number of files' ); - self::assertFileEquals( - __DIR__ . '/Assertions/EmptyLogFile.txt', - $this->getInstancePath() . '/typo3temp/var/log/typo3_0493d91d8e.log', - 'Logfile was not empty.' - ); + $this->assertEmptyLog(); } } diff --git a/Tests/Functional/Import/DestinationDataTest/ImportsExampleAsExpectedTest.php b/Tests/Functional/Import/DestinationDataTest/ImportsExampleAsExpectedTest.php index c3f17ce..7ec50a4 100644 --- a/Tests/Functional/Import/DestinationDataTest/ImportsExampleAsExpectedTest.php +++ b/Tests/Functional/Import/DestinationDataTest/ImportsExampleAsExpectedTest.php @@ -17,10 +17,6 @@ class ImportsExampleAsExpectedTest extends AbstractTest { $this->setDateAspect(new \DateTimeImmutable('2021-07-13', new \DateTimeZone('Europe/Berlin'))); - $fileImportPathConfiguration = 'staedte/beispielstadt/events/'; - $fileImportPath = $this->getInstancePath() . '/fileadmin/' . $fileImportPathConfiguration; - GeneralUtility::mkdir_deep($fileImportPath); - $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleImportConfigurationWithCategories.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleRegion.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleCategory.php'); @@ -62,7 +58,7 @@ class ImportsExampleAsExpectedTest extends AbstractTest ); $this->assertCSVDataSet('EXT:events/Tests/Functional/Import/DestinationDataTest/Assertions/ImportsExampleAsExpected.csv'); - $importedFiles = GeneralUtility::getFilesInDir($fileImportPath); + $importedFiles = GeneralUtility::getFilesInDir($this->fileImportPath); self::assertIsArray($importedFiles, 'Failed to retrieve imported files from filesystem.'); self::assertSame( [ @@ -74,10 +70,6 @@ class ImportsExampleAsExpectedTest extends AbstractTest 'Got unexpected number of files' ); - self::assertFileEquals( - __DIR__ . '/Assertions/EmptyLogFile.txt', - $this->getInstancePath() . '/typo3temp/var/log/typo3_0493d91d8e.log', - 'Logfile was not empty.' - ); + $this->assertEmptyLog(); } } diff --git a/Tests/Functional/Import/DestinationDataTest/ImportsFeaturesTest.php b/Tests/Functional/Import/DestinationDataTest/ImportsFeaturesTest.php index e710be4..932ae8a 100644 --- a/Tests/Functional/Import/DestinationDataTest/ImportsFeaturesTest.php +++ b/Tests/Functional/Import/DestinationDataTest/ImportsFeaturesTest.php @@ -25,10 +25,6 @@ class ImportsFeaturesTest extends AbstractTest $tester = $this->executeCommand(); $this->assertCSVDataSet('EXT:events/Tests/Functional/Import/DestinationDataTest/Assertions/ImportsFeaturesAddsNewFeatures.csv'); - self::assertFileEquals( - __DIR__ . '/Assertions/EmptyLogFile.txt', - $this->getInstancePath() . '/typo3temp/var/log/typo3_0493d91d8e.log', - 'Logfile was not empty.' - ); + $this->assertEmptyLog(); } } diff --git a/Tests/Functional/Import/DestinationDataTest/ImportsFirstDateOfDatesTest.php b/Tests/Functional/Import/DestinationDataTest/ImportsFirstDateOfDatesTest.php index 7ffc408..5d3344c 100644 --- a/Tests/Functional/Import/DestinationDataTest/ImportsFirstDateOfDatesTest.php +++ b/Tests/Functional/Import/DestinationDataTest/ImportsFirstDateOfDatesTest.php @@ -30,11 +30,7 @@ class ImportsFirstDateOfDatesTest extends AbstractTest $this->executeCommand(); $this->assertCSVDataSet('EXT:events/Tests/Functional/Import/DestinationDataTest/Assertions/ImportsFirstDateOfSingleDate.csv'); - self::assertFileEquals( - __DIR__ . '/Assertions/EmptyLogFile.txt', - $this->getInstancePath() . '/typo3temp/var/log/typo3_0493d91d8e.log', - 'Logfile was not empty.' - ); + $this->assertEmptyLog(); } /** @@ -47,11 +43,7 @@ class ImportsFirstDateOfDatesTest extends AbstractTest $this->executeCommand(); $this->assertCSVDataSet('EXT:events/Tests/Functional/Import/DestinationDataTest/Assertions/ImportsFirstDateOfRecurringDatesWeekly.csv'); - self::assertFileEquals( - __DIR__ . '/Assertions/EmptyLogFile.txt', - $this->getInstancePath() . '/typo3temp/var/log/typo3_0493d91d8e.log', - 'Logfile was not empty.' - ); + $this->assertEmptyLog(); } /** @@ -64,10 +56,6 @@ class ImportsFirstDateOfDatesTest extends AbstractTest $this->executeCommand(); $this->assertCSVDataSet('EXT:events/Tests/Functional/Import/DestinationDataTest/Assertions/ImportsFirstDateOfRecurringDatesDaily.csv'); - self::assertFileEquals( - __DIR__ . '/Assertions/EmptyLogFile.txt', - $this->getInstancePath() . '/typo3temp/var/log/typo3_0493d91d8e.log', - 'Logfile was not empty.' - ); + $this->assertEmptyLog(); } } diff --git a/Tests/Functional/Import/DestinationDataTest/ImportsSingleConfigurationTest.php b/Tests/Functional/Import/DestinationDataTest/ImportsSingleConfigurationTest.php index 8db8bfe..8422256 100644 --- a/Tests/Functional/Import/DestinationDataTest/ImportsSingleConfigurationTest.php +++ b/Tests/Functional/Import/DestinationDataTest/ImportsSingleConfigurationTest.php @@ -17,10 +17,6 @@ class ImportsSingleConfigurationTest extends AbstractTest { $this->setDateAspect(new \DateTimeImmutable('2021-07-13', new \DateTimeZone('Europe/Berlin'))); - $fileImportPathConfiguration = 'staedte/beispielstadt/events/'; - $fileImportPath = $this->getInstancePath() . '/fileadmin/' . $fileImportPathConfiguration; - GeneralUtility::mkdir_deep($fileImportPath); - $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleRegion.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleCategory.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleImportConfiguration.php'); @@ -62,7 +58,7 @@ class ImportsSingleConfigurationTest extends AbstractTest ); $this->assertCSVDataSet('EXT:events/Tests/Functional/Import/DestinationDataTest/Assertions/ImportsExampleAsExpected.csv'); - $importedFiles = GeneralUtility::getFilesInDir($fileImportPath); + $importedFiles = GeneralUtility::getFilesInDir($this->fileImportPath); self::assertIsArray($importedFiles, 'Failed to retrieve imported files from filesystem.'); self::assertSame( [ @@ -74,10 +70,6 @@ class ImportsSingleConfigurationTest extends AbstractTest 'Got unexpected number of files' ); - self::assertFileEquals( - __DIR__ . '/Assertions/EmptyLogFile.txt', - $this->getInstancePath() . '/typo3temp/var/log/typo3_0493d91d8e.log', - 'Logfile was not empty.' - ); + $this->assertEmptyLog(); } } diff --git a/Tests/Functional/Import/DestinationDataTest/ImportsTicketsTest.php b/Tests/Functional/Import/DestinationDataTest/ImportsTicketsTest.php index bf1c7f4..50ce39f 100644 --- a/Tests/Functional/Import/DestinationDataTest/ImportsTicketsTest.php +++ b/Tests/Functional/Import/DestinationDataTest/ImportsTicketsTest.php @@ -3,7 +3,6 @@ namespace Wrm\Events\Tests\Functional\Import\DestinationDataTest; use GuzzleHttp\Psr7\Response; -use TYPO3\CMS\Core\Utility\GeneralUtility; /** * @testdox DestinationData import @@ -17,10 +16,6 @@ class ImportsTicketsTest extends AbstractTest */ public function importsExampleAsExpected(): void { - $fileImportPathConfiguration = 'staedte/beispielstadt/events/'; - $fileImportPath = $this->getInstancePath() . '/fileadmin/' . $fileImportPathConfiguration; - GeneralUtility::mkdir_deep($fileImportPath); - $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/DefaultImportConfiguration.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleRegion.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleCategory.php'); @@ -46,10 +41,6 @@ class ImportsTicketsTest extends AbstractTest $this->assertCSVDataSet('EXT:events/Tests/Functional/Import/DestinationDataTest/Assertions/ImportsTickets.csv'); - self::assertFileEquals( - __DIR__ . '/Assertions/EmptyLogFile.txt', - $this->getInstancePath() . '/typo3temp/var/log/typo3_0493d91d8e.log', - 'Logfile was not empty.' - ); + $this->assertEmptyLog(); } } diff --git a/Tests/Functional/Import/DestinationDataTest/ImportsWithConfiguredRepeatUntilTest.php b/Tests/Functional/Import/DestinationDataTest/ImportsWithConfiguredRepeatUntilTest.php index 47a9a68..bfa6286 100644 --- a/Tests/Functional/Import/DestinationDataTest/ImportsWithConfiguredRepeatUntilTest.php +++ b/Tests/Functional/Import/DestinationDataTest/ImportsWithConfiguredRepeatUntilTest.php @@ -32,11 +32,7 @@ class ImportsWithConfiguredRepeatUntilTest extends AbstractTest $this->executeCommand(); $this->assertCSVDataSet('EXT:events/Tests/Functional/Import/DestinationDataTest/Assertions/ImportsRecurringDatesWeeklyWithConfiguredRepeatUntil.csv'); - self::assertFileEquals( - __DIR__ . '/Assertions/EmptyLogFile.txt', - $this->getInstancePath() . '/typo3temp/var/log/typo3_0493d91d8e.log', - 'Logfile was not empty.' - ); + $this->assertEmptyLog(); } /** @@ -54,10 +50,6 @@ class ImportsWithConfiguredRepeatUntilTest extends AbstractTest $this->executeCommand(); $this->assertCSVDataSet('EXT:events/Tests/Functional/Import/DestinationDataTest/Assertions/ImportsRecurringDatesDailyWithConfiguredRepeatUntil.csv'); - self::assertFileEquals( - __DIR__ . '/Assertions/EmptyLogFile.txt', - $this->getInstancePath() . '/typo3temp/var/log/typo3_0493d91d8e.log', - 'Logfile was not empty.' - ); + $this->assertEmptyLog(); } } diff --git a/Tests/Functional/Import/DestinationDataTest/ImportsWithLocationsTest.php b/Tests/Functional/Import/DestinationDataTest/ImportsWithLocationsTest.php index 62f2726..41bff4d 100644 --- a/Tests/Functional/Import/DestinationDataTest/ImportsWithLocationsTest.php +++ b/Tests/Functional/Import/DestinationDataTest/ImportsWithLocationsTest.php @@ -3,24 +3,17 @@ namespace Wrm\Events\Tests\Functional\Import\DestinationDataTest; use GuzzleHttp\Psr7\Response; -use TYPO3\CMS\Core\Utility\GeneralUtility; /** * @testdox DestinationData import */ class ImportsWithLocationsTest extends AbstractTest { - /** - * @test - */ - public function importsWithLocations(): void + protected function setUp(): void { - $fileImportPathConfiguration = 'staedte/beispielstadt/events/'; - $fileImportPath = $this->getInstancePath() . '/fileadmin/' . $fileImportPathConfiguration; - GeneralUtility::mkdir_deep($fileImportPath); + parent::setUp(); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/DefaultImportConfiguration.php'); - $this->setUpConfiguration([ 'restUrl = https://example.com/some-path/', 'license = example-license', @@ -29,7 +22,13 @@ class ImportsWithLocationsTest extends AbstractTest 'restMode = next_months,12', 'restTemplate = ET2014A.json', ]); + } + /** + * @test + */ + public function importsWithLocations(): void + { $requests = &$this->setUpResponses([ new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ResponseWithLocations.json') ?: ''), ]); @@ -37,10 +36,6 @@ class ImportsWithLocationsTest extends AbstractTest self::assertSame(0, $tester->getStatusCode()); $this->assertCSVDataSet('EXT:events/Tests/Functional/Import/DestinationDataTest/Assertions/ImportsWithLocations.csv'); - self::assertFileEquals( - __DIR__ . '/Assertions/EmptyLogFile.txt', - $this->getInstancePath() . '/typo3temp/var/log/typo3_0493d91d8e.log', - 'Logfile was not empty.' - ); + $this->assertEmptyLog(); } } diff --git a/Tests/Functional/Import/DestinationDataTest/ImportsWithoutCategoryIfNotProvidedTest.php b/Tests/Functional/Import/DestinationDataTest/ImportsWithoutCategoryIfNotProvidedTest.php index 68e1873..b8cccd3 100644 --- a/Tests/Functional/Import/DestinationDataTest/ImportsWithoutCategoryIfNotProvidedTest.php +++ b/Tests/Functional/Import/DestinationDataTest/ImportsWithoutCategoryIfNotProvidedTest.php @@ -15,10 +15,6 @@ class ImportsWithoutCategoryIfNotProvidedTest extends AbstractTest */ public function importsWithoutCategoryIfNotProvided(): void { - $fileImportPathConfiguration = 'staedte/beispielstadt/events/'; - $fileImportPath = $this->getInstancePath() . '/fileadmin/' . $fileImportPathConfiguration; - GeneralUtility::mkdir_deep($fileImportPath); - $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/DefaultImportConfiguration.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleRegion.php'); $this->setUpConfiguration([ @@ -64,7 +60,7 @@ class ImportsWithoutCategoryIfNotProvidedTest extends AbstractTest ); $this->assertCSVDataSet('EXT:events/Tests/Functional/Import/DestinationDataTest/Assertions/ImportsWithoutCategoryIfNotProvided.csv'); - $importedFiles = GeneralUtility::getFilesInDir($fileImportPath); + $importedFiles = GeneralUtility::getFilesInDir($this->fileImportPath); self::assertIsArray($importedFiles, 'Failed to retrieve imported files from filesystem.'); self::assertSame( [ @@ -76,10 +72,6 @@ class ImportsWithoutCategoryIfNotProvidedTest extends AbstractTest 'Got unexpected number of files' ); - self::assertFileEquals( - __DIR__ . '/Assertions/EmptyLogFile.txt', - $this->getInstancePath() . '/typo3temp/var/log/typo3_0493d91d8e.log', - 'Logfile was not empty.' - ); + $this->assertEmptyLog(); } } diff --git a/Tests/Functional/Import/DestinationDataTest/ImportsWithoutLocationTest.php b/Tests/Functional/Import/DestinationDataTest/ImportsWithoutLocationTest.php index a9b8f74..9bf69e7 100644 --- a/Tests/Functional/Import/DestinationDataTest/ImportsWithoutLocationTest.php +++ b/Tests/Functional/Import/DestinationDataTest/ImportsWithoutLocationTest.php @@ -3,7 +3,6 @@ namespace Wrm\Events\Tests\Functional\Import\DestinationDataTest; use GuzzleHttp\Psr7\Response; -use TYPO3\CMS\Core\Utility\GeneralUtility; /** * @testdox DestinationData import @@ -15,10 +14,6 @@ class ImportsWithoutLocationTest extends AbstractTest */ public function importsWithoutLocationIfNotProvided(): void { - $fileImportPathConfiguration = 'staedte/beispielstadt/events/'; - $fileImportPath = $this->getInstancePath() . '/fileadmin/' . $fileImportPathConfiguration; - GeneralUtility::mkdir_deep($fileImportPath); - $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleImportConfigurationWithoutRegion.php'); $this->setUpConfiguration([ 'restUrl = https://example.com/some-path/', @@ -41,10 +36,6 @@ class ImportsWithoutLocationTest extends AbstractTest 'Added unexpected location.' ); $this->assertCSVDataSet('EXT:events/Tests/Functional/Import/DestinationDataTest/Assertions/ImportsWithoutLocationIfNotProvided.csv'); - self::assertFileEquals( - __DIR__ . '/Assertions/EmptyLogFile.txt', - $this->getInstancePath() . '/typo3temp/var/log/typo3_0493d91d8e.log', - 'Logfile was not empty.' - ); + $this->assertEmptyLog(); } } diff --git a/Tests/Functional/Import/DestinationDataTest/ImportsWithoutRegionIfNotProvidedTest.php b/Tests/Functional/Import/DestinationDataTest/ImportsWithoutRegionIfNotProvidedTest.php index f763110..b189791 100644 --- a/Tests/Functional/Import/DestinationDataTest/ImportsWithoutRegionIfNotProvidedTest.php +++ b/Tests/Functional/Import/DestinationDataTest/ImportsWithoutRegionIfNotProvidedTest.php @@ -15,10 +15,6 @@ class ImportsWithoutRegionIfNotProvidedTest extends AbstractTest */ public function importsWithoutRegionIfNotProvided(): void { - $fileImportPathConfiguration = 'staedte/beispielstadt/events/'; - $fileImportPath = $this->getInstancePath() . '/fileadmin/' . $fileImportPathConfiguration; - GeneralUtility::mkdir_deep($fileImportPath); - $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleImportConfigurationWithoutRegion.php'); $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/SingleCategory.php'); $this->setUpConfiguration([ @@ -58,7 +54,7 @@ class ImportsWithoutRegionIfNotProvidedTest extends AbstractTest ); $this->assertCSVDataSet('EXT:events/Tests/Functional/Import/DestinationDataTest/Assertions/ImportsWithoutRegionIfNotProvided.csv'); - $importedFiles = GeneralUtility::getFilesInDir($fileImportPath); + $importedFiles = GeneralUtility::getFilesInDir($this->fileImportPath); self::assertIsArray($importedFiles, 'Failed to retrieve imported files from filesystem.'); self::assertSame( [ @@ -70,10 +66,6 @@ class ImportsWithoutRegionIfNotProvidedTest extends AbstractTest 'Got unexpected number of files' ); - self::assertFileEquals( - __DIR__ . '/Assertions/EmptyLogFile.txt', - $this->getInstancePath() . '/typo3temp/var/log/typo3_0493d91d8e.log', - 'Logfile was not empty.' - ); + $this->assertEmptyLog(); } }