From 44efc02e12738640ceb51dfef95fdd818f14bd3d Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Tue, 4 Jul 2023 07:28:48 +0200 Subject: [PATCH] De-duplicate code within functional tests --- 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 32fd3d5c..b4171109 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 1648764e..43e804c6 100644 --- a/Tests/Functional/Import/DestinationDataTest/AbstractTest.php +++ b/Tests/Functional/Import/DestinationDataTest/AbstractTest.php @@ -16,4 +16,13 @@ protected function setUp(): void $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 b2ef1132..4672bc79 100644 --- a/Tests/Functional/Import/DestinationDataTest/ImportCleansTransientFilesTest.php +++ b/Tests/Functional/Import/DestinationDataTest/ImportCleansTransientFilesTest.php @@ -59,10 +59,6 @@ public function cleansTransientFiles(): void 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 59e1b72d..282fc843 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 @@ public function doesNotUseUploadsFolder(): void 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 @@ public function doesNotUseUploadsFolder(): void 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 09799da1..5aafb5f0 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 @@ public function importsExampleAsExpected(): void 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 2e3bd045..69b47224 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 @@ public function importsExampleAsExpected(): void 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 d7930c48..2f7815b4 100644 --- a/Tests/Functional/Import/DestinationDataTest/ImportHandlesImagesTest.php +++ b/Tests/Functional/Import/DestinationDataTest/ImportHandlesImagesTest.php @@ -57,11 +57,7 @@ public function addsNewImages(): void '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 @@ public function addsMultipleImagesToSingleEvent(): void '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 @@ public function removesNoLongerExistingImages(): void '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 @@ public function updatesExistingImage(): void '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 @@ public function addsNewImageToExistingImages(): void '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 @@ public function updatesSortingOfImages(): void '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 e0ec73a6..7ed2ed63 100644 --- a/Tests/Functional/Import/DestinationDataTest/ImportsAllConfigurationTest.php +++ b/Tests/Functional/Import/DestinationDataTest/ImportsAllConfigurationTest.php @@ -18,10 +18,6 @@ public function importsConfiguration(): void { $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 @@ public function importsConfiguration(): void ); $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 @@ public function importsConfiguration(): void '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 c3f17ce7..7ec50a4c 100644 --- a/Tests/Functional/Import/DestinationDataTest/ImportsExampleAsExpectedTest.php +++ b/Tests/Functional/Import/DestinationDataTest/ImportsExampleAsExpectedTest.php @@ -17,10 +17,6 @@ public function importsExampleAsExpected(): void { $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 @@ public function importsExampleAsExpected(): void ); $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 @@ public function importsExampleAsExpected(): void '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 e710be45..932ae8a9 100644 --- a/Tests/Functional/Import/DestinationDataTest/ImportsFeaturesTest.php +++ b/Tests/Functional/Import/DestinationDataTest/ImportsFeaturesTest.php @@ -25,10 +25,6 @@ public function addsNewFeatures(): void $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 7ffc4085..5d3344c5 100644 --- a/Tests/Functional/Import/DestinationDataTest/ImportsFirstDateOfDatesTest.php +++ b/Tests/Functional/Import/DestinationDataTest/ImportsFirstDateOfDatesTest.php @@ -30,11 +30,7 @@ public function singelDate(): void $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 @@ public function recurringWeekly(): void $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 @@ public function recurringDaily(): void $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 8db8bfea..84222561 100644 --- a/Tests/Functional/Import/DestinationDataTest/ImportsSingleConfigurationTest.php +++ b/Tests/Functional/Import/DestinationDataTest/ImportsSingleConfigurationTest.php @@ -17,10 +17,6 @@ public function importsConfiguration(): void { $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 @@ public function importsConfiguration(): void ); $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 @@ public function importsConfiguration(): void '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 bf1c7f4b..50ce39f8 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 @@ public function importsExampleAsExpected(): void $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 47a9a685..bfa62864 100644 --- a/Tests/Functional/Import/DestinationDataTest/ImportsWithConfiguredRepeatUntilTest.php +++ b/Tests/Functional/Import/DestinationDataTest/ImportsWithConfiguredRepeatUntilTest.php @@ -32,11 +32,7 @@ public function recurringWeekly(): void $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 @@ public function recurringDaily(): void $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 62f27263..41bff4d6 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 @@ public function importsWithLocations(): void '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 @@ public function importsWithLocations(): void 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 68e1873f..b8cccd3f 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 @@ public function importsWithoutCategoryIfNotProvided(): void ); $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 @@ public function importsWithoutCategoryIfNotProvided(): void '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 a9b8f74b..9bf69e74 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 @@ public function importsWithoutLocationIfNotProvided(): void '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 f7631101..b1897910 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 @@ public function importsWithoutRegionIfNotProvided(): void ); $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 @@ public function importsWithoutRegionIfNotProvided(): void '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(); } }