diff --git a/Classes/Service/DestinationDataImportService.php b/Classes/Service/DestinationDataImportService.php index 0bef308..eac3cce 100644 --- a/Classes/Service/DestinationDataImportService.php +++ b/Classes/Service/DestinationDataImportService.php @@ -380,6 +380,10 @@ class DestinationDataImportService */ private function setCategories(array $categories): void { + if ($this->categoryParentUid === 0) { + return; + } + $sysParentCategory = $this->sysCategoriesRepository->findByUid($this->categoryParentUid); if (!$sysParentCategory instanceof Category) { $this->logger->warning( diff --git a/Tests/Functional/Import/DestinationDataTest/Assertions/EmptyLogFile.txt b/Tests/Functional/Import/DestinationDataTest/Assertions/EmptyLogFile.txt new file mode 100644 index 0000000..e69de29 diff --git a/Tests/Functional/Import/DestinationDataTest/Assertions/ImportsExampleAsExpected.csv b/Tests/Functional/Import/DestinationDataTest/Assertions/ImportsExampleAsExpected.csv index d11b7ba..900d31a 100644 --- a/Tests/Functional/Import/DestinationDataTest/Assertions/ImportsExampleAsExpected.csv +++ b/Tests/Functional/Import/DestinationDataTest/Assertions/ImportsExampleAsExpected.csv @@ -8,14 +8,14 @@ ,"1","2","0","0","0","0","0","-1","0","0","0","0","0","Allerlei Weihnachtliches (Heute mit Johannes Geißer)",,"e_100347853","e-100347853","0",,"Die Lichter sind entzündet, die Plätzchen duften, man rückt endlich wieder näher zusammen und lauscht den Geschichten. Vier Schauspieler*innen unseres Theaters überraschen mit ihren weihnachtlichen Texten, die sie für uns ausgewählt haben. Dazu plaudern sie über persönliche Anekdoten und erinnern sich an ihre schönsten und verrücktesten Weihnachtsfeste. Und da der Genuss in der Vorweihnachtszeit nicht fehlen darf, wird an jedem Adventssonntag eine andere weihnachtliche Spezialität serviert. Eintritt: 10 € (inkl. Gedeck mit weihnachtlicher Schillerlocke) Um Voranmeldung unter 03672-486470 oder schillerhaus@rudolstadt.de wird gebeten. -Es gilt die 2G-PLUS-Regel.",,"Schillerhaus Rudolstadt","Schillerstraße 25",,"Rudolstadt","07407","Deutschland","http://www.schillerhaus.rudolstadt.de/","+ 49 3672 / 486470",,,,,"50.720971023259","11.335229873657","1","0",,"1","1",,"1", +Es gilt die 2G-PLUS-Regel.",,"Schillerhaus Rudolstadt","Schillerstraße 25",,"Rudolstadt","07407","Deutschland","http://www.schillerhaus.rudolstadt.de/","+ 49 3672 / 486470",,,,,"50.720971023259","11.335229873657","1","1",,"1","1",,"1", ,"2","2","0","0","0","0","0","-1","0","0","0","0","0","Tüftlerzeit",,"e_100354481","e-100354481","0",,"Die Tüftlerzeit wird dieses Mal ein weihnachtliches Angebot bereithalten. Alle kleinen Tüftler dürfen gespannt sein. Voranmeldung über: kinderbibliothek@rudolstadt.de oder 03672-486420 -Bitte beachten Sie die derzeit geltenden Zugangsregeln.",,"Stadtbibliothek Rudolstadt","Schulplatz 13",,"Rudolstadt","07407","Deutschland","http://www.stadtbibliothek-rudolstadt.de/","0 36 72 - 48 64 20",,,,,"50.720835175056","11.342568397522","1","0",,"3","2",,"1", +Bitte beachten Sie die derzeit geltenden Zugangsregeln.",,"Stadtbibliothek Rudolstadt","Schulplatz 13",,"Rudolstadt","07407","Deutschland","http://www.stadtbibliothek-rudolstadt.de/","0 36 72 - 48 64 20",,,,,"50.720835175056","11.342568397522","1","1",,"3","2",,"1", ,"3","2","0","0","0","0","0","-1","0","0","0","0","0","Adventliche Orgelmusik (Orgel: KMD Frank Bettenhausen)",,"e_100350503","e-100350503","0",,"Immer mittwochs in der Adventszeit spielt Frank Bettenhausen solo und zusammen mit anderen Musikern auf der Steinmeyerorgel aus dem Jahr 1906. Bekannte Adventslieder, barocke und romantische Kompositionen stehen neben besinnlichen Texten von Pfarrer Johannes-Martin Weiss. -Es gilt die 2G-PLUS-Regel.",,"Lutherkirche","Caspar-Schulte-Straße",,"Rudolstadt","07407","Deutschland",,"03672 - 48 96 13",,,,,"50.718688721183","11.327333450317","1","0",,"4","3",,"1", +Es gilt die 2G-PLUS-Regel.",,"Lutherkirche","Caspar-Schulte-Straße",,"Rudolstadt","07407","Deutschland",,"03672 - 48 96 13",,,,,"50.718688721183","11.327333450317","1","2",,"4","3",,"1", "tx_events_domain_model_date",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ,"uid","pid","cruser_id","hidden","starttime","endtime","sys_language_uid","l10n_parent","t3ver_oid","t3ver_wsid","t3ver_state","event","start","end","canceled","postponed_date","canceled_link",,,,,,,,,,,,,,,,,,,,,,,,,, ,"1","2","0","0","0","0",-1,0,"0","0","0","1","4101372000","4101377400","no","0",,,,,,,,,,,,,,,,,,,,,,,,,,, @@ -26,3 +26,16 @@ Es gilt die 2G-PLUS-Regel.",,"Lutherkirche","Caspar-Schulte-Straße",,"Rudolstad ,"6","2","0","0","0","0",-1,0,"0","0","0","3","4100436000","4100439600","no","0",,,,,,,,,,,,,,,,,,,,,,,,,,, ,"7","2","0","0","0","0",-1,0,"0","0","0","3","4101040800","4101044400","no","0",,,,,,,,,,,,,,,,,,,,,,,,,,, ,"8","2","0","0","0","0",-1,0,"0","0","0","3","4101645600","4101649200","no","0",,,,,,,,,,,,,,,,,,,,,,,,,,, +"sys_category",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,"uid","pid","cruser_id","hidden","starttime","endtime","sys_language_uid","l10n_parent","title","items","parent",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,1,2,0,0,0,0,0,0,"Top Category",0,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,2,2,0,0,0,0,0,0,"Event Category Parent",0,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,3,2,0,0,0,0,0,0,"Weihnachten",0,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,4,2,0,0,0,0,0,0,"Kinder",0,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,5,2,0,0,0,0,0,0,"Konzerte, Festivals, Show & Tanz",0,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +"sys_category_record_mm",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,"uid_local","uid_foreign","tablenames","fieldname",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,3,1,"tx_events_domain_model_event","categories",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,4,2,"tx_events_domain_model_event","categories",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,5,3,"tx_events_domain_model_event","categories",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,3,3,"tx_events_domain_model_event","categories",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, diff --git a/Tests/Functional/Import/DestinationDataTest/Assertions/ImportsWithoutCategoryIfNotProvided.csv b/Tests/Functional/Import/DestinationDataTest/Assertions/ImportsWithoutCategoryIfNotProvided.csv new file mode 100644 index 0000000..d11b7ba --- /dev/null +++ b/Tests/Functional/Import/DestinationDataTest/Assertions/ImportsWithoutCategoryIfNotProvided.csv @@ -0,0 +1,28 @@ +"tx_events_domain_model_organizer",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,"uid","pid","cruser_id","deleted","hidden","starttime","endtime","sys_language_uid","l10n_parent","t3ver_oid","t3ver_wsid","t3ver_state","t3ver_stage","name","street","district","city","zip","phone","web","email",,,,,,,,,,,,,,,,,,,,,, +,"1","2","0","0","0","0","0","-1","0","0","0","0","0","Schillerhaus Rudolstadt","Schillerstraße 25",,"Rudolstadt","07407","+ 49 3672 / 486470","http://schillerhaus.rudolstadt.de","schillerhaus@rudolstadt.de",,,,,,,,,,,,,,,,,,,,,, +,"2","2","0","0","0","0","0","-1","0","0","0","0","0","Stadtbibliothek Rudolstadt","Schulplatz 13",,"Rudolstadt","07407","0 36 72 - 48 64 20","http://www.stadtbibliothek-rudolstadt.de ","stadtbibliothek@rudolstadt.de",,,,,,,,,,,,,,,,,,,,,, +,"3","2","0","0","0","0","0","-1","0","0","0","0","0","Lutherkirche","Caspar-Schulte-Straße",,"Rudolstadt","07407","03672 - 48 96 13",,,,,,,,,,,,,,,,,,,,,,,, +"tx_events_domain_model_event",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,"uid","pid","cruser_id","deleted","hidden","starttime","endtime","sys_language_uid","l10n_parent","t3ver_oid","t3ver_wsid","t3ver_state","t3ver_stage","title","subtitle","global_id","slug","highlight","teaser","details","price_info","name","street","district","city","zip","country","web","phone","ticket","facebook","youtube","instagram","latitude","longitude","images","categories","pages","dates","organizer","partner","region","references_events" +,"1","2","0","0","0","0","0","-1","0","0","0","0","0","Allerlei Weihnachtliches (Heute mit Johannes Geißer)",,"e_100347853","e-100347853","0",,"Die Lichter sind entzündet, die Plätzchen duften, man rückt endlich wieder näher zusammen und lauscht den Geschichten. Vier Schauspieler*innen unseres Theaters überraschen mit ihren weihnachtlichen Texten, die sie für uns ausgewählt haben. Dazu plaudern sie über persönliche Anekdoten und erinnern sich an ihre schönsten und verrücktesten Weihnachtsfeste. Und da der Genuss in der Vorweihnachtszeit nicht fehlen darf, wird an jedem Adventssonntag eine andere weihnachtliche Spezialität serviert. +Eintritt: 10 € (inkl. Gedeck mit weihnachtlicher Schillerlocke) +Um Voranmeldung unter 03672-486470 oder schillerhaus@rudolstadt.de wird gebeten. +Es gilt die 2G-PLUS-Regel.",,"Schillerhaus Rudolstadt","Schillerstraße 25",,"Rudolstadt","07407","Deutschland","http://www.schillerhaus.rudolstadt.de/","+ 49 3672 / 486470",,,,,"50.720971023259","11.335229873657","1","0",,"1","1",,"1", +,"2","2","0","0","0","0","0","-1","0","0","0","0","0","Tüftlerzeit",,"e_100354481","e-100354481","0",,"Die Tüftlerzeit wird dieses Mal ein weihnachtliches Angebot bereithalten. Alle kleinen Tüftler dürfen gespannt sein. +Voranmeldung über: kinderbibliothek@rudolstadt.de oder 03672-486420 + +Bitte beachten Sie die derzeit geltenden Zugangsregeln.",,"Stadtbibliothek Rudolstadt","Schulplatz 13",,"Rudolstadt","07407","Deutschland","http://www.stadtbibliothek-rudolstadt.de/","0 36 72 - 48 64 20",,,,,"50.720835175056","11.342568397522","1","0",,"3","2",,"1", +,"3","2","0","0","0","0","0","-1","0","0","0","0","0","Adventliche Orgelmusik (Orgel: KMD Frank Bettenhausen)",,"e_100350503","e-100350503","0",,"Immer mittwochs in der Adventszeit spielt Frank Bettenhausen solo und zusammen mit anderen Musikern auf der Steinmeyerorgel aus dem Jahr 1906. Bekannte Adventslieder, barocke und romantische Kompositionen stehen neben besinnlichen Texten von Pfarrer Johannes-Martin Weiss. + +Es gilt die 2G-PLUS-Regel.",,"Lutherkirche","Caspar-Schulte-Straße",,"Rudolstadt","07407","Deutschland",,"03672 - 48 96 13",,,,,"50.718688721183","11.327333450317","1","0",,"4","3",,"1", +"tx_events_domain_model_date",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,"uid","pid","cruser_id","hidden","starttime","endtime","sys_language_uid","l10n_parent","t3ver_oid","t3ver_wsid","t3ver_state","event","start","end","canceled","postponed_date","canceled_link",,,,,,,,,,,,,,,,,,,,,,,,,, +,"1","2","0","0","0","0",-1,0,"0","0","0","1","4101372000","4101377400","no","0",,,,,,,,,,,,,,,,,,,,,,,,,,, +,"2","2","0","0","0","0",-1,0,"0","0","0","2","4101112800","4101118200","no","0",,,,,,,,,,,,,,,,,,,,,,,,,,, +,"3","2","0","0","0","0",-1,0,"0","0","0","2","1642687200","1642694400","no","0",,,,,,,,,,,,,,,,,,,,,,,,,,, +,"4","2","0","0","0","0",-1,0,"0","0","0","2","1645106400","1645113600","no","0",,,,,,,,,,,,,,,,,,,,,,,,,,, +,"5","2","0","0","0","0",-1,0,"0","0","0","3","4099831200","4099834800","no","0",,,,,,,,,,,,,,,,,,,,,,,,,,, +,"6","2","0","0","0","0",-1,0,"0","0","0","3","4100436000","4100439600","no","0",,,,,,,,,,,,,,,,,,,,,,,,,,, +,"7","2","0","0","0","0",-1,0,"0","0","0","3","4101040800","4101044400","no","0",,,,,,,,,,,,,,,,,,,,,,,,,,, +,"8","2","0","0","0","0",-1,0,"0","0","0","3","4101645600","4101649200","no","0",,,,,,,,,,,,,,,,,,,,,,,,,,, diff --git a/Tests/Functional/Import/DestinationDataTest/Assertions/ImportsWithoutRegionIfNotProvided.csv b/Tests/Functional/Import/DestinationDataTest/Assertions/ImportsWithoutRegionIfNotProvided.csv index c1a68ec..caa07bf 100644 --- a/Tests/Functional/Import/DestinationDataTest/Assertions/ImportsWithoutRegionIfNotProvided.csv +++ b/Tests/Functional/Import/DestinationDataTest/Assertions/ImportsWithoutRegionIfNotProvided.csv @@ -8,14 +8,14 @@ ,"1","2","0","0","0","0","0","-1","0","0","0","0","0","Allerlei Weihnachtliches (Heute mit Johannes Geißer)",,"e_100347853","e-100347853","0",,"Die Lichter sind entzündet, die Plätzchen duften, man rückt endlich wieder näher zusammen und lauscht den Geschichten. Vier Schauspieler*innen unseres Theaters überraschen mit ihren weihnachtlichen Texten, die sie für uns ausgewählt haben. Dazu plaudern sie über persönliche Anekdoten und erinnern sich an ihre schönsten und verrücktesten Weihnachtsfeste. Und da der Genuss in der Vorweihnachtszeit nicht fehlen darf, wird an jedem Adventssonntag eine andere weihnachtliche Spezialität serviert. Eintritt: 10 € (inkl. Gedeck mit weihnachtlicher Schillerlocke) Um Voranmeldung unter 03672-486470 oder schillerhaus@rudolstadt.de wird gebeten. -Es gilt die 2G-PLUS-Regel.",,"Schillerhaus Rudolstadt","Schillerstraße 25",,"Rudolstadt","07407","Deutschland","http://www.schillerhaus.rudolstadt.de/","+ 49 3672 / 486470",,,,,"50.720971023259","11.335229873657","1","0",,"1","1",,"0", +Es gilt die 2G-PLUS-Regel.",,"Schillerhaus Rudolstadt","Schillerstraße 25",,"Rudolstadt","07407","Deutschland","http://www.schillerhaus.rudolstadt.de/","+ 49 3672 / 486470",,,,,"50.720971023259","11.335229873657","1","1",,"1","1",,"0", ,"2","2","0","0","0","0","0","-1","0","0","0","0","0","Tüftlerzeit",,"e_100354481","e-100354481","0",,"Die Tüftlerzeit wird dieses Mal ein weihnachtliches Angebot bereithalten. Alle kleinen Tüftler dürfen gespannt sein. Voranmeldung über: kinderbibliothek@rudolstadt.de oder 03672-486420 -Bitte beachten Sie die derzeit geltenden Zugangsregeln.",,"Stadtbibliothek Rudolstadt","Schulplatz 13",,"Rudolstadt","07407","Deutschland","http://www.stadtbibliothek-rudolstadt.de/","0 36 72 - 48 64 20",,,,,"50.720835175056","11.342568397522","1","0",,"3","2",,"0", +Bitte beachten Sie die derzeit geltenden Zugangsregeln.",,"Stadtbibliothek Rudolstadt","Schulplatz 13",,"Rudolstadt","07407","Deutschland","http://www.stadtbibliothek-rudolstadt.de/","0 36 72 - 48 64 20",,,,,"50.720835175056","11.342568397522","1","1",,"3","2",,"0", ,"3","2","0","0","0","0","0","-1","0","0","0","0","0","Adventliche Orgelmusik (Orgel: KMD Frank Bettenhausen)",,"e_100350503","e-100350503","0",,"Immer mittwochs in der Adventszeit spielt Frank Bettenhausen solo und zusammen mit anderen Musikern auf der Steinmeyerorgel aus dem Jahr 1906. Bekannte Adventslieder, barocke und romantische Kompositionen stehen neben besinnlichen Texten von Pfarrer Johannes-Martin Weiss. -Es gilt die 2G-PLUS-Regel.",,"Lutherkirche","Caspar-Schulte-Straße",,"Rudolstadt","07407","Deutschland",,"03672 - 48 96 13",,,,,"50.718688721183","11.327333450317","1","0",,"4","3",,"0", +Es gilt die 2G-PLUS-Regel.",,"Lutherkirche","Caspar-Schulte-Straße",,"Rudolstadt","07407","Deutschland",,"03672 - 48 96 13",,,,,"50.718688721183","11.327333450317","1","2",,"4","3",,"0", "tx_events_domain_model_date",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, ,"uid","pid","cruser_id","hidden","starttime","endtime","sys_language_uid","l10n_parent","t3ver_oid","t3ver_wsid","t3ver_state","event","start","end","canceled","postponed_date","canceled_link",,,,,,,,,,,,,,,,,,,,,,,,,, ,"1","2","0","0","0","0",-1,0,"0","0","0","1","4101372000","4101377400","no","0",,,,,,,,,,,,,,,,,,,,,,,,,,, @@ -26,3 +26,16 @@ Es gilt die 2G-PLUS-Regel.",,"Lutherkirche","Caspar-Schulte-Straße",,"Rudolstad ,"6","2","0","0","0","0",-1,0,"0","0","0","3","4100436000","4100439600","no","0",,,,,,,,,,,,,,,,,,,,,,,,,,, ,"7","2","0","0","0","0",-1,0,"0","0","0","3","4101040800","4101044400","no","0",,,,,,,,,,,,,,,,,,,,,,,,,,, ,"8","2","0","0","0","0",-1,0,"0","0","0","3","4101645600","4101649200","no","0",,,,,,,,,,,,,,,,,,,,,,,,,,, +"sys_category",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,"uid","pid","cruser_id","hidden","starttime","endtime","sys_language_uid","l10n_parent","title","items","parent",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,1,2,0,0,0,0,0,0,"Top Category",0,0,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,2,2,0,0,0,0,0,0,"Event Category Parent",0,1,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,3,2,0,0,0,0,0,0,"Weihnachten",0,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,4,2,0,0,0,0,0,0,"Kinder",0,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,5,2,0,0,0,0,0,0,"Konzerte, Festivals, Show & Tanz",0,2,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +"sys_category_record_mm",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,"uid_local","uid_foreign","tablenames","fieldname",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,3,1,"tx_events_domain_model_event","categories",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,4,2,"tx_events_domain_model_event","categories",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,5,3,"tx_events_domain_model_event","categories",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, +,3,3,"tx_events_domain_model_event","categories",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,, diff --git a/Tests/Functional/Import/DestinationDataTest/Fixtures/SingleCategory.xml b/Tests/Functional/Import/DestinationDataTest/Fixtures/SingleCategory.xml new file mode 100644 index 0000000..ca1c635 --- /dev/null +++ b/Tests/Functional/Import/DestinationDataTest/Fixtures/SingleCategory.xml @@ -0,0 +1,15 @@ + + + + 1 + 2 + Top Category + + + 2 + 2 + Event Category Parent + 1 + + + diff --git a/Tests/Functional/Import/DestinationDataTest/ImportCleansTransientFilesTest.php b/Tests/Functional/Import/DestinationDataTest/ImportCleansTransientFilesTest.php index 21efcaa..957242b 100644 --- a/Tests/Functional/Import/DestinationDataTest/ImportCleansTransientFilesTest.php +++ b/Tests/Functional/Import/DestinationDataTest/ImportCleansTransientFilesTest.php @@ -62,5 +62,11 @@ class ImportCleansTransientFilesTest extends AbstractTest $transientFiles = GeneralUtility::getFilesInDir(Environment::getVarPath() . '/transient/'); 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.' + ); } } diff --git a/Tests/Functional/Import/DestinationDataTest/ImportDoesNotUseUploadsFolderTest.php b/Tests/Functional/Import/DestinationDataTest/ImportDoesNotUseUploadsFolderTest.php index a2c644c..ece0b95 100644 --- a/Tests/Functional/Import/DestinationDataTest/ImportDoesNotUseUploadsFolderTest.php +++ b/Tests/Functional/Import/DestinationDataTest/ImportDoesNotUseUploadsFolderTest.php @@ -60,5 +60,11 @@ 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.' + ); } } diff --git a/Tests/Functional/Import/DestinationDataTest/ImportsExampleAsExpectedTest.php b/Tests/Functional/Import/DestinationDataTest/ImportsExampleAsExpectedTest.php index acaf5fa..0ce6f55 100644 --- a/Tests/Functional/Import/DestinationDataTest/ImportsExampleAsExpectedTest.php +++ b/Tests/Functional/Import/DestinationDataTest/ImportsExampleAsExpectedTest.php @@ -18,6 +18,7 @@ class ImportsExampleAsExpectedTest extends AbstractTest $fileImportPath = 'staedte/beispielstadt/events/'; $this->importDataSet('EXT:events/Tests/Functional/Import/DestinationDataTest/Fixtures/SingleRegion.xml'); + $this->importDataSet('EXT:events/Tests/Functional/Import/DestinationDataTest/Fixtures/SingleCategory.xml'); $this->setUpConfiguration([ 'restUrl = ' . $this->getInstancePath() . '/typo3conf/ext/events/Tests/Functional/Import/DestinationDataTest/Fixtures/Response.json', 'license = example-license', @@ -25,8 +26,8 @@ class ImportsExampleAsExpectedTest extends AbstractTest 'restLimit = 3', 'restMode = next_months,12', 'restTemplate = ET2014A.json', - 'categoriesPid = ', - 'categoryParentUid = ', + 'categoriesPid = 2', + 'categoryParentUid = 2', ]); $requests = &$this->setUpResponses([ @@ -61,7 +62,6 @@ class ImportsExampleAsExpectedTest extends AbstractTest ); $this->assertCSVDataSet('EXT:events/Tests/Functional/Import/DestinationDataTest/Assertions/ImportsExampleAsExpected.csv'); - $importedFiles = GeneralUtility::getFilesInDir($this->getInstancePath() . '/fileadmin/' . $fileImportPath); self::assertIsArray($importedFiles, 'Failed to retrieve imported files from filesystem.'); self::assertSame( @@ -73,5 +73,11 @@ class ImportsExampleAsExpectedTest extends AbstractTest array_values($importedFiles), 'Got unexpected number of files' ); + + 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/ImportsWithoutCategoryIfNotProvidedTest.php b/Tests/Functional/Import/DestinationDataTest/ImportsWithoutCategoryIfNotProvidedTest.php new file mode 100644 index 0000000..a817861 --- /dev/null +++ b/Tests/Functional/Import/DestinationDataTest/ImportsWithoutCategoryIfNotProvidedTest.php @@ -0,0 +1,88 @@ +importDataSet('EXT:events/Tests/Functional/Import/DestinationDataTest/Fixtures/SingleRegion.xml'); + $this->setUpConfiguration([ + 'restUrl = ' . $this->getInstancePath() . '/typo3conf/ext/events/Tests/Functional/Import/DestinationDataTest/Fixtures/Response.json', + 'license = example-license', + 'restType = Event', + 'restLimit = 3', + 'restMode = next_months,12', + 'restTemplate = ET2014A.json', + 'categoriesPid = ', + 'categoryParentUid = ', + ]); + + $requests = &$this->setUpResponses([ + new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ExampleImage.jpg') ?: ''), + new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ExampleImage.jpg') ?: ''), + new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ExampleImage.jpg') ?: ''), + ]); + + $tester = $this->executeCommand([ + 'storage-pid' => '2', + 'rest-experience' => 'beispielstadt', + 'files-folder' => $fileImportPath, + 'region-uid' => '1', + ]); + + self::assertSame(0, $tester->getStatusCode()); + + self::assertCount(3, $requests, 'Unexpected number of requests were made.'); + self::assertSame('https://dam.destination.one/849917/279ac45b3fc701a7197131f627164fffd9f8cc77bc75165e2fc2b864ed606920/theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg', (string)$requests[0]['request']->getUri()); + self::assertSame('https://dam.destination.one/828118/f13bbf5602ffc406ebae2faa3527654dea84194666bce4925a1ca8bd3f50c5e9/tueftlerzeit-sfz-rudolstadt-jpg.jpg', (string)$requests[1]['request']->getUri()); + self::assertSame('https://dam.destination.one/853436/109ac1cf87913e21b5e2b0ef0cc63d223a14374364952a855746a8e7c3fcfc36/lutherkirche-jpg.jpg', (string)$requests[2]['request']->getUri()); + + self::assertCount( + 0, + $this->getAllRecords('tx_events_domain_model_partner'), + 'Added unexpected partners.' + ); + self::assertCount( + 1, + $this->getAllRecords('tx_events_domain_model_region'), + 'Added or removed unexpected region.' + ); + self::assertCount( + 0, + $this->getAllRecords('sys_category'), + 'Added unexpected category.' + ); + $this->assertCSVDataSet('EXT:events/Tests/Functional/Import/DestinationDataTest/Assertions/ImportsWithoutCategoryIfNotProvided.csv'); + + + $importedFiles = GeneralUtility::getFilesInDir($this->getInstancePath() . '/fileadmin/' . $fileImportPath); + self::assertIsArray($importedFiles, 'Failed to retrieve imported files from filesystem.'); + self::assertSame( + [ + 'lutherkirche-jpg.jpg', + 'theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg', + 'tueftlerzeit-sfz-rudolstadt-jpg.jpg', + ], + array_values($importedFiles), + 'Got unexpected number of files' + ); + + 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/ImportsWithoutRegionIfNotProvidedTest.php b/Tests/Functional/Import/DestinationDataTest/ImportsWithoutRegionIfNotProvidedTest.php index e383e79..60f1dc7 100644 --- a/Tests/Functional/Import/DestinationDataTest/ImportsWithoutRegionIfNotProvidedTest.php +++ b/Tests/Functional/Import/DestinationDataTest/ImportsWithoutRegionIfNotProvidedTest.php @@ -16,6 +16,7 @@ class ImportsWithoutRegionIfNotProvidedTest extends AbstractTest public function importsWithoutRegionIfNotProvided(): void { $fileImportPath = 'staedte/beispielstadt/events/'; + $this->importDataSet('EXT:events/Tests/Functional/Import/DestinationDataTest/Fixtures/SingleCategory.xml'); $this->setUpConfiguration([ 'restUrl = ' . $this->getInstancePath() . '/typo3conf/ext/events/Tests/Functional/Import/DestinationDataTest/Fixtures/Response.json', 'license = example-license', @@ -23,8 +24,8 @@ class ImportsWithoutRegionIfNotProvidedTest extends AbstractTest 'restLimit = 3', 'restMode = next_months,12', 'restTemplate = ET2014A.json', - 'categoriesPid = ', - 'categoryParentUid = ', + 'categoriesPid = 2', + 'categoryParentUid = 2', ]); $requests = &$this->setUpResponses([ @@ -70,5 +71,11 @@ class ImportsWithoutRegionIfNotProvidedTest extends AbstractTest array_values($importedFiles), 'Got unexpected number of files' ); + + self::assertFileEquals( + __DIR__ . '/Assertions/EmptyLogFile.txt', + $this->getInstancePath() . '/typo3temp/var/log/typo3_0493d91d8e.log', + 'Logfile was not empty.' + ); } }