From 0d156e640e9c8e8399f23b3d6d0f2383aed294ba Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Wed, 24 Jan 2024 10:51:12 +0100 Subject: [PATCH] Add support for slogan as array Relates: #10890 --- .../Import/Entity/TouristAttraction.php | 15 ++-- .../Typo3Converter/GeneralConverter.php | 2 +- .../Model/Frontend/TouristAttraction.php | 10 ++- Documentation/Changelog/2.2.0.rst | 30 +++++++ Tests/Functional/AbstractImportTest.php | 3 + ...portsTouristAttractionWithSingleSlogan.php | 28 +++++++ ...mportsTouristAttractionWithSloganArray.php | 28 +++++++ .../attraction-with-single-slogan.json | 55 +++++++++++++ .../attraction-with-slogan-array.json | 65 +++++++++++++++ ...portsTouristAttractionWithSingleSlogan.php | 65 +++++++++++++++ ...mportsTouristAttractionWithSloganArray.php | 65 +++++++++++++++ Tests/Functional/ImportTest.php | 80 ++++++++++++------- .../Model/Frontend/TouristAttractionTest.php | 24 ++++++ composer.json | 1 + ext_emconf.php | 2 +- 15 files changed, 437 insertions(+), 36 deletions(-) create mode 100644 Documentation/Changelog/2.2.0.rst create mode 100644 Tests/Functional/Assertions/Import/ImportsTouristAttractionWithSingleSlogan.php create mode 100644 Tests/Functional/Assertions/Import/ImportsTouristAttractionWithSloganArray.php create mode 100644 Tests/Functional/Fixtures/Import/Guzzle/thuecat.org/resources/attraction-with-single-slogan.json create mode 100644 Tests/Functional/Fixtures/Import/Guzzle/thuecat.org/resources/attraction-with-slogan-array.json create mode 100644 Tests/Functional/Fixtures/Import/ImportsTouristAttractionWithSingleSlogan.php create mode 100644 Tests/Functional/Fixtures/Import/ImportsTouristAttractionWithSloganArray.php diff --git a/Classes/Domain/Import/Entity/TouristAttraction.php b/Classes/Domain/Import/Entity/TouristAttraction.php index fd2579ad..36219293 100644 --- a/Classes/Domain/Import/Entity/TouristAttraction.php +++ b/Classes/Domain/Import/Entity/TouristAttraction.php @@ -28,9 +28,9 @@ class TouristAttraction extends Place implements MapsToType { /** - * @var string + * @var string[] */ - protected $slogan = ''; + protected $slogan = []; /** * @var string @@ -77,7 +77,7 @@ class TouristAttraction extends Place implements MapsToType */ protected $availableLanguages = []; - public function getSlogan(): string + public function getSlogan(): array { return $this->slogan; } @@ -144,10 +144,15 @@ public function getAvailableLanguages(): array /** * @internal for mapping via Symfony component. + * + * @param string|array $slogan */ - public function setSlogan(string $slogan): void + public function setSlogan($slogan): void { - $this->slogan = PropertyValues::removePrefixFromEntry($slogan); + if (is_string($slogan)) { + $slogan = [$slogan]; + } + $this->slogan = PropertyValues::removePrefixFromEntries($slogan); } /** diff --git a/Classes/Domain/Import/Typo3Converter/GeneralConverter.php b/Classes/Domain/Import/Typo3Converter/GeneralConverter.php index 40613cbc..3b7aebb0 100644 --- a/Classes/Domain/Import/Typo3Converter/GeneralConverter.php +++ b/Classes/Domain/Import/Typo3Converter/GeneralConverter.php @@ -244,7 +244,7 @@ private function buildDataArrayFromEntity( 'payment_accepted' => method_exists($entity, 'getPaymentsAccepted') ? implode(',', $entity->getPaymentsAccepted()) : '', 'distance_to_public_transport' => method_exists($entity, 'getDistanceToPublicTransport') ? $entity->getDistanceToPublicTransport() : '', - 'slogan' => method_exists($entity, 'getSlogan') ? $entity->getSlogan() : '', + 'slogan' => method_exists($entity, 'getSlogan') ? implode(',', $entity->getSlogan()) : '', 'start_of_construction' => method_exists($entity, 'getStartOfConstruction') ? $entity->getStartOfConstruction() : '', 'museum_service' => method_exists($entity, 'getMuseumServices') ? implode(',', $entity->getMuseumServices()) : '', 'architectural_style' => method_exists($entity, 'getArchitecturalStyles') ? implode(',', $entity->getArchitecturalStyles()) : '', diff --git a/Classes/Domain/Model/Frontend/TouristAttraction.php b/Classes/Domain/Model/Frontend/TouristAttraction.php index 1f3f169c..35fff9ab 100644 --- a/Classes/Domain/Model/Frontend/TouristAttraction.php +++ b/Classes/Domain/Model/Frontend/TouristAttraction.php @@ -84,7 +84,15 @@ class TouristAttraction extends Place public function getSlogan(): string { - return $this->slogan; + return explode(',', $this->slogan)[0] ?? ''; + } + + /** + * @return string[] + */ + public function getSlogans(): array + { + return explode(',', $this->slogan); } public function getOffers(): ?Offers diff --git a/Documentation/Changelog/2.2.0.rst b/Documentation/Changelog/2.2.0.rst new file mode 100644 index 00000000..812a3987 --- /dev/null +++ b/Documentation/Changelog/2.2.0.rst @@ -0,0 +1,30 @@ +2.2.0 +===== + +Breaking +-------- + +Nothing + +Features +-------- + +* Add support for multiple slogans (array within slogan). + The existing API will return the first slogan. + A new method `getSlogans` is added which will return the array of slogans. + +Fixes +----- + +Nothing + +Tasks +----- + +Nothing + +Deprecation +----------- + +Nothing + diff --git a/Tests/Functional/AbstractImportTest.php b/Tests/Functional/AbstractImportTest.php index 31d8075e..f477f0c4 100644 --- a/Tests/Functional/AbstractImportTest.php +++ b/Tests/Functional/AbstractImportTest.php @@ -23,11 +23,14 @@ namespace WerkraumMedia\ThueCat\Tests\Functional; +use Codappix\Typo3PhpDatasets\TestingFramework; use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; abstract class AbstractImportTest extends FunctionalTestCase { + use TestingFramework; + /** * Whether to expect errors to be logged. * Will check for no errors if set to false. diff --git a/Tests/Functional/Assertions/Import/ImportsTouristAttractionWithSingleSlogan.php b/Tests/Functional/Assertions/Import/ImportsTouristAttractionWithSingleSlogan.php new file mode 100644 index 00000000..65410991 --- /dev/null +++ b/Tests/Functional/Assertions/Import/ImportsTouristAttractionWithSingleSlogan.php @@ -0,0 +1,28 @@ + [ + 0 => [ + 'uid' => '1', + 'pid' => '10', + 'sys_language_uid' => '0', + 'l18n_parent' => '0', + 'l10n_source' => '0', + 'remote_id' => 'https://thuecat.org/resources/attraction-with-single-slogan', + 'title' => 'Attraktion mit single slogan', + 'slogan' => 'InsiderTip', + ], + 1 => [ + 'uid' => '2', + 'pid' => '10', + 'sys_language_uid' => '1', + 'l18n_parent' => '1', + 'l10n_source' => '1', + 'remote_id' => 'https://thuecat.org/resources/attraction-with-single-slogan', + 'title' => 'Attraction with single slogan', + 'slogan' => 'InsiderTip', + ], + ], +]; diff --git a/Tests/Functional/Assertions/Import/ImportsTouristAttractionWithSloganArray.php b/Tests/Functional/Assertions/Import/ImportsTouristAttractionWithSloganArray.php new file mode 100644 index 00000000..7b0268cc --- /dev/null +++ b/Tests/Functional/Assertions/Import/ImportsTouristAttractionWithSloganArray.php @@ -0,0 +1,28 @@ + [ + 0 => [ + 'uid' => '1', + 'pid' => '10', + 'sys_language_uid' => '0', + 'l18n_parent' => '0', + 'l10n_source' => '0', + 'remote_id' => 'https://thuecat.org/resources/attraction-with-slogan-array', + 'title' => 'Attraktion mit slogan array', + 'slogan' => 'Highlight,InsiderTip,Unique', + ], + 1 => [ + 'uid' => '2', + 'pid' => '10', + 'sys_language_uid' => '1', + 'l18n_parent' => '1', + 'l10n_source' => '1', + 'remote_id' => 'https://thuecat.org/resources/attraction-with-slogan-array', + 'title' => 'Attraction with slogan array', + 'slogan' => 'Highlight,InsiderTip,Unique', + ], + ], +]; diff --git a/Tests/Functional/Fixtures/Import/Guzzle/thuecat.org/resources/attraction-with-single-slogan.json b/Tests/Functional/Fixtures/Import/Guzzle/thuecat.org/resources/attraction-with-single-slogan.json new file mode 100644 index 00000000..064e9be3 --- /dev/null +++ b/Tests/Functional/Fixtures/Import/Guzzle/thuecat.org/resources/attraction-with-single-slogan.json @@ -0,0 +1,55 @@ +{ + "@context": { + "cdb": "https://thuecat.org/ontology/cdb/1.0/", + "dachkg": "https://thuecat.org/ontology/dachkg/1.0/", + "dbo": "http://dbpedia.org/ontology/", + "dsv": "http://ontologies.sti-innsbruck.at/dsv/", + "foaf": "http://xmlns.com/foaf/0.1/", + "owl": "http://www.w3.org/2002/07/owl#", + "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#", + "rdfs": "http://www.w3.org/2000/01/rdf-schema#", + "schema": "http://schema.org/", + "sh": "http://www.w3.org/ns/shacl#", + "thuecat": "https://thuecat.org/ontology/thuecat/1.0/", + "ttgds": "https://thuecat.org/ontology/ttgds/1.0/", + "xsd": "http://www.w3.org/2001/XMLSchema#" + }, + "@graph": [ + { + "@id": "https://thuecat.org/resources/attraction-with-single-slogan", + "@type": [ + "schema:Place", + "schema:Thing", + "schema:TouristAttraction", + "ttgds:PointOfInterest" + ], + "schema:availableLanguage": [ + { + "@type": "thuecat:Language", + "@value": "thuecat:German" + }, + { + "@type": "thuecat:Language", + "@value": "thuecat:English" + } + ], + "schema:name": [ + { + "@language": "de", + "@value": "Attraktion mit single slogan" + }, + { + "@language": "en", + "@value": "Attraction with single slogan" + } + ], + "schema:slogan": { + "@type": "thuecat:ThuSlogan", + "@value": "thuecat:InsiderTip" + }, + "thuecat:contentResponsible": { + "@id": "https://thuecat.org/resources/018132452787-ngbe" + } + } + ] +} diff --git a/Tests/Functional/Fixtures/Import/Guzzle/thuecat.org/resources/attraction-with-slogan-array.json b/Tests/Functional/Fixtures/Import/Guzzle/thuecat.org/resources/attraction-with-slogan-array.json new file mode 100644 index 00000000..099eb10e --- /dev/null +++ b/Tests/Functional/Fixtures/Import/Guzzle/thuecat.org/resources/attraction-with-slogan-array.json @@ -0,0 +1,65 @@ +{ + "@context": { + "cdb": "https://thuecat.org/ontology/cdb/1.0/", + "dachkg": "https://thuecat.org/ontology/dachkg/1.0/", + "dbo": "http://dbpedia.org/ontology/", + "dsv": "http://ontologies.sti-innsbruck.at/dsv/", + "foaf": "http://xmlns.com/foaf/0.1/", + "owl": "http://www.w3.org/2002/07/owl#", + "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#", + "rdfs": "http://www.w3.org/2000/01/rdf-schema#", + "schema": "http://schema.org/", + "sh": "http://www.w3.org/ns/shacl#", + "thuecat": "https://thuecat.org/ontology/thuecat/1.0/", + "ttgds": "https://thuecat.org/ontology/ttgds/1.0/", + "xsd": "http://www.w3.org/2001/XMLSchema#" + }, + "@graph": [ + { + "@id": "https://thuecat.org/resources/attraction-with-slogan-array", + "@type": [ + "schema:Place", + "schema:Thing", + "schema:TouristAttraction", + "ttgds:PointOfInterest" + ], + "schema:availableLanguage": [ + { + "@type": "thuecat:Language", + "@value": "thuecat:German" + }, + { + "@type": "thuecat:Language", + "@value": "thuecat:English" + } + ], + "schema:name": [ + { + "@language": "de", + "@value": "Attraktion mit slogan array" + }, + { + "@language": "en", + "@value": "Attraction with slogan array" + } + ], + "schema:slogan": [ + { + "@type": "thuecat:ThuSlogan", + "@value": "thuecat:Highlight" + }, + { + "@type": "thuecat:ThuSlogan", + "@value": "thuecat:InsiderTip" + }, + { + "@type": "thuecat:ThuSlogan", + "@value": "thuecat:Unique" + } + ], + "thuecat:contentResponsible": { + "@id": "https://thuecat.org/resources/018132452787-ngbe" + } + } + ] +} diff --git a/Tests/Functional/Fixtures/Import/ImportsTouristAttractionWithSingleSlogan.php b/Tests/Functional/Fixtures/Import/ImportsTouristAttractionWithSingleSlogan.php new file mode 100644 index 00000000..9d331919 --- /dev/null +++ b/Tests/Functional/Fixtures/Import/ImportsTouristAttractionWithSingleSlogan.php @@ -0,0 +1,65 @@ + [ + 0 => [ + 'uid' => '1', + 'pid' => '0', + 'tstamp' => '1613400587', + 'crdate' => '1613400558', + 'doktype' => PageRepository::DOKTYPE_DEFAULT, + 'title' => 'Rootpage', + 'is_siteroot' => '1', + ], + 1 => [ + 'uid' => '10', + 'pid' => '1', + 'tstamp' => '1613400587', + 'crdate' => '1613400558', + 'doktype' => PageRepository::DOKTYPE_SYSFOLDER, + 'title' => 'Storage folder', + ], + ], + 'tx_thuecat_import_configuration' => [ + 0 => [ + 'uid' => '1', + 'pid' => '0', + 'tstamp' => '1613400587', + 'crdate' => '1613400558', + 'disable' => '0', + 'title' => 'Tourist Attraction', + 'type' => 'static', + 'configuration' => ' + + + + + + 10 + + + + + + + + https://thuecat.org/resources/attraction-with-single-slogan + + + + 0 + + + + + + + + ', + ], + ], +]; diff --git a/Tests/Functional/Fixtures/Import/ImportsTouristAttractionWithSloganArray.php b/Tests/Functional/Fixtures/Import/ImportsTouristAttractionWithSloganArray.php new file mode 100644 index 00000000..45878845 --- /dev/null +++ b/Tests/Functional/Fixtures/Import/ImportsTouristAttractionWithSloganArray.php @@ -0,0 +1,65 @@ + [ + 0 => [ + 'uid' => '1', + 'pid' => '0', + 'tstamp' => '1613400587', + 'crdate' => '1613400558', + 'doktype' => PageRepository::DOKTYPE_DEFAULT, + 'title' => 'Rootpage', + 'is_siteroot' => '1', + ], + 1 => [ + 'uid' => '10', + 'pid' => '1', + 'tstamp' => '1613400587', + 'crdate' => '1613400558', + 'doktype' => PageRepository::DOKTYPE_SYSFOLDER, + 'title' => 'Storage folder', + ], + ], + 'tx_thuecat_import_configuration' => [ + 0 => [ + 'uid' => '1', + 'pid' => '0', + 'tstamp' => '1613400587', + 'crdate' => '1613400558', + 'disable' => '0', + 'title' => 'Tourist Attraction', + 'type' => 'static', + 'configuration' => ' + + + + + + 10 + + + + + + + + https://thuecat.org/resources/attraction-with-slogan-array + + + + 0 + + + + + + + + ', + ], + ], +]; diff --git a/Tests/Functional/ImportTest.php b/Tests/Functional/ImportTest.php index 2a570f26..d3964d9b 100644 --- a/Tests/Functional/ImportTest.php +++ b/Tests/Functional/ImportTest.php @@ -24,6 +24,7 @@ */ use WerkraumMedia\ThueCat\Domain\Import\Importer; +use WerkraumMedia\ThueCat\Domain\Model\Backend\ImportConfiguration; use WerkraumMedia\ThueCat\Domain\Repository\Backend\ImportConfigurationRepository; /** @@ -67,8 +68,7 @@ public function importsFreshOrganization(): void $this->importDataSet(__DIR__ . '/Fixtures/Import/ImportsFreshOrganization.xml'); GuzzleClientFaker::appendResponseFromFile(__DIR__ . '/Fixtures/Import/Guzzle/thuecat.org/resources/018132452787-ngbe.json'); - $configuration = $this->get(ImportConfigurationRepository::class)->findByUid(1); - $this->get(Importer::class)->importConfiguration($configuration); + $this->importConfiguration(); $this->assertCSVDataSet('EXT:thuecat/Tests/Functional/Fixtures/Import/ImportsFreshOrganization.csv'); } @@ -81,8 +81,7 @@ public function updatesExistingOrganization(): void $this->importDataSet(__DIR__ . '/Fixtures/Import/UpdatesExistingOrganization.xml'); GuzzleClientFaker::appendResponseFromFile(__DIR__ . '/Fixtures/Import/Guzzle/thuecat.org/resources/018132452787-ngbe.json'); - $configuration = $this->get(ImportConfigurationRepository::class)->findByUid(1); - $this->get(Importer::class)->importConfiguration($configuration); + $this->importConfiguration(); $organisations = $this->getAllRecords('tx_thuecat_organisation'); self::assertCount(1, $organisations); @@ -116,8 +115,7 @@ public function importsTown(): void GuzzleClientFaker::appendResponseFromFile(__DIR__ . '/Fixtures/Import/Guzzle/thuecat.org/resources/043064193523-jcyt.json'); GuzzleClientFaker::appendResponseFromFile(__DIR__ . '/Fixtures/Import/Guzzle/thuecat.org/resources/018132452787-ngbe.json'); - $configuration = $this->get(ImportConfigurationRepository::class)->findByUid(1); - $this->get(Importer::class)->importConfiguration($configuration); + $this->importConfiguration(); $this->assertCSVDataSet('EXT:thuecat/Tests/Functional/Fixtures/Import/ImportsTown.csv'); } @@ -131,8 +129,7 @@ public function importsTownWithRelation(): void GuzzleClientFaker::appendResponseFromFile(__DIR__ . '/Fixtures/Import/Guzzle/thuecat.org/resources/043064193523-jcyt.json'); GuzzleClientFaker::appendResponseFromFile(__DIR__ . '/Fixtures/Import/Guzzle/thuecat.org/resources/018132452787-ngbe.json'); - $configuration = $this->get(ImportConfigurationRepository::class)->findByUid(1); - $this->get(Importer::class)->importConfiguration($configuration); + $this->importConfiguration(); $this->assertCSVDataSet('EXT:thuecat/Tests/Functional/Fixtures/Import/ImportsTownWithRelation.csv'); } @@ -166,8 +163,7 @@ public function importsTouristAttractionsWithRelations(): void GuzzleClientFaker::appendResponseFromFile(__DIR__ . '/Fixtures/Import/Guzzle/thuecat.org/resources/440055527204-ocar.json'); GuzzleClientFaker::appendResponseFromFile(__DIR__ . '/Fixtures/Import/Guzzle/thuecat.org/resources/dms_5197164.json'); - $configuration = $this->get(ImportConfigurationRepository::class)->findByUid(1); - $this->get(Importer::class)->importConfiguration($configuration); + $this->importConfiguration(); $this->assertCSVDataSet('EXT:thuecat/Tests/Functional/Fixtures/Import/ImportsTouristAttractionsWithRelations.csv'); } @@ -181,8 +177,7 @@ public function importsTouristAttractionsWithFilteredOpeningHours(): void GuzzleClientFaker::appendResponseFromFile(__DIR__ . '/Fixtures/Import/Guzzle/thuecat.org/resources/opening-hours-to-filter.json'); GuzzleClientFaker::appendResponseFromFile(__DIR__ . '/Fixtures/Import/Guzzle/thuecat.org/resources/018132452787-ngbe.json'); - $configuration = $this->get(ImportConfigurationRepository::class)->findByUid(1); - $this->get(Importer::class)->importConfiguration($configuration); + $this->importConfiguration(); $this->assertCSVDataSet('EXT:thuecat/Tests/Functional/Fixtures/Import/ImportsTouristAttractionsWithFilteredOpeningHours.csv'); } @@ -196,8 +191,7 @@ public function importsTouristAttractionsWithSpecialOpeningHours(): void GuzzleClientFaker::appendResponseFromFile(__DIR__ . '/Fixtures/Import/Guzzle/thuecat.org/resources/special-opening-hours.json'); GuzzleClientFaker::appendResponseFromFile(__DIR__ . '/Fixtures/Import/Guzzle/thuecat.org/resources/018132452787-ngbe.json'); - $configuration = $this->get(ImportConfigurationRepository::class)->findByUid(1); - $this->get(Importer::class)->importConfiguration($configuration); + $this->importConfiguration(); $this->assertCSVDataSet('EXT:thuecat/Tests/Functional/Fixtures/Import/ImportsTouristAttractionsWithSpecialOpeningHours.csv'); } @@ -214,8 +208,7 @@ public function importsTouristInformationWithRelation(): void GuzzleClientFaker::appendResponseFromFile(__DIR__ . '/Fixtures/Import/Guzzle/thuecat.org/resources/573211638937-gmqb.json'); GuzzleClientFaker::appendResponseFromFile(__DIR__ . '/Fixtures/Import/Guzzle/thuecat.org/resources/356133173991-cryw.json'); - $configuration = $this->get(ImportConfigurationRepository::class)->findByUid(1); - $this->get(Importer::class)->importConfiguration($configuration); + $this->importConfiguration(); $this->assertCSVDataSet('EXT:thuecat/Tests/Functional/Fixtures/Import/ImportsTouristInformationWithRelation.csv'); } @@ -250,8 +243,7 @@ public function importsBasedOnSyncScope(): void GuzzleClientFaker::appendResponseFromFile(__DIR__ . '/Fixtures/Import/Guzzle/thuecat.org/resources/440055527204-ocar.json'); GuzzleClientFaker::appendResponseFromFile(__DIR__ . '/Fixtures/Import/Guzzle/thuecat.org/resources/dms_5197164.json'); - $configuration = $this->get(ImportConfigurationRepository::class)->findByUid(1); - $this->get(Importer::class)->importConfiguration($configuration); + $this->importConfiguration(); $this->assertCSVDataSet('EXT:thuecat/Tests/Functional/Fixtures/Import/ImportsSyncScope.csv'); } @@ -294,8 +286,7 @@ public function importsBasedOnContainsPlace(): void GuzzleClientFaker::appendNotFoundResponse(); } - $configuration = $this->get(ImportConfigurationRepository::class)->findByUid(1); - $this->get(Importer::class)->importConfiguration($configuration); + $this->importConfiguration(); $this->assertCSVDataSet('EXT:thuecat/Tests/Functional/Fixtures/Import/ImportsContainsPlace.csv'); } @@ -317,8 +308,7 @@ public function importsFollowingRecordsInCaseOfAnMappingException(): void GuzzleClientFaker::appendNotFoundResponse(); } - $configuration = $this->get(ImportConfigurationRepository::class)->findByUid(1); - $this->get(Importer::class)->importConfiguration($configuration); + $this->importConfiguration(); if (version_compare(PHP_VERSION, '8.1.0', '<')) { $this->assertCSVDataSet('EXT:thuecat/Tests/Functional/Fixtures/Import/ImportsFollowingRecordsInCaseOfAnMappingExceptionOldPhp.csv'); @@ -358,8 +348,7 @@ public function importWithMultipleReferencesToSameObject(): void GuzzleClientFaker::appendResponseFromFile(__DIR__ . '/Fixtures/Import/Guzzle/thuecat.org/resources/440055527204-ocar.json'); GuzzleClientFaker::appendResponseFromFile(__DIR__ . '/Fixtures/Import/Guzzle/thuecat.org/resources/dms_5197164.json'); - $configuration = $this->get(ImportConfigurationRepository::class)->findByUid(1); - $this->get(Importer::class)->importConfiguration($configuration); + $this->importConfiguration(); $this->assertCSVDataSet('EXT:thuecat/Tests/Functional/Fixtures/Import/ImportWithMultipleReferencesToSameObject.csv'); } @@ -379,8 +368,7 @@ public function importsTouristAttractionWithMedia(): void GuzzleClientFaker::appendResponseFromFile(__DIR__ . '/Fixtures/Import/Guzzle/thuecat.org/resources/image-with-license-author.json'); GuzzleClientFaker::appendResponseFromFile(__DIR__ . '/Fixtures/Import/Guzzle/thuecat.org/resources/image-with-author-and-license-author.json'); - $configuration = $this->get(ImportConfigurationRepository::class)->findByUid(1); - $this->get(Importer::class)->importConfiguration($configuration); + $this->importConfiguration(); $this->assertCSVDataSet('EXT:thuecat/Tests/Functional/Fixtures/Import/ImportsTouristAttractionWithMedia.csv'); } @@ -396,12 +384,48 @@ public function importsTouristAttractionWithAccessibilitySpecification(): void GuzzleClientFaker::appendResponseFromFile(__DIR__ . '/Fixtures/Import/Guzzle/thuecat.org/resources/018132452787-ngbe.json'); GuzzleClientFaker::appendResponseFromFile(__DIR__ . '/Fixtures/Import/Guzzle/thuecat.org/resources/e_331baf4eeda4453db920dde62f7e6edc-rfa-accessibility-specification.json'); - $configuration = $this->get(ImportConfigurationRepository::class)->findByUid(1); - $this->get(Importer::class)->importConfiguration($configuration); + $this->importConfiguration(); $this->assertCSVDataSet('EXT:thuecat/Tests/Functional/Fixtures/Import/ImportsTouristAttractionWithAccessibilitySpecification.csv'); $records = $this->getAllRecords('tx_thuecat_tourist_attraction'); self::assertStringEqualsFile(__DIR__ . '/Fixtures/Import/ImportsTouristAttractionWithAccessibilitySpecificationGerman.txt', $records[0]['accessibility_specification'] . PHP_EOL); self::assertStringEqualsFile(__DIR__ . '/Fixtures/Import/ImportsTouristAttractionWithAccessibilitySpecificationEnglish.txt', $records[1]['accessibility_specification'] . PHP_EOL); } + + /** + * @test + */ + public function importsTouristAttractionWithSloganArray(): void + { + $this->importPHPDataSet(__DIR__ . '/Fixtures/Import/ImportsTouristAttractionWithSloganArray.php'); + + GuzzleClientFaker::appendResponseFromFile(__DIR__ . '/Fixtures/Import/Guzzle/thuecat.org/resources/attraction-with-slogan-array.json'); + GuzzleClientFaker::appendResponseFromFile(__DIR__ . '/Fixtures/Import/Guzzle/thuecat.org/resources/018132452787-ngbe.json'); + + $this->importConfiguration(); + + $this->assertPHPDataSet(__DIR__ . '/Assertions/Import/ImportsTouristAttractionWithSloganArray.php'); + } + + /** + * @test + */ + public function importsTouristAttractionWithSingleSlogan(): void + { + $this->importPHPDataSet(__DIR__ . '/Fixtures/Import/ImportsTouristAttractionWithSingleSlogan.php'); + + GuzzleClientFaker::appendResponseFromFile(__DIR__ . '/Fixtures/Import/Guzzle/thuecat.org/resources/attraction-with-single-slogan.json'); + GuzzleClientFaker::appendResponseFromFile(__DIR__ . '/Fixtures/Import/Guzzle/thuecat.org/resources/018132452787-ngbe.json'); + + $this->importConfiguration(); + + $this->assertPHPDataSet(__DIR__ . '/Assertions/Import/ImportsTouristAttractionWithSingleSlogan.php'); + } + + private function importConfiguration(): void + { + $configuration = $this->get(ImportConfigurationRepository::class)->findByUid(1); + self::assertInstanceOf(ImportConfiguration::class, $configuration); + $this->get(Importer::class)->importConfiguration($configuration); + } } diff --git a/Tests/Unit/Domain/Model/Frontend/TouristAttractionTest.php b/Tests/Unit/Domain/Model/Frontend/TouristAttractionTest.php index 5159d560..bf1b0356 100644 --- a/Tests/Unit/Domain/Model/Frontend/TouristAttractionTest.php +++ b/Tests/Unit/Domain/Model/Frontend/TouristAttractionTest.php @@ -291,4 +291,28 @@ public function filterOutPreviousDates( } } } + + /** + * @test + */ + public function returnsSingleSlogan(): void + { + $subject = new TouristAttraction(); + $subject->_setProperty('slogan', 'Some text'); + + self::assertSame('Some text', $subject->getSlogan()); + self::assertSame(['Some text'], $subject->getSlogans()); + } + + /** + * @test + */ + public function returnsMultipleSlogans(): void + { + $subject = new TouristAttraction(); + $subject->_setProperty('slogan', 'Some text,Highlight'); + + self::assertSame('Some text', $subject->getSlogan()); + self::assertSame(['Some text', 'Highlight'], $subject->getSlogans()); + } } diff --git a/composer.json b/composer.json index ba129f46..da441abe 100644 --- a/composer.json +++ b/composer.json @@ -54,6 +54,7 @@ "typo3/cms-frontend": "^10.4 || ^11.5" }, "require-dev": { + "codappix/typo3-php-datasets": "^1.4", "codeception/codeception": "^4.2", "codeception/module-webdriver": "^2.0", "jangregor/phpstan-prophecy": "^1.0", diff --git a/ext_emconf.php b/ext_emconf.php index ec918cb3..463993d0 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -11,7 +11,7 @@ 'author' => 'Daniel Siepmann', 'author_email' => 'coding@daniel-siepmann.de', 'author_company' => '', - 'version' => '2.1.0', + 'version' => '2.2.0', 'constraints' => [ 'depends' => [ 'core' => '',