diff --git a/Classes/Service/Cleanup/Files.php b/Classes/Service/Cleanup/Files.php index 7e7029c..d1041d4 100644 --- a/Classes/Service/Cleanup/Files.php +++ b/Classes/Service/Cleanup/Files.php @@ -68,6 +68,27 @@ class Files $referencesQuery->createNamedParameter('tx_events_domain_model_%') ) ); + // Remove file relations removed via import + $referencesQuery->orWhere( + $referencesQuery->expr()->andX( + $referencesQuery->expr()->eq( + 'tablenames', + $referencesQuery->createNamedParameter('') + ), + $referencesQuery->expr()->eq( + 'fieldname', + $referencesQuery->createNamedParameter('') + ), + $referencesQuery->expr()->eq( + 'sorting_foreign', + $referencesQuery->createNamedParameter('0') + ), + $referencesQuery->expr()->eq( + 'uid_foreign', + $referencesQuery->createNamedParameter('0') + ) + ) + ); $referencesQuery->orderBy('tablenames'); $referencesQuery->addOrderBy('uid_foreign'); @@ -81,6 +102,11 @@ class Files continue; } + if ($reference['tablenames'] === '') { + $referenceUidsToMarkAsDeleted[] = $reference['uid']; + continue; + } + $uidsPerTable[(string)$reference['tablenames']][$reference['uid']] = $reference['uid_foreign']; } @@ -125,6 +151,10 @@ class Files 'reference.tablenames', $queryBuilder->createNamedParameter('tx_events_domain_model_%') )) + ->orWhere($queryBuilder->expr()->eq( + 'reference.tablenames', + $queryBuilder->createNamedParameter('') + )) ->groupBy('file.uid') ->having( $queryBuilder->expr()->eq( @@ -179,10 +209,18 @@ class Files $queryBuilder->getRestrictions()->removeAll(); $queryBuilder ->delete('sys_file_reference') - ->where($queryBuilder->expr()->like( - 'tablenames', - $queryBuilder->createNamedParameter('tx_events_domain_model_%') - )) + ->where( + $queryBuilder->expr()->orX( + $queryBuilder->expr()->like( + 'tablenames', + $queryBuilder->createNamedParameter('tx_events_domain_model_%') + ), + $queryBuilder->expr()->eq( + 'tablenames', + $queryBuilder->createNamedParameter('') + ) + ) + ) ->andWhere($queryBuilder->expr()->eq( 'deleted', 1 diff --git a/Classes/Service/DestinationDataImportService.php b/Classes/Service/DestinationDataImportService.php index e8378dd..154c686 100644 --- a/Classes/Service/DestinationDataImportService.php +++ b/Classes/Service/DestinationDataImportService.php @@ -3,11 +3,8 @@ namespace Wrm\Events\Service; use Exception; -use TYPO3\CMS\Core\DataHandling\DataHandler; use TYPO3\CMS\Core\Log\Logger; use TYPO3\CMS\Core\Log\LogManager; -use TYPO3\CMS\Core\Resource\File; -use TYPO3\CMS\Core\Resource\Index\MetaDataRepository; use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Extbase\Configuration\ConfigurationManager; use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface; @@ -24,6 +21,7 @@ use Wrm\Events\Service\DestinationDataImportService\CategoriesAssignment; use Wrm\Events\Service\DestinationDataImportService\CategoriesAssignment\Import as CategoryImport; use Wrm\Events\Service\DestinationDataImportService\DataFetcher; use Wrm\Events\Service\DestinationDataImportService\DatesFactory; +use Wrm\Events\Service\DestinationDataImportService\FilesAssignment; use Wrm\Events\Service\DestinationDataImportService\LocationAssignment; use Wrm\Events\Service\DestinationDataImportService\Slugger; @@ -59,11 +57,6 @@ class DestinationDataImportService */ private $dateRepository; - /** - * @var MetaDataRepository - */ - private $metaDataRepository; - /** * @var ConfigurationManager */ @@ -89,6 +82,11 @@ class DestinationDataImportService */ private $datesFactory; + /** + * @var FilesAssignment + */ + private $filesAssignment; + /** * @var CategoriesAssignment */ @@ -109,11 +107,11 @@ class DestinationDataImportService * @param EventRepository $eventRepository * @param OrganizerRepository $organizerRepository * @param DateRepository $dateRepository - * @param MetaDataRepository $metaDataRepository * @param ConfigurationManager $configurationManager * @param PersistenceManager $persistenceManager * @param ObjectManager $objectManager * @param DataFetcher $dataFetcher + * @param FilesAssignment $filesAssignment * @param CategoriesAssignment $categoriesAssignment * @param LocationAssignment $locationAssignment * @param Slugger $slugger @@ -122,12 +120,12 @@ class DestinationDataImportService EventRepository $eventRepository, OrganizerRepository $organizerRepository, DateRepository $dateRepository, - MetaDataRepository $metaDataRepository, ConfigurationManager $configurationManager, PersistenceManager $persistenceManager, ObjectManager $objectManager, DataFetcher $dataFetcher, DatesFactory $datesFactory, + FilesAssignment $filesAssignment, CategoriesAssignment $categoriesAssignment, LocationAssignment $locationAssignment, Slugger $slugger @@ -135,12 +133,12 @@ class DestinationDataImportService $this->eventRepository = $eventRepository; $this->organizerRepository = $organizerRepository; $this->dateRepository = $dateRepository; - $this->metaDataRepository = $metaDataRepository; $this->configurationManager = $configurationManager; $this->persistenceManager = $persistenceManager; $this->objectManager = $objectManager; $this->dataFetcher = $dataFetcher; $this->datesFactory = $datesFactory; + $this->filesAssignment = $filesAssignment; $this->categoriesAssignment = $categoriesAssignment; $this->locationAssignment = $locationAssignment; $this->slugger = $slugger; @@ -454,147 +452,12 @@ class DestinationDataImportService private function setAssets(array $assets): void { $this->logger->info('Set assets'); - - $allowedMimeTypes = [ - 'image/jpeg', - 'image/png', - ]; - $importFolder = $this->import->getFilesFolder(); - - $error = false; - - foreach ($assets as $media_object) { - if ( - $media_object['rel'] == 'default' - && in_array($media_object['type'], $allowedMimeTypes) - ) { - $fileUrl = urldecode($media_object['url']); - $orgFileNameSanitized = $importFolder->getStorage()->sanitizeFileName( - basename( - urldecode($media_object['url']) - ) - ); - - $this->logger->info('File attached:' . $fileUrl); - $this->logger->info('File attached sanitized:' . $orgFileNameSanitized); - - if ($importFolder->hasFile($orgFileNameSanitized)) { - $this->logger->info('File already exists'); - } else { - $this->logger->info("File don't exist " . $orgFileNameSanitized); - // Load the file - if ($filename = $this->loadFile($fileUrl)) { - // Move file to defined folder - $this->logger->info('Adding file ' . $filename); - - $importFolder->addFile($filename, basename($fileUrl)); - } else { - $error = true; - } - } - - if ($error !== true) { - if ($this->tmpCurrentEvent->getImages()->count() > 0) { - $this->logger->info('Relation found'); - // TODO: How to delete file references? - } else { - $this->logger->info('No relation found'); - if ($importFolder->hasFile($orgFileNameSanitized) === false) { - $this->logger->warning('Could not find file.', [$orgFileNameSanitized]); - continue; - } - - $file = $importFolder->getStorage()->getFileInFolder($orgFileNameSanitized, $importFolder); - if (!$file instanceof File) { - $this->logger->warning('Could not find file.', [$orgFileNameSanitized]); - continue; - } - - $this->metaDataRepository->update( - $file->getUid(), - [ - 'title' => $this->getShortenedString($media_object['value'], 100), - 'description' => $media_object['description'] ?? '', - 'alternative' => 'DD Import', - ] - ); - $this->createFileRelations( - $file->getUid(), - 'tx_events_domain_model_event', - $this->tmpCurrentEvent->getUid(), - 'images', - $this->import->getStoragePid() - ); - } - } - } - $error = false; - } - } - - private function loadFile(string $fileUrl): string - { - $this->logger->info('Getting file ' . $fileUrl); - - $file = new \SplFileInfo($fileUrl); - $temporaryFilename = GeneralUtility::tempnam($file->getBasename()); - - try { - $response = $this->dataFetcher->fetchImage($fileUrl); - } catch (Exception $e) { - $this->logger->error('Cannot load file ' . $fileUrl); - return ''; - } - - $fileContent = $response->getBody()->__toString(); - if ($response->getStatusCode() !== 200) { - $this->logger->error('Cannot load file ' . $fileUrl); - } - - if (GeneralUtility::writeFile($temporaryFilename, $fileContent, true) === false) { - $this->logger->error('Could not write temporary file.'); - return ''; - } - - return $temporaryFilename; - } - - private function createFileRelations( - int $uid_local, - string $tablenames, - int $uid_foreign, - string $fieldname, - int $storagePid - ): bool { - $newId = 'NEW1234'; - - $data = []; - $data['sys_file_reference'][$newId] = [ - 'table_local' => 'sys_file', - 'uid_local' => $uid_local, - 'tablenames' => $tablenames, - 'uid_foreign' => $uid_foreign, - 'fieldname' => $fieldname, - 'pid' => $storagePid, - ]; - - $data[$tablenames][$uid_foreign] = [ - 'pid' => $storagePid, - $fieldname => $newId, - ]; - - $dataHandler = $this->objectManager->get(DataHandler::class); - $dataHandler->start($data, []); - $dataHandler->process_datamap(); - - if (count($dataHandler->errorLog) === 0) { - return true; - } - - foreach ($dataHandler->errorLog as $error) { - $this->logger->info($error); - } - return false; + $images = $this->filesAssignment->getImages( + $this->import, + $this->tmpCurrentEvent, + $assets + ); + $this->tmpCurrentEvent->setImages($images); } /** @@ -627,13 +490,4 @@ class DestinationDataImportService return (bool)$value; } - - private function getShortenedString(string $string, int $lenght): string - { - if ($string === mb_substr($string, 0, $lenght)) { - return $string; - } - - return mb_substr($string, 0, $lenght - 3) . ' …'; - } } diff --git a/Classes/Service/DestinationDataImportService/FilesAssignment.php b/Classes/Service/DestinationDataImportService/FilesAssignment.php new file mode 100644 index 0000000..3c5e174 --- /dev/null +++ b/Classes/Service/DestinationDataImportService/FilesAssignment.php @@ -0,0 +1,212 @@ + + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA + * 02110-1301, USA. + */ + +namespace Wrm\Events\Service\DestinationDataImportService; + +use Exception; +use Psr\Log\LoggerInterface; +use TYPO3\CMS\Core\Log\LogManager; +use TYPO3\CMS\Core\Resource\DuplicationBehavior; +use TYPO3\CMS\Core\Resource\File; +use TYPO3\CMS\Core\Resource\Index\MetaDataRepository; +use TYPO3\CMS\Core\Resource\ResourceFactory; +use TYPO3\CMS\Core\Utility\GeneralUtility; +use TYPO3\CMS\Extbase\Domain\Model\FileReference; +use TYPO3\CMS\Extbase\Persistence\ObjectStorage; +use Wrm\Events\Domain\Model\Event; +use Wrm\Events\Domain\Model\Import; + +class FilesAssignment +{ + /** + * @var LoggerInterface + */ + private $logger; + + /** + * @var DataFetcher + */ + private $dataFetcher; + + /** + * @var ResourceFactory + */ + private $resourceFactory; + + /** + * @var MetaDataRepository + */ + private $metaDataRepository; + + public function __construct( + LogManager $logManager, + DataFetcher $dataFetcher, + ResourceFactory $resourceFactory, + MetaDataRepository $metaDataRepository + ) { + $this->logger = $logManager->getLogger(self::class); + $this->dataFetcher = $dataFetcher; + $this->resourceFactory = $resourceFactory; + $this->metaDataRepository = $metaDataRepository; + } + + /** + * @return ObjectStorage + */ + public function getImages( + Import $import, + Event $event, + array $assets + ): ObjectStorage { + $images = new ObjectStorage(); + $importFolder = $import->getFilesFolder(); + + foreach ($assets as $mediaObject) { + if ($this->isImage($mediaObject) === false) { + continue; + } + + $fileUrl = urldecode($mediaObject['url']); + $orgFileNameSanitized = $importFolder->getStorage()->sanitizeFileName(basename($fileUrl)); + + $this->logger->info('File attached.', [$fileUrl, $orgFileNameSanitized]); + + if ($importFolder->hasFile($orgFileNameSanitized)) { + $this->logger->info('File already exists.', [$orgFileNameSanitized]); + } else { + $this->logger->info('File does not exist.', [$orgFileNameSanitized]); + } + + if ($filename = $this->loadFile($fileUrl)) { + $this->logger->info('Adding file to FAL.', [$filename]); + $importFolder->addFile($filename, basename($fileUrl), DuplicationBehavior::REPLACE); + } else { + continue; + } + + if ($importFolder->hasFile($orgFileNameSanitized) === false) { + $this->logger->warning('Could not find file.', [$orgFileNameSanitized]); + continue; + } + + $file = $importFolder->getStorage()->getFileInFolder($orgFileNameSanitized, $importFolder); + if (!$file instanceof File) { + $this->logger->warning('Could not find file.', [$orgFileNameSanitized]); + continue; + } + + $this->updateMetadata($file, $mediaObject); + $images->attach($this->getFileReference($event, $file, $mediaObject)); + } + + return $images; + } + + private function loadFile(string $fileUrl): string + { + $this->logger->info('Getting file.', [$fileUrl]); + + try { + $response = $this->dataFetcher->fetchImage($fileUrl); + } catch (Exception $e) { + $this->logger->error('Cannot load file.', [$fileUrl]); + return ''; + } + + if ($response->getStatusCode() !== 200) { + $this->logger->error('Cannot load file.', [$fileUrl]); + return ''; + } + + $file = new \SplFileInfo($fileUrl); + $temporaryFilename = GeneralUtility::tempnam($file->getBasename()); + $writeResult = GeneralUtility::writeFile($temporaryFilename, $response->getBody()->__toString(), true); + if ($writeResult === false) { + $this->logger->error('Could not write temporary file.', [$temporaryFilename]); + return ''; + } + + return $temporaryFilename; + } + + private function updateMetadata( + File $file, + array $mediaObject + ): void { + $this->metaDataRepository->update($file->getUid(), [ + 'title' => $this->getShortenedString($mediaObject['value'], 100), + 'description' => $mediaObject['description'] ?? '', + 'alternative' => 'DD Import', + ]); + } + + private function getFileReference( + Event $event, + File $file, + array $mediaObject + ): FileReference { + foreach ($event->getImages() as $existingRelation) { + if ($existingRelation->getOriginalResource()->getOriginalFile() === $file) { + return $existingRelation; + } + } + + return $this->createFileReference($event, $file, $mediaObject); + } + + private function createFileReference( + Event $event, + File $file, + array $mediaObject + ): FileReference { + $coreReference = $this->resourceFactory->createFileReferenceObject([ + 'uid' => uniqid('NEW_'), + 'uid_local' => $file->getUid(), + 'uid_foreign' => $event->getUid(), + ]); + $extbaseReference = new FileReference(); + $extbaseReference->setOriginalResource($coreReference); + return $extbaseReference; + } + + private function getShortenedString(string $string, int $lenght): string + { + if ($string === mb_substr($string, 0, $lenght)) { + return $string; + } + + return mb_substr($string, 0, $lenght - 3) . ' …'; + } + + private function isImage(array $mediaObject): bool + { + $allowedMimeTypes = [ + 'image/jpeg', + 'image/png', + ]; + + return ((string)$mediaObject['rel']) === 'default' + && in_array($mediaObject['type'], $allowedMimeTypes) + ; + } +} diff --git a/Documentation/Changelog/3.4.0.rst b/Documentation/Changelog/3.4.0.rst index e9c8639..7e8e46d 100644 --- a/Documentation/Changelog/3.4.0.rst +++ b/Documentation/Changelog/3.4.0.rst @@ -31,6 +31,10 @@ Features ``1`` turns off the option ``useMidnight``, ``start`` and ``end``. Only dates with a start date in the future will be shown. +* Handle changes to images for events. + The import of destination data one only added new images but kept existing images untouched. + This was now improved. The import now will update, remove and re-sort images as well. + Fixes ----- diff --git a/Documentation/Commands.rst b/Documentation/Commands.rst index ab9e7f8..1580866 100644 --- a/Documentation/Commands.rst +++ b/Documentation/Commands.rst @@ -1,3 +1,4 @@ +.. index:: single: Command .. _commands: Commands @@ -16,15 +17,30 @@ Access built in help: # Get detailed help of command ./vendor/bin/typo3 help events:destinationdataimport +.. index:: single: Command; events:destinationdataimportviaconfiguration +.. _eventsDestinationdataimportviaconfiguration: + ``events:destinationdataimportviaconfiguration`` ------------------------------------------------ +.. index:: single: Command; events:destinationdataimportviaallconfigurations +.. _eventsDestinationdataimportviaallconfigurations: + ``events:destinationdataimportviaallconfigurations`` ---------------------------------------------------- +.. index:: single: Command; events:removeAll +.. _eventsRemoveAll: + ``events:removeAll`` --------------------------------- +-------------------- + +.. index:: single: Command; events:removePast +.. _eventsRemovePast: ``events:removePast`` --------------------------------- +--------------------- +Will remove all dates within the past. +Events with no more dates will be removed as well. +It also will remove all related files that no longer are in use. diff --git a/Documentation/Features/Caching.rst b/Documentation/Features/Caching.rst index 480fcce..6819e77 100644 --- a/Documentation/Features/Caching.rst +++ b/Documentation/Features/Caching.rst @@ -1,6 +1,5 @@ -.. _caching: - .. index:: single: caching +.. _caching: Caching ======= diff --git a/Documentation/Features/ImportDestinationOne.rst b/Documentation/Features/ImportDestinationOne.rst new file mode 100644 index 0000000..cc519c5 --- /dev/null +++ b/Documentation/Features/ImportDestinationOne.rst @@ -0,0 +1,27 @@ +.. index:: single: import; DestinationOne + single: DestinationOne +.. _importDestinationOne: + +Import Destination One +====================== + +The extension provides out of the box to import events from Destination Data One. + +The import can fetch events, dates, categories and images. +Multiple imports can be defined, e.g. one per experience. +Imports are configured as database entries "Import Configuration". + +The import can be triggered via scheduler tasks as well as commands. +A single import as well as all imports at once can be triggered. + +The import will: + +* Add and update events + +* Flush all dates for updated events and re-create all dates. + +* Add and update all images for updated and added events. + +The import will not: + +* Remove outdated data. Use cleanup command :ref:`eventsRemovePast` instead. diff --git a/Tests/Functional/Cleanup/Fixtures/RemovePastTestDatabase.php b/Tests/Functional/Cleanup/Fixtures/RemovePastTestDatabase.php index a44c879..6ac09de 100644 --- a/Tests/Functional/Cleanup/Fixtures/RemovePastTestDatabase.php +++ b/Tests/Functional/Cleanup/Fixtures/RemovePastTestDatabase.php @@ -164,6 +164,26 @@ return [ 'identifier_hash' => '475768e491580fb8b74ed36c2b1aaf619ca5e11d', 'folder_hash' => 'b4ab666a114d9905a50606d1837b74d952dfd90f', ], + [ + 'uid' => '5', + 'pid' => '0', + 'tstamp' => '1371467047', + 'type' => '2', + 'storage' => '1', + 'identifier' => '/user_uploads/example-for-no-longer-used.gif', + 'extension' => 'gif', + 'mime_type' => 'image/gif', + 'name' => 'example-for-no-longer-used.gif', + 'sha1' => '359ae0fb420fe8afe1a8b8bc5e46d75090a826b9', + 'size' => '637', + 'creation_date' => '1370877201', + 'modification_date' => '1369407629', + 'last_indexed' => '0', + 'missing' => '0', + 'metadata' => '0', + 'identifier_hash' => '475768e491580fb8b74ed36c2b1aaf619ca5e11d', + 'folder_hash' => 'b4ab666a114d9905a50606d1837b74d952dfd90f', + ], ], 'sys_file_metadata' => [ [ @@ -198,6 +218,14 @@ return [ 'cruser_id' => '1', 'file' => '4', ], + [ + 'uid' => '5', + 'pid' => '0', + 'tstamp' => '1371467047', + 'crdate' => '1371467047', + 'cruser_id' => '1', + 'file' => '5', + ], ], 'sys_file_reference' => [ [ @@ -280,6 +308,22 @@ return [ 'sorting_foreign' => '1', 'table_local' => 'sys_file', ], + [ + 'uid' => '6', + 'pid' => '2', + 'tstamp' => '1373537480', + 'crdate' => '1371484347', + 'cruser_id' => '1', + 'deleted' => '0', + 'hidden' => '0', + 'sys_language_uid' => '0', + 'uid_local' => '5', + 'uid_foreign' => '0', + 'tablenames' => '', + 'fieldname' => '', + 'sorting_foreign' => '0', + 'table_local' => 'sys_file', + ], ], 'tx_events_domain_model_region' => [ [ @@ -377,8 +421,8 @@ return [ 'uid' => '3', 'pid' => '2', 'event' => '2', - 'start' => '9999999998', - 'end' => '9999999999', + 'start' => (new DateTimeImmutable())->modify('+2 days')->format('U'), + 'end' => (new DateTimeImmutable())->modify('+3 days')->format('U'), 'canceled' => 'no', ], [ diff --git a/Tests/Functional/Cleanup/Fixtures/RemovePastTestFileadmin/user_uploads/example-for-no-longer-used.gif b/Tests/Functional/Cleanup/Fixtures/RemovePastTestFileadmin/user_uploads/example-for-no-longer-used.gif new file mode 100644 index 0000000..e69de29 diff --git a/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesAddsMultipleImagestoSingleEvent.php b/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesAddsMultipleImagestoSingleEvent.php new file mode 100644 index 0000000..a71eac4 --- /dev/null +++ b/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesAddsMultipleImagestoSingleEvent.php @@ -0,0 +1,72 @@ + [ + [ + 'uid' => 1, + 'pid' => 0, + 'missing' => 0, + 'storage' => 1, + 'type' => \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE, + 'identifier' => '/staedte/beispielstadt/events/theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg', + 'extension' => 'jpg', + 'name' => 'theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg', + ], + [ + 'uid' => 2, + 'pid' => 0, + 'missing' => 0, + 'storage' => 1, + 'type' => \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE, + 'identifier' => '/staedte/beispielstadt/events/tueftlerzeit-sfz-rudolstadt-jpg.jpg', + 'extension' => 'jpg', + 'name' => 'tueftlerzeit-sfz-rudolstadt-jpg.jpg', + ], + ], + 'sys_file_reference' => [ + [ + 'uid' => 1, + 'pid' => 2, + 'uid_local' => 1, + 'uid_foreign' => 1, + 'tablenames' => 'tx_events_domain_model_event', + 'fieldname' => 'images', + 'sorting_foreign' => 1, + 'table_local' => 'sys_file', + 'title' => null, + 'description' => null, + 'alternative' => null, + ], + [ + 'uid' => 2, + 'pid' => 2, + 'uid_local' => 2, + 'uid_foreign' => 1, + 'tablenames' => 'tx_events_domain_model_event', + 'fieldname' => 'images', + 'sorting_foreign' => 2, + 'table_local' => 'sys_file', + 'title' => null, + 'description' => null, + 'alternative' => null, + ], + ], + 'sys_file_metadata' => [ + [ + 'uid' => 1, + 'pid' => 0, + 'file' => 1, + 'title' => 'Theater-Rudolstadt_Johannes-Geißer_photo-by-Lisa-Stern_web_.jpg', + 'description' => '', + 'alternative' => 'DD Import', + ], + [ + 'uid' => 2, + 'pid' => 0, + 'file' => 2, + 'title' => 'Tueftlerzeit©SFZ-Rudolstadt.jpg', + 'description' => 'Description of Tueftlerzeit', + 'alternative' => 'DD Import', + ], + ], +]; diff --git a/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesAddsNewImageToExistingImages.php b/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesAddsNewImageToExistingImages.php new file mode 100644 index 0000000..e525cd2 --- /dev/null +++ b/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesAddsNewImageToExistingImages.php @@ -0,0 +1,112 @@ + [ + [ + 'uid' => 1, + 'pid' => 0, + 'missing' => 0, + 'storage' => 1, + 'type' => \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE, + 'identifier' => '/staedte/beispielstadt/events/theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg', + 'extension' => 'jpg', + 'name' => 'theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg', + 'identifier_hash' => 'fe4fcc840baa706899f7060096f693a01d8be36d', + 'folder_hash' => 'dcb2fdd85835a5ae315fdd7ef5cb2b859d9ec437', + 'sha1' => 'da39a3ee5e6b4b0d3255bfef95601890afd80709', + ], + [ + 'uid' => 2, + 'pid' => 0, + 'missing' => 0, + 'storage' => 1, + 'type' => \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE, + 'identifier' => '/staedte/beispielstadt/events/tueftlerzeit-sfz-rudolstadt-jpg.jpg', + 'extension' => 'jpg', + 'name' => 'tueftlerzeit-sfz-rudolstadt-jpg.jpg', + 'identifier_hash' => 'c87e5e8f8984291f9134cd2f8712e5ff82544d96', + 'folder_hash' => 'dcb2fdd85835a5ae315fdd7ef5cb2b859d9ec437', + 'sha1' => 'da39a3ee5e6b4b0d3255bfef95601890afd80709', + ], + [ + 'uid' => 3, + 'pid' => 0, + 'missing' => 0, + 'storage' => 1, + 'type' => \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE, + 'identifier' => '/staedte/beispielstadt/events/lutherkirche-jpg.jpg', + 'extension' => 'jpg', + 'name' => 'lutherkirche-jpg.jpg', + 'identifier_hash' => '8eca2f20c1226c3b1d2ec64418f10cb69926a7c0', + 'folder_hash' => 'dcb2fdd85835a5ae315fdd7ef5cb2b859d9ec437', + 'sha1' => 'da39a3ee5e6b4b0d3255bfef95601890afd80709', + ], + ], + 'sys_file_reference' => [ + [ + 'uid' => 1, + 'pid' => 2, + 'uid_local' => 1, + 'uid_foreign' => 1, + 'tablenames' => 'tx_events_domain_model_event', + 'fieldname' => 'images', + 'sorting_foreign' => 1, + 'table_local' => 'sys_file', + 'title' => null, + 'description' => null, + 'alternative' => null, + ], + [ + 'uid' => 2, + 'pid' => 2, + 'uid_local' => 2, + 'uid_foreign' => 1, + 'tablenames' => 'tx_events_domain_model_event', + 'fieldname' => 'images', + 'sorting_foreign' => 3, + 'table_local' => 'sys_file', + 'title' => null, + 'description' => null, + 'alternative' => null, + ], + [ + 'uid' => 3, + 'pid' => 2, + 'uid_local' => 3, + 'uid_foreign' => 1, + 'tablenames' => 'tx_events_domain_model_event', + 'fieldname' => 'images', + 'sorting_foreign' => 2, + 'table_local' => 'sys_file', + 'title' => null, + 'description' => null, + 'alternative' => null, + ], + ], + 'sys_file_metadata' => [ + [ + 'uid' => 1, + 'pid' => 0, + 'file' => 1, + 'title' => 'Theater-Rudolstadt_Johannes-Geißer_photo-by-Lisa-Stern_web_.jpg', + 'description' => '', + 'alternative' => 'DD Import', + ], + [ + 'uid' => 2, + 'pid' => 0, + 'file' => 2, + 'title' => 'Tueftlerzeit©SFZ-Rudolstadt.jpg', + 'description' => 'Description of Tueftlerzeit', + 'alternative' => 'DD Import', + ], + [ + 'uid' => 3, + 'pid' => 0, + 'file' => 3, + 'title' => 'Lutherkirche.jpg', + 'description' => '', + 'alternative' => 'DD Import', + ], + ], +]; diff --git a/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesAddsNewImages.php b/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesAddsNewImages.php new file mode 100644 index 0000000..df0a77c --- /dev/null +++ b/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesAddsNewImages.php @@ -0,0 +1,103 @@ + [ + [ + 'uid' => 1, + 'pid' => 0, + 'missing' => 0, + 'storage' => 1, + 'type' => \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE, + 'identifier' => '/staedte/beispielstadt/events/theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg', + 'extension' => 'jpg', + 'name' => 'theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg', + ], + [ + 'uid' => 2, + 'pid' => 0, + 'missing' => 0, + 'storage' => 1, + 'type' => \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE, + 'identifier' => '/staedte/beispielstadt/events/tueftlerzeit-sfz-rudolstadt-jpg.jpg', + 'extension' => 'jpg', + 'name' => 'tueftlerzeit-sfz-rudolstadt-jpg.jpg', + ], + [ + 'uid' => 3, + 'pid' => 0, + 'missing' => 0, + 'storage' => 1, + 'type' => \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE, + 'identifier' => '/staedte/beispielstadt/events/lutherkirche-jpg.jpg', + 'extension' => 'jpg', + 'name' => 'lutherkirche-jpg.jpg', + ], + ], + 'sys_file_reference' => [ + [ + 'uid' => 1, + 'pid' => 2, + 'uid_local' => 1, + 'uid_foreign' => 1, + 'tablenames' => 'tx_events_domain_model_event', + 'fieldname' => 'images', + 'sorting_foreign' => 1, + 'table_local' => 'sys_file', + 'title' => null, + 'description' => null, + 'alternative' => null, + ], + [ + 'uid' => 2, + 'pid' => 2, + 'uid_local' => 2, + 'uid_foreign' => 2, + 'tablenames' => 'tx_events_domain_model_event', + 'fieldname' => 'images', + 'sorting_foreign' => 1, + 'table_local' => 'sys_file', + 'title' => null, + 'description' => null, + 'alternative' => null, + ], + [ + 'uid' => 3, + 'pid' => 2, + 'uid_local' => 3, + 'uid_foreign' => 3, + 'tablenames' => 'tx_events_domain_model_event', + 'fieldname' => 'images', + 'sorting_foreign' => 1, + 'table_local' => 'sys_file', + 'title' => null, + 'description' => null, + 'alternative' => null, + ], + ], + 'sys_file_metadata' => [ + [ + 'uid' => 1, + 'pid' => 0, + 'file' => 1, + 'title' => 'Theater-Rudolstadt_Johannes-Geißer_photo-by-Lisa-Stern_web_.jpg', + 'description' => '', + 'alternative' => 'DD Import', + ], + [ + 'uid' => 2, + 'pid' => 0, + 'file' => 2, + 'title' => 'Tueftlerzeit©SFZ-Rudolstadt.jpg', + 'description' => 'Description of Tueftlerzeit', + 'alternative' => 'DD Import', + ], + [ + 'uid' => 3, + 'pid' => 0, + 'file' => 3, + 'title' => 'Lutherkirche.jpg', + 'description' => '', + 'alternative' => 'DD Import', + ], + ], +]; diff --git a/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesRemovesNoLongerExistingImages.php b/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesRemovesNoLongerExistingImages.php new file mode 100644 index 0000000..aa9980d --- /dev/null +++ b/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesRemovesNoLongerExistingImages.php @@ -0,0 +1,82 @@ + [ + [ + 'uid' => 1, + 'pid' => 0, + 'missing' => 0, + 'storage' => 1, + 'type' => \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE, + 'identifier' => '/staedte/beispielstadt/events/theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg', + 'extension' => 'jpg', + 'name' => 'theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg', + ], + [ + 'uid' => 2, + 'pid' => 0, + 'missing' => 0, + 'storage' => 1, + 'type' => \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE, + 'identifier' => '/staedte/beispielstadt/events/tueftlerzeit-sfz-rudolstadt-jpg.jpg', + 'extension' => 'jpg', + 'name' => 'tueftlerzeit-sfz-rudolstadt-jpg.jpg', + ], + ], + 'sys_file_reference' => [ + [ + 'uid' => 1, + 'pid' => 2, + 'uid_local' => 1, + 'uid_foreign' => 0, + 'tablenames' => '', + 'fieldname' => '', + 'sorting_foreign' => 0, + 'table_local' => '', + 'title' => null, + 'description' => null, + 'alternative' => null, + ], + [ + 'uid' => 2, + 'pid' => 2, + 'uid_local' => 2, + 'uid_foreign' => 1, + 'tablenames' => 'tx_events_domain_model_event', + 'fieldname' => 'images', + 'sorting_foreign' => 1, + 'table_local' => 'sys_file', + 'title' => null, + 'description' => null, + 'alternative' => null, + ], + ], + 'sys_file_metadata' => [ + [ + 'uid' => 1, + 'pid' => 0, + 'file' => 1, + 'title' => 'Theater-Rudolstadt_Johannes-Geißer_photo-by-Lisa-Stern_web_.jpg', + 'description' => '', + 'alternative' => 'DD Import', + ], + [ + 'uid' => 2, + 'pid' => 0, + 'file' => 2, + 'title' => 'Tueftlerzeit©SFZ-Rudolstadt.jpg', + 'description' => 'Description of Tueftlerzeit', + 'alternative' => 'DD Import', + ], + ], + 'tx_events_domain_model_event' => [ + [ + 'uid' => 1, + 'pid' => 2, + 'title' => 'Allerlei Weihnachtliches (Heute mit Johannes Geißer)', + 'global_id' => 'e_100347853', + 'slug' => 'allerlei-weihnachtliches-heute-mit-johannes-geisser', + 'images' => 1, + ], + ], +]; diff --git a/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesUpdatesExistingImage.php b/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesUpdatesExistingImage.php new file mode 100644 index 0000000..a71eac4 --- /dev/null +++ b/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesUpdatesExistingImage.php @@ -0,0 +1,72 @@ + [ + [ + 'uid' => 1, + 'pid' => 0, + 'missing' => 0, + 'storage' => 1, + 'type' => \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE, + 'identifier' => '/staedte/beispielstadt/events/theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg', + 'extension' => 'jpg', + 'name' => 'theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg', + ], + [ + 'uid' => 2, + 'pid' => 0, + 'missing' => 0, + 'storage' => 1, + 'type' => \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE, + 'identifier' => '/staedte/beispielstadt/events/tueftlerzeit-sfz-rudolstadt-jpg.jpg', + 'extension' => 'jpg', + 'name' => 'tueftlerzeit-sfz-rudolstadt-jpg.jpg', + ], + ], + 'sys_file_reference' => [ + [ + 'uid' => 1, + 'pid' => 2, + 'uid_local' => 1, + 'uid_foreign' => 1, + 'tablenames' => 'tx_events_domain_model_event', + 'fieldname' => 'images', + 'sorting_foreign' => 1, + 'table_local' => 'sys_file', + 'title' => null, + 'description' => null, + 'alternative' => null, + ], + [ + 'uid' => 2, + 'pid' => 2, + 'uid_local' => 2, + 'uid_foreign' => 1, + 'tablenames' => 'tx_events_domain_model_event', + 'fieldname' => 'images', + 'sorting_foreign' => 2, + 'table_local' => 'sys_file', + 'title' => null, + 'description' => null, + 'alternative' => null, + ], + ], + 'sys_file_metadata' => [ + [ + 'uid' => 1, + 'pid' => 0, + 'file' => 1, + 'title' => 'Theater-Rudolstadt_Johannes-Geißer_photo-by-Lisa-Stern_web_.jpg', + 'description' => '', + 'alternative' => 'DD Import', + ], + [ + 'uid' => 2, + 'pid' => 0, + 'file' => 2, + 'title' => 'Tueftlerzeit©SFZ-Rudolstadt.jpg', + 'description' => 'Description of Tueftlerzeit', + 'alternative' => 'DD Import', + ], + ], +]; diff --git a/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesUpdatesSortingOfImages.php b/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesUpdatesSortingOfImages.php new file mode 100644 index 0000000..03f6a18 --- /dev/null +++ b/Tests/Functional/Import/DestinationDataTest/Assertions/ImportHandlesImagesUpdatesSortingOfImages.php @@ -0,0 +1,72 @@ + [ + [ + 'uid' => 1, + 'pid' => 0, + 'missing' => 0, + 'storage' => 1, + 'type' => \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE, + 'identifier' => '/staedte/beispielstadt/events/theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg', + 'extension' => 'jpg', + 'name' => 'theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg', + ], + [ + 'uid' => 2, + 'pid' => 0, + 'missing' => 0, + 'storage' => 1, + 'type' => \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE, + 'identifier' => '/staedte/beispielstadt/events/tueftlerzeit-sfz-rudolstadt-jpg.jpg', + 'extension' => 'jpg', + 'name' => 'tueftlerzeit-sfz-rudolstadt-jpg.jpg', + ], + ], + 'sys_file_reference' => [ + [ + 'uid' => 1, + 'pid' => 2, + 'uid_local' => 1, + 'uid_foreign' => 1, + 'tablenames' => 'tx_events_domain_model_event', + 'fieldname' => 'images', + 'sorting_foreign' => 2, + 'table_local' => 'sys_file', + 'title' => null, + 'description' => null, + 'alternative' => null, + ], + [ + 'uid' => 2, + 'pid' => 2, + 'uid_local' => 2, + 'uid_foreign' => 1, + 'tablenames' => 'tx_events_domain_model_event', + 'fieldname' => 'images', + 'sorting_foreign' => 1, + 'table_local' => 'sys_file', + 'title' => null, + 'description' => null, + 'alternative' => null, + ], + ], + 'sys_file_metadata' => [ + [ + 'uid' => 1, + 'pid' => 0, + 'file' => 1, + 'title' => 'Theater-Rudolstadt_Johannes-Geißer_photo-by-Lisa-Stern_web_.jpg', + 'description' => '', + 'alternative' => 'DD Import', + ], + [ + 'uid' => 2, + 'pid' => 0, + 'file' => 2, + 'title' => 'Tueftlerzeit©SFZ-Rudolstadt.jpg', + 'description' => 'Description of Tueftlerzeit', + 'alternative' => 'DD Import', + ], + ], +]; diff --git a/Tests/Functional/Import/DestinationDataTest/Fixtures/Database/ImportHandlesImagesExistingData.php b/Tests/Functional/Import/DestinationDataTest/Fixtures/Database/ImportHandlesImagesExistingData.php new file mode 100644 index 0000000..e6e632e --- /dev/null +++ b/Tests/Functional/Import/DestinationDataTest/Fixtures/Database/ImportHandlesImagesExistingData.php @@ -0,0 +1,88 @@ + [ + [ + 'uid' => 1, + 'pid' => 0, + 'missing' => 0, + 'storage' => 1, + 'type' => \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE, + 'identifier' => '/staedte/beispielstadt/events/theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg', + 'extension' => 'jpg', + 'name' => 'theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg', + 'identifier_hash' => 'fe4fcc840baa706899f7060096f693a01d8be36d', + 'folder_hash' => 'dcb2fdd85835a5ae315fdd7ef5cb2b859d9ec437', + 'sha1' => 'da39a3ee5e6b4b0d3255bfef95601890afd80709', + ], + [ + 'uid' => 2, + 'pid' => 0, + 'missing' => 0, + 'storage' => 1, + 'type' => \TYPO3\CMS\Core\Resource\File::FILETYPE_IMAGE, + 'identifier' => '/staedte/beispielstadt/events/tueftlerzeit-sfz-rudolstadt-jpg.jpg', + 'extension' => 'jpg', + 'name' => 'tueftlerzeit-sfz-rudolstadt-jpg.jpg', + 'identifier_hash' => 'c87e5e8f8984291f9134cd2f8712e5ff82544d96', + 'folder_hash' => 'dcb2fdd85835a5ae315fdd7ef5cb2b859d9ec437', + 'sha1' => 'da39a3ee5e6b4b0d3255bfef95601890afd80709', + ], + ], + 'sys_file_reference' => [ + [ + 'uid' => 1, + 'pid' => 2, + 'uid_local' => 1, + 'uid_foreign' => 1, + 'tablenames' => 'tx_events_domain_model_event', + 'fieldname' => 'images', + 'sorting_foreign' => 1, + 'table_local' => 'sys_file', + 'title' => null, + 'description' => null, + 'alternative' => null, + ], + [ + 'uid' => 2, + 'pid' => 2, + 'uid_local' => 2, + 'uid_foreign' => 1, + 'tablenames' => 'tx_events_domain_model_event', + 'fieldname' => 'images', + 'sorting_foreign' => 2, + 'table_local' => 'sys_file', + 'title' => null, + 'description' => null, + 'alternative' => null, + ], + ], + 'sys_file_metadata' => [ + [ + 'uid' => 1, + 'pid' => 0, + 'file' => 1, + 'title' => 'Theater-Rudolstadt_Johannes-Geißer_photo-by-Lisa-Stern_web_.jpg', + 'description' => '', + 'alternative' => 'DD Import', + ], + [ + 'uid' => 2, + 'pid' => 0, + 'file' => 2, + 'title' => 'Tueftlerzeit©SFZ-Rudolstadt.jpg', + 'description' => 'Description of Tueftlerzeit', + 'alternative' => 'DD Import', + ], + ], + 'tx_events_domain_model_event' => [ + [ + 'uid' => 1, + 'pid' => 2, + 'title' => 'Allerlei Weihnachtliches (Heute mit Johannes Geißer)', + 'global_id' => 'e_100347853', + 'slug' => 'allerlei-weihnachtliches-heute-mit-johannes-geisser', + 'images' => 2, + ], + ], +]; diff --git a/Tests/Functional/Import/DestinationDataTest/Fixtures/ResponseWithMultipleImagesForSingleEvent.json b/Tests/Functional/Import/DestinationDataTest/Fixtures/ResponseWithMultipleImagesForSingleEvent.json new file mode 100644 index 0000000..5558c03 --- /dev/null +++ b/Tests/Functional/Import/DestinationDataTest/Fixtures/ResponseWithMultipleImagesForSingleEvent.json @@ -0,0 +1,194 @@ +{ + "status": "OK", + "count": 3, + "overallcount": 50, + "channels": [], + "facetGroups": [], + "items": [ + { + "global_id": "e_100347853", + "id": "100347853", + "title": "Allerlei Weihnachtliches (Heute mit Johannes Geißer)", + "type": "Event", + "categories": [ + "Weihnachten" + ], + "texts": [ + { + "rel": "details", + "type": "text/html", + "value": "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. 
" + }, + { + "rel": "details", + "type": "text/plain", + "value": "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.\nEintritt: 10 € (inkl. Gedeck mit weihnachtlicher Schillerlocke)\nUm Voranmeldung unter 03672-486470 oder schillerhaus@rudolstadt.de wird gebeten.\nEs gilt die 2G-PLUS-Regel." + }, + { + "rel": "teaser", + "type": "text/html" + }, + { + "rel": "teaser", + "type": "text/plain" + } + ], + "country": "Deutschland", + "areas": [ + "Rudolstadt und Umgebung" + ], + "city": "Rudolstadt", + "zip": "07407", + "street": "Schillerstraße 25", + "phone": "+ 49 3672 / 486470", + "fax": "+ 49 3672 / 486475", + "web": "http://www.schillerhaus.rudolstadt.de/", + "email": "schillerhaus@rudolstadt.de", + "author": "support@hubermedia.de", + "geo": { + "main": { + "latitude": 50.720971023258805, + "longitude": 11.335229873657227 + }, + "entry": [], + "attributes": [] + }, + "ratings": [ + { + "type": "eT4", + "value": 40.0 + }, + { + "type": "order", + "value": 99.0001 + } + ], + "cuisine_types": [], + "payment": [], + "media_objects": [ + { + "rel": "venuewebsite", + "url": "http://schillerhaus.rudolstadt.de/", + "latitude": null, + "longitude": null, + "value": "" + }, + { + "rel": "default", + "url": "https://dam.destination.one/849917/279ac45b3fc701a7197131f627164fffd9f8cc77bc75165e2fc2b864ed606920/theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg", + "type": "image/jpeg", + "latitude": null, + "longitude": null, + "width": 1920, + "height": 1080, + "value": "Theater-Rudolstadt_Johannes-Geißer_photo-by-Lisa-Stern_web_.jpg" + }, + { + "rel": "default", + "url": "https://dam.destination.one/828118/f13bbf5602ffc406ebae2faa3527654dea84194666bce4925a1ca8bd3f50c5e9/tueftlerzeit-sfz-rudolstadt-jpg.jpg", + "type": "image/jpeg", + "latitude": null, + "longitude": null, + "description": "Description of Tueftlerzeit", + "width": 1920, + "height": 1080, + "value": "Tueftlerzeit©SFZ-Rudolstadt.jpg" + } + ], + "keywords": [], + "timeIntervals": [ + { + "weekdays": [], + "start": "2022-12-19T15:00:00+01:00", + "end": "2022-12-19T16:30:00+01:00", + "tz": "Europe/Berlin", + "interval": 1 + } + ], + "kitchenTimeIntervals": [], + "deliveryTimeIntervals": [], + "numbers": [], + "name": "Schillerhaus Rudolstadt", + "attributes": [ + { + "key": "VO_Id", + "value": "100050775" + }, + { + "key": "VO_CategoryName", + "value": "POI" + }, + { + "key": "VA_Id", + "value": "100050775" + }, + { + "key": "VA_CategoryName", + "value": "POI" + }, + { + "key": "interval_first_match_start", + "value": "2022-12-19T15:00:00+01" + }, + { + "key": "interval_first_match_end", + "value": "2022-12-19T16:30:00+01" + }, + { + "key": "interval_match_count", + "value": "1" + } + ], + "features": [ + "vorhandenes Feature", + "Barrierefrei", + "Zielgruppe Jugendliche", + "Karten an der Abendkasse", + "Ausreichende Lüftung", + "Beachtung der Hygienehinweise" + ], + "addresses": [ + { + "name": "Städtetourismus in Thüringen e.V.", + "city": "Weimar", + "zip": "99423", + "street": "UNESCO-Platz 1", + "phone": "+49 (3643) 745 314", + "web": "http://www.thueringer-staedte.de", + "email": "verein@thueringer-staedte.de", + "rel": "author" + }, + { + "name": "Städtetourismus in Thüringen\" e.V.", + "web": "http://www.thueringer-staedte.de", + "email": "verein@thueringer-staedte.de", + "rel": "organisation" + }, + { + "name": "Schillerhaus Rudolstadt", + "city": "Rudolstadt", + "zip": "07407", + "street": "Schillerstraße 25", + "phone": "+ 49 3672 / 486470", + "fax": "+ 49 3672 / 486475", + "web": "http://schillerhaus.rudolstadt.de", + "email": "schillerhaus@rudolstadt.de", + "rel": "organizer" + } + ], + "created": "2022-10-31T12:29:00+00:00", + "changed": "2022-12-14T08:29:00+00:00", + "source": { + "url": "http://destination.one/", + "value": "destination.one" + }, + "company": "", + "district": "", + "postoffice": "", + "phone2": "", + "seasons": [], + "subitems": [], + "hyperObjects": [] + } + ] +} diff --git a/Tests/Functional/Import/DestinationDataTest/Fixtures/ResponseWithNewImages.json b/Tests/Functional/Import/DestinationDataTest/Fixtures/ResponseWithNewImages.json new file mode 100644 index 0000000..b6be236 --- /dev/null +++ b/Tests/Functional/Import/DestinationDataTest/Fixtures/ResponseWithNewImages.json @@ -0,0 +1,557 @@ +{ + "status": "OK", + "count": 3, + "overallcount": 50, + "channels": [], + "facetGroups": [], + "items": [ + { + "global_id": "e_100347853", + "id": "100347853", + "title": "Allerlei Weihnachtliches (Heute mit Johannes Geißer)", + "type": "Event", + "categories": [ + "Weihnachten" + ], + "texts": [ + { + "rel": "details", + "type": "text/html", + "value": "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. 
" + }, + { + "rel": "details", + "type": "text/plain", + "value": "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.\nEintritt: 10 € (inkl. Gedeck mit weihnachtlicher Schillerlocke)\nUm Voranmeldung unter 03672-486470 oder schillerhaus@rudolstadt.de wird gebeten.\nEs gilt die 2G-PLUS-Regel." + }, + { + "rel": "teaser", + "type": "text/html" + }, + { + "rel": "teaser", + "type": "text/plain" + } + ], + "country": "Deutschland", + "areas": [ + "Rudolstadt und Umgebung" + ], + "city": "Rudolstadt", + "zip": "07407", + "street": "Schillerstraße 25", + "phone": "+ 49 3672 / 486470", + "fax": "+ 49 3672 / 486475", + "web": "http://www.schillerhaus.rudolstadt.de/", + "email": "schillerhaus@rudolstadt.de", + "author": "support@hubermedia.de", + "geo": { + "main": { + "latitude": 50.720971023258805, + "longitude": 11.335229873657227 + }, + "entry": [], + "attributes": [] + }, + "ratings": [ + { + "type": "eT4", + "value": 40.0 + }, + { + "type": "order", + "value": 99.0001 + } + ], + "cuisine_types": [], + "payment": [], + "media_objects": [ + { + "rel": "venuewebsite", + "url": "http://schillerhaus.rudolstadt.de/", + "latitude": null, + "longitude": null, + "value": "" + }, + { + "rel": "default", + "url": "https://dam.destination.one/849917/279ac45b3fc701a7197131f627164fffd9f8cc77bc75165e2fc2b864ed606920/theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg", + "type": "image/jpeg", + "latitude": null, + "longitude": null, + "width": 1920, + "height": 1080, + "value": "Theater-Rudolstadt_Johannes-Geißer_photo-by-Lisa-Stern_web_.jpg" + } + ], + "keywords": [], + "timeIntervals": [ + { + "weekdays": [], + "start": "2022-12-19T15:00:00+01:00", + "end": "2022-12-19T16:30:00+01:00", + "tz": "Europe/Berlin", + "interval": 1 + } + ], + "kitchenTimeIntervals": [], + "deliveryTimeIntervals": [], + "numbers": [], + "name": "Schillerhaus Rudolstadt", + "attributes": [ + { + "key": "VO_Id", + "value": "100050775" + }, + { + "key": "VO_CategoryName", + "value": "POI" + }, + { + "key": "VA_Id", + "value": "100050775" + }, + { + "key": "VA_CategoryName", + "value": "POI" + }, + { + "key": "interval_first_match_start", + "value": "2022-12-19T15:00:00+01" + }, + { + "key": "interval_first_match_end", + "value": "2022-12-19T16:30:00+01" + }, + { + "key": "interval_match_count", + "value": "1" + } + ], + "features": [ + "vorhandenes Feature", + "Barrierefrei", + "Zielgruppe Jugendliche", + "Karten an der Abendkasse", + "Ausreichende Lüftung", + "Beachtung der Hygienehinweise" + ], + "addresses": [ + { + "name": "Städtetourismus in Thüringen e.V.", + "city": "Weimar", + "zip": "99423", + "street": "UNESCO-Platz 1", + "phone": "+49 (3643) 745 314", + "web": "http://www.thueringer-staedte.de", + "email": "verein@thueringer-staedte.de", + "rel": "author" + }, + { + "name": "Städtetourismus in Thüringen\" e.V.", + "web": "http://www.thueringer-staedte.de", + "email": "verein@thueringer-staedte.de", + "rel": "organisation" + }, + { + "name": "Schillerhaus Rudolstadt", + "city": "Rudolstadt", + "zip": "07407", + "street": "Schillerstraße 25", + "phone": "+ 49 3672 / 486470", + "fax": "+ 49 3672 / 486475", + "web": "http://schillerhaus.rudolstadt.de", + "email": "schillerhaus@rudolstadt.de", + "rel": "organizer" + } + ], + "created": "2022-10-31T12:29:00+00:00", + "changed": "2022-12-14T08:29:00+00:00", + "source": { + "url": "http://destination.one/", + "value": "destination.one" + }, + "company": "", + "district": "", + "postoffice": "", + "phone2": "", + "seasons": [], + "subitems": [], + "hyperObjects": [] + }, + { + "global_id": "e_100354481", + "id": "100354481", + "title": "Tüftlerzeit", + "type": "Event", + "categories": [ + "Kinder" + ], + "texts": [ + { + "rel": "details", + "type": "text/html", + "value": "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." + }, + { + "rel": "details", + "type": "text/plain", + "value": "Die Tüftlerzeit wird dieses Mal ein weihnachtliches Angebot bereithalten. Alle kleinen Tüftler dürfen gespannt sein.\nVoranmeldung über: kinderbibliothek@rudolstadt.de oder 03672-486420\n\nBitte beachten Sie die derzeit geltenden Zugangsregeln." + }, + { + "rel": "teaser", + "type": "text/html" + }, + { + "rel": "teaser", + "type": "text/plain" + } + ], + "country": "Deutschland", + "areas": [ + "Rudolstadt und Umgebung" + ], + "city": "Rudolstadt", + "zip": "07407", + "street": "Schulplatz 13", + "phone": "0 36 72 - 48 64 20", + "fax": "0 36 72 - 48 64 30", + "web": "http://www.stadtbibliothek-rudolstadt.de/", + "email": "stadtbibliothek@rudolstadt.de", + "author": "support@hubermedia.de", + "geo": { + "main": { + "latitude": 50.720835175055917, + "longitude": 11.342568397521973 + }, + "entry": [], + "attributes": [] + }, + "ratings": [ + { + "type": "eT4", + "value": 40.0 + }, + { + "type": "order", + "value": 99.0001 + } + ], + "cuisine_types": [], + "payment": [], + "media_objects": [ + { + "rel": "venuewebsite", + "url": "http://www.stadtbibliothek-rudolstadt.de/", + "latitude": null, + "longitude": null, + "value": "" + }, + { + "rel": "default", + "url": "https://dam.destination.one/828118/f13bbf5602ffc406ebae2faa3527654dea84194666bce4925a1ca8bd3f50c5e9/tueftlerzeit-sfz-rudolstadt-jpg.jpg", + "type": "image/jpeg", + "latitude": null, + "longitude": null, + "description": "Description of Tueftlerzeit", + "width": 1920, + "height": 1080, + "value": "Tueftlerzeit©SFZ-Rudolstadt.jpg" + } + ], + "keywords": [], + "timeIntervals": [ + { + "weekdays": [], + "start": "2022-12-16T15:00:00+01:00", + "end": "2022-12-16T16:30:00+01:00", + "tz": "Europe/Berlin", + "interval": 1 + }, + { + "weekdays": [], + "start": "2022-04-01T11:00:00+02:00", + "end": "2022-04-01T13:00:00+02:00", + "repeatUntil": "2022-04-03T00:00+02:00", + "tz": "Europe/Berlin", + "freq": "Daily", + "interval": 1 + }, + { + "weekdays": [], + "start": "2022-02-17T15:00:00+01:00", + "end": "2022-02-17T17:00:00+01:00", + "tz": "Europe/Berlin", + "interval": 1 + } + ], + "kitchenTimeIntervals": [], + "deliveryTimeIntervals": [], + "numbers": [], + "name": "Stadtbibliothek Rudolstadt", + "attributes": [ + { + "key": "VO_Id", + "value": "100042570" + }, + { + "key": "VO_CategoryName", + "value": "POI" + }, + { + "key": "VA_Id", + "value": "100042570" + }, + { + "key": "VA_CategoryName", + "value": "POI" + }, + { + "key": "interval_first_match_start", + "value": "2022-12-16T15:00:00+01" + }, + { + "key": "interval_first_match_end", + "value": "2022-12-16T16:30:00+01" + }, + { + "key": "interval_match_count", + "value": "3" + }, + { + "key": "interval_last_match_start", + "value": "2022-02-17T15:00:00+01" + }, + { + "key": "interval_last_match_end", + "value": "2022-02-17T17:00:00+01" + } + ], + "features": [], + "addresses": [ + { + "name": "Städtetourismus in Thüringen e.V.", + "city": "Weimar", + "zip": "99423", + "street": "UNESCO-Platz 1", + "phone": "+49 (3643) 745 314", + "web": "http://www.thueringer-staedte.de", + "email": "verein@thueringer-staedte.de", + "rel": "author" + }, + { + "name": "Städtetourismus in Thüringen\" e.V.", + "web": "http://www.thueringer-staedte.de", + "email": "verein@thueringer-staedte.de", + "rel": "organisation" + }, + { + "name": "Stadtbibliothek Rudolstadt", + "city": "Rudolstadt", + "zip": "07407", + "street": "Schulplatz 13", + "phone": "0 36 72 - 48 64 20", + "fax": "0 36 72 - 48 64 30", + "web": "http://www.stadtbibliothek-rudolstadt.de ", + "email": "stadtbibliothek@rudolstadt.de", + "rel": "organizer" + } + ], + "created": "2022-11-10T23:02:00+00:00", + "changed": "2022-12-14T08:28:00+00:00", + "source": { + "url": "http://destination.one/", + "value": "destination.one" + }, + "company": "", + "district": "", + "postoffice": "", + "phone2": "", + "seasons": [], + "subitems": [], + "hyperObjects": [] + }, + { + "global_id": "e_100350503", + "id": "100350503", + "title": "Adventliche Orgelmusik (Orgel: KMD Frank Bettenhausen)", + "type": "Event", + "categories": [ + "Konzerte, Festivals, Show & Tanz", + "Weihnachten" + ], + "texts": [ + { + "rel": "details", + "type": "text/html", + "value": "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.
" + }, + { + "rel": "details", + "type": "text/plain", + "value": "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.\n\nEs gilt die 2G-PLUS-Regel." + }, + { + "rel": "teaser", + "type": "text/html" + }, + { + "rel": "teaser", + "type": "text/plain" + } + ], + "country": "Deutschland", + "areas": [ + "Rudolstadt und Umgebung" + ], + "city": "Rudolstadt", + "zip": "07407", + "street": "Caspar-Schulte-Straße", + "phone": "03672 - 48 96 13", + "author": "support@hubermedia.de", + "geo": { + "main": { + "latitude": 50.718688721182531, + "longitude": 11.327333450317383 + }, + "entry": [], + "attributes": [] + }, + "ratings": [ + { + "type": "eT4", + "value": 40.0 + }, + { + "type": "order", + "value": 99.0001 + } + ], + "cuisine_types": [], + "payment": [], + "media_objects": [ + { + "rel": "default", + "url": "https://dam.destination.one/853436/109ac1cf87913e21b5e2b0ef0cc63d223a14374364952a855746a8e7c3fcfc36/lutherkirche-jpg.jpg", + "type": "image/jpeg", + "latitude": null, + "longitude": null, + "width": 1920, + "height": 1080, + "value": "Lutherkirche.jpg" + } + ], + "keywords": [], + "timeIntervals": [ + { + "weekdays": [], + "start": "2022-12-01T19:00:00+01:00", + "end": "2022-12-01T20:00:00+01:00", + "tz": "Europe/Berlin", + "interval": 1 + }, + { + "weekdays": [ + "Saturday", + "Sunday" + ], + "start": "2022-11-02T11:00:00+01:00", + "end": "2022-11-02T13:00:00+01:00", + "repeatUntil": "2022-11-25T13:00:00+01:00", + "tz": "Europe/Berlin", + "freq": "Weekly", + "interval": 1 + }, + { + "weekdays": [], + "start": "2022-12-22T19:00:00+01:00", + "end": "2022-12-22T20:00:00+01:00", + "tz": "Europe/Berlin", + "interval": 1 + } + ], + "kitchenTimeIntervals": [], + "deliveryTimeIntervals": [], + "numbers": [], + "name": "Lutherkirche", + "attributes": [ + { + "key": "VO_Id", + "value": "100118350" + }, + { + "key": "VO_CategoryName", + "value": "POI" + }, + { + "key": "VA_Id", + "value": "100118350" + }, + { + "key": "VA_CategoryName", + "value": "POI" + }, + { + "key": "interval_first_match_start", + "value": "2022-12-15T19:00:00+01" + }, + { + "key": "interval_first_match_end", + "value": "2022-12-15T20:00:00+01" + }, + { + "key": "interval_match_count", + "value": "2" + }, + { + "key": "interval_last_match_start", + "value": "2022-12-22T19:00:00+01" + }, + { + "key": "interval_last_match_end", + "value": "2022-12-22T20:00:00+01" + } + ], + "features": [], + "addresses": [ + { + "name": "Städtetourismus in Thüringen e.V.", + "city": "Weimar", + "zip": "99423", + "street": "UNESCO-Platz 1", + "phone": "+49 (3643) 745 314", + "web": "http://www.thueringer-staedte.de", + "email": "verein@thueringer-staedte.de", + "rel": "author" + }, + { + "name": "Städtetourismus in Thüringen\" e.V.", + "web": "http://www.thueringer-staedte.de", + "email": "verein@thueringer-staedte.de", + "rel": "organisation" + }, + { + "name": "Lutherkirche", + "city": "Rudolstadt", + "zip": "07407", + "street": "Caspar-Schulte-Straße", + "phone": "03672 - 48 96 13", + "rel": "organizer" + } + ], + "created": "2022-11-08T22:15:00+00:00", + "changed": "2022-12-14T08:38:00+00:00", + "source": { + "url": "http://destination.one/", + "value": "destination.one" + }, + "company": "", + "district": "", + "postoffice": "", + "phone2": "", + "seasons": [], + "subitems": [], + "hyperObjects": [] + } + ] +} diff --git a/Tests/Functional/Import/DestinationDataTest/Fixtures/ResponseWithOneMoreImageForSingleEvent.json b/Tests/Functional/Import/DestinationDataTest/Fixtures/ResponseWithOneMoreImageForSingleEvent.json new file mode 100644 index 0000000..33615a6 --- /dev/null +++ b/Tests/Functional/Import/DestinationDataTest/Fixtures/ResponseWithOneMoreImageForSingleEvent.json @@ -0,0 +1,204 @@ +{ + "status": "OK", + "count": 3, + "overallcount": 50, + "channels": [], + "facetGroups": [], + "items": [ + { + "global_id": "e_100347853", + "id": "100347853", + "title": "Allerlei Weihnachtliches (Heute mit Johannes Geißer)", + "type": "Event", + "categories": [ + "Weihnachten" + ], + "texts": [ + { + "rel": "details", + "type": "text/html", + "value": "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. 
" + }, + { + "rel": "details", + "type": "text/plain", + "value": "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.\nEintritt: 10 € (inkl. Gedeck mit weihnachtlicher Schillerlocke)\nUm Voranmeldung unter 03672-486470 oder schillerhaus@rudolstadt.de wird gebeten.\nEs gilt die 2G-PLUS-Regel." + }, + { + "rel": "teaser", + "type": "text/html" + }, + { + "rel": "teaser", + "type": "text/plain" + } + ], + "country": "Deutschland", + "areas": [ + "Rudolstadt und Umgebung" + ], + "city": "Rudolstadt", + "zip": "07407", + "street": "Schillerstraße 25", + "phone": "+ 49 3672 / 486470", + "fax": "+ 49 3672 / 486475", + "web": "http://www.schillerhaus.rudolstadt.de/", + "email": "schillerhaus@rudolstadt.de", + "author": "support@hubermedia.de", + "geo": { + "main": { + "latitude": 50.720971023258805, + "longitude": 11.335229873657227 + }, + "entry": [], + "attributes": [] + }, + "ratings": [ + { + "type": "eT4", + "value": 40.0 + }, + { + "type": "order", + "value": 99.0001 + } + ], + "cuisine_types": [], + "payment": [], + "media_objects": [ + { + "rel": "venuewebsite", + "url": "http://schillerhaus.rudolstadt.de/", + "latitude": null, + "longitude": null, + "value": "" + }, + { + "rel": "default", + "url": "https://dam.destination.one/849917/279ac45b3fc701a7197131f627164fffd9f8cc77bc75165e2fc2b864ed606920/theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg", + "type": "image/jpeg", + "latitude": null, + "longitude": null, + "width": 1920, + "height": 1080, + "value": "Theater-Rudolstadt_Johannes-Geißer_photo-by-Lisa-Stern_web_.jpg" + }, + { + "rel": "default", + "url": "https://dam.destination.one/853436/109ac1cf87913e21b5e2b0ef0cc63d223a14374364952a855746a8e7c3fcfc36/lutherkirche-jpg.jpg", + "type": "image/jpeg", + "latitude": null, + "longitude": null, + "width": 1920, + "height": 1080, + "value": "Lutherkirche.jpg" + }, + { + "rel": "default", + "url": "https://dam.destination.one/828118/f13bbf5602ffc406ebae2faa3527654dea84194666bce4925a1ca8bd3f50c5e9/tueftlerzeit-sfz-rudolstadt-jpg.jpg", + "type": "image/jpeg", + "latitude": null, + "longitude": null, + "description": "Description of Tueftlerzeit", + "width": 1920, + "height": 1080, + "value": "Tueftlerzeit©SFZ-Rudolstadt.jpg" + } + ], + "keywords": [], + "timeIntervals": [ + { + "weekdays": [], + "start": "2022-12-19T15:00:00+01:00", + "end": "2022-12-19T16:30:00+01:00", + "tz": "Europe/Berlin", + "interval": 1 + } + ], + "kitchenTimeIntervals": [], + "deliveryTimeIntervals": [], + "numbers": [], + "name": "Schillerhaus Rudolstadt", + "attributes": [ + { + "key": "VO_Id", + "value": "100050775" + }, + { + "key": "VO_CategoryName", + "value": "POI" + }, + { + "key": "VA_Id", + "value": "100050775" + }, + { + "key": "VA_CategoryName", + "value": "POI" + }, + { + "key": "interval_first_match_start", + "value": "2022-12-19T15:00:00+01" + }, + { + "key": "interval_first_match_end", + "value": "2022-12-19T16:30:00+01" + }, + { + "key": "interval_match_count", + "value": "1" + } + ], + "features": [ + "vorhandenes Feature", + "Barrierefrei", + "Zielgruppe Jugendliche", + "Karten an der Abendkasse", + "Ausreichende Lüftung", + "Beachtung der Hygienehinweise" + ], + "addresses": [ + { + "name": "Städtetourismus in Thüringen e.V.", + "city": "Weimar", + "zip": "99423", + "street": "UNESCO-Platz 1", + "phone": "+49 (3643) 745 314", + "web": "http://www.thueringer-staedte.de", + "email": "verein@thueringer-staedte.de", + "rel": "author" + }, + { + "name": "Städtetourismus in Thüringen\" e.V.", + "web": "http://www.thueringer-staedte.de", + "email": "verein@thueringer-staedte.de", + "rel": "organisation" + }, + { + "name": "Schillerhaus Rudolstadt", + "city": "Rudolstadt", + "zip": "07407", + "street": "Schillerstraße 25", + "phone": "+ 49 3672 / 486470", + "fax": "+ 49 3672 / 486475", + "web": "http://schillerhaus.rudolstadt.de", + "email": "schillerhaus@rudolstadt.de", + "rel": "organizer" + } + ], + "created": "2022-10-31T12:29:00+00:00", + "changed": "2022-12-14T08:29:00+00:00", + "source": { + "url": "http://destination.one/", + "value": "destination.one" + }, + "company": "", + "district": "", + "postoffice": "", + "phone2": "", + "seasons": [], + "subitems": [], + "hyperObjects": [] + } + ] +} diff --git a/Tests/Functional/Import/DestinationDataTest/Fixtures/ResponseWithSingleImageForSingleEvent.json b/Tests/Functional/Import/DestinationDataTest/Fixtures/ResponseWithSingleImageForSingleEvent.json new file mode 100644 index 0000000..43abde5 --- /dev/null +++ b/Tests/Functional/Import/DestinationDataTest/Fixtures/ResponseWithSingleImageForSingleEvent.json @@ -0,0 +1,184 @@ +{ + "status": "OK", + "count": 3, + "overallcount": 50, + "channels": [], + "facetGroups": [], + "items": [ + { + "global_id": "e_100347853", + "id": "100347853", + "title": "Allerlei Weihnachtliches (Heute mit Johannes Geißer)", + "type": "Event", + "categories": [ + "Weihnachten" + ], + "texts": [ + { + "rel": "details", + "type": "text/html", + "value": "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. 
" + }, + { + "rel": "details", + "type": "text/plain", + "value": "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.\nEintritt: 10 € (inkl. Gedeck mit weihnachtlicher Schillerlocke)\nUm Voranmeldung unter 03672-486470 oder schillerhaus@rudolstadt.de wird gebeten.\nEs gilt die 2G-PLUS-Regel." + }, + { + "rel": "teaser", + "type": "text/html" + }, + { + "rel": "teaser", + "type": "text/plain" + } + ], + "country": "Deutschland", + "areas": [ + "Rudolstadt und Umgebung" + ], + "city": "Rudolstadt", + "zip": "07407", + "street": "Schillerstraße 25", + "phone": "+ 49 3672 / 486470", + "fax": "+ 49 3672 / 486475", + "web": "http://www.schillerhaus.rudolstadt.de/", + "email": "schillerhaus@rudolstadt.de", + "author": "support@hubermedia.de", + "geo": { + "main": { + "latitude": 50.720971023258805, + "longitude": 11.335229873657227 + }, + "entry": [], + "attributes": [] + }, + "ratings": [ + { + "type": "eT4", + "value": 40.0 + }, + { + "type": "order", + "value": 99.0001 + } + ], + "cuisine_types": [], + "payment": [], + "media_objects": [ + { + "rel": "venuewebsite", + "url": "http://schillerhaus.rudolstadt.de/", + "latitude": null, + "longitude": null, + "value": "" + }, + { + "rel": "default", + "url": "https://dam.destination.one/828118/f13bbf5602ffc406ebae2faa3527654dea84194666bce4925a1ca8bd3f50c5e9/tueftlerzeit-sfz-rudolstadt-jpg.jpg", + "type": "image/jpeg", + "latitude": null, + "longitude": null, + "description": "Description of Tueftlerzeit", + "width": 1920, + "height": 1080, + "value": "Tueftlerzeit©SFZ-Rudolstadt.jpg" + } + ], + "keywords": [], + "timeIntervals": [ + { + "weekdays": [], + "start": "2022-12-19T15:00:00+01:00", + "end": "2022-12-19T16:30:00+01:00", + "tz": "Europe/Berlin", + "interval": 1 + } + ], + "kitchenTimeIntervals": [], + "deliveryTimeIntervals": [], + "numbers": [], + "name": "Schillerhaus Rudolstadt", + "attributes": [ + { + "key": "VO_Id", + "value": "100050775" + }, + { + "key": "VO_CategoryName", + "value": "POI" + }, + { + "key": "VA_Id", + "value": "100050775" + }, + { + "key": "VA_CategoryName", + "value": "POI" + }, + { + "key": "interval_first_match_start", + "value": "2022-12-19T15:00:00+01" + }, + { + "key": "interval_first_match_end", + "value": "2022-12-19T16:30:00+01" + }, + { + "key": "interval_match_count", + "value": "1" + } + ], + "features": [ + "vorhandenes Feature", + "Barrierefrei", + "Zielgruppe Jugendliche", + "Karten an der Abendkasse", + "Ausreichende Lüftung", + "Beachtung der Hygienehinweise" + ], + "addresses": [ + { + "name": "Städtetourismus in Thüringen e.V.", + "city": "Weimar", + "zip": "99423", + "street": "UNESCO-Platz 1", + "phone": "+49 (3643) 745 314", + "web": "http://www.thueringer-staedte.de", + "email": "verein@thueringer-staedte.de", + "rel": "author" + }, + { + "name": "Städtetourismus in Thüringen\" e.V.", + "web": "http://www.thueringer-staedte.de", + "email": "verein@thueringer-staedte.de", + "rel": "organisation" + }, + { + "name": "Schillerhaus Rudolstadt", + "city": "Rudolstadt", + "zip": "07407", + "street": "Schillerstraße 25", + "phone": "+ 49 3672 / 486470", + "fax": "+ 49 3672 / 486475", + "web": "http://schillerhaus.rudolstadt.de", + "email": "schillerhaus@rudolstadt.de", + "rel": "organizer" + } + ], + "created": "2022-10-31T12:29:00+00:00", + "changed": "2022-12-14T08:29:00+00:00", + "source": { + "url": "http://destination.one/", + "value": "destination.one" + }, + "company": "", + "district": "", + "postoffice": "", + "phone2": "", + "seasons": [], + "subitems": [], + "hyperObjects": [] + } + ] +} diff --git a/Tests/Functional/Import/DestinationDataTest/Fixtures/ResponseWithSortedImagesForSingleEvent.json b/Tests/Functional/Import/DestinationDataTest/Fixtures/ResponseWithSortedImagesForSingleEvent.json new file mode 100644 index 0000000..5b3fd76 --- /dev/null +++ b/Tests/Functional/Import/DestinationDataTest/Fixtures/ResponseWithSortedImagesForSingleEvent.json @@ -0,0 +1,194 @@ +{ + "status": "OK", + "count": 3, + "overallcount": 50, + "channels": [], + "facetGroups": [], + "items": [ + { + "global_id": "e_100347853", + "id": "100347853", + "title": "Allerlei Weihnachtliches (Heute mit Johannes Geißer)", + "type": "Event", + "categories": [ + "Weihnachten" + ], + "texts": [ + { + "rel": "details", + "type": "text/html", + "value": "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. 
" + }, + { + "rel": "details", + "type": "text/plain", + "value": "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.\nEintritt: 10 € (inkl. Gedeck mit weihnachtlicher Schillerlocke)\nUm Voranmeldung unter 03672-486470 oder schillerhaus@rudolstadt.de wird gebeten.\nEs gilt die 2G-PLUS-Regel." + }, + { + "rel": "teaser", + "type": "text/html" + }, + { + "rel": "teaser", + "type": "text/plain" + } + ], + "country": "Deutschland", + "areas": [ + "Rudolstadt und Umgebung" + ], + "city": "Rudolstadt", + "zip": "07407", + "street": "Schillerstraße 25", + "phone": "+ 49 3672 / 486470", + "fax": "+ 49 3672 / 486475", + "web": "http://www.schillerhaus.rudolstadt.de/", + "email": "schillerhaus@rudolstadt.de", + "author": "support@hubermedia.de", + "geo": { + "main": { + "latitude": 50.720971023258805, + "longitude": 11.335229873657227 + }, + "entry": [], + "attributes": [] + }, + "ratings": [ + { + "type": "eT4", + "value": 40.0 + }, + { + "type": "order", + "value": 99.0001 + } + ], + "cuisine_types": [], + "payment": [], + "media_objects": [ + { + "rel": "venuewebsite", + "url": "http://schillerhaus.rudolstadt.de/", + "latitude": null, + "longitude": null, + "value": "" + }, + { + "rel": "default", + "url": "https://dam.destination.one/828118/f13bbf5602ffc406ebae2faa3527654dea84194666bce4925a1ca8bd3f50c5e9/tueftlerzeit-sfz-rudolstadt-jpg.jpg", + "type": "image/jpeg", + "latitude": null, + "longitude": null, + "description": "Description of Tueftlerzeit", + "width": 1920, + "height": 1080, + "value": "Tueftlerzeit©SFZ-Rudolstadt.jpg" + }, + { + "rel": "default", + "url": "https://dam.destination.one/849917/279ac45b3fc701a7197131f627164fffd9f8cc77bc75165e2fc2b864ed606920/theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg", + "type": "image/jpeg", + "latitude": null, + "longitude": null, + "width": 1920, + "height": 1080, + "value": "Theater-Rudolstadt_Johannes-Geißer_photo-by-Lisa-Stern_web_.jpg" + } + ], + "keywords": [], + "timeIntervals": [ + { + "weekdays": [], + "start": "2022-12-19T15:00:00+01:00", + "end": "2022-12-19T16:30:00+01:00", + "tz": "Europe/Berlin", + "interval": 1 + } + ], + "kitchenTimeIntervals": [], + "deliveryTimeIntervals": [], + "numbers": [], + "name": "Schillerhaus Rudolstadt", + "attributes": [ + { + "key": "VO_Id", + "value": "100050775" + }, + { + "key": "VO_CategoryName", + "value": "POI" + }, + { + "key": "VA_Id", + "value": "100050775" + }, + { + "key": "VA_CategoryName", + "value": "POI" + }, + { + "key": "interval_first_match_start", + "value": "2022-12-19T15:00:00+01" + }, + { + "key": "interval_first_match_end", + "value": "2022-12-19T16:30:00+01" + }, + { + "key": "interval_match_count", + "value": "1" + } + ], + "features": [ + "vorhandenes Feature", + "Barrierefrei", + "Zielgruppe Jugendliche", + "Karten an der Abendkasse", + "Ausreichende Lüftung", + "Beachtung der Hygienehinweise" + ], + "addresses": [ + { + "name": "Städtetourismus in Thüringen e.V.", + "city": "Weimar", + "zip": "99423", + "street": "UNESCO-Platz 1", + "phone": "+49 (3643) 745 314", + "web": "http://www.thueringer-staedte.de", + "email": "verein@thueringer-staedte.de", + "rel": "author" + }, + { + "name": "Städtetourismus in Thüringen\" e.V.", + "web": "http://www.thueringer-staedte.de", + "email": "verein@thueringer-staedte.de", + "rel": "organisation" + }, + { + "name": "Schillerhaus Rudolstadt", + "city": "Rudolstadt", + "zip": "07407", + "street": "Schillerstraße 25", + "phone": "+ 49 3672 / 486470", + "fax": "+ 49 3672 / 486475", + "web": "http://schillerhaus.rudolstadt.de", + "email": "schillerhaus@rudolstadt.de", + "rel": "organizer" + } + ], + "created": "2022-10-31T12:29:00+00:00", + "changed": "2022-12-14T08:29:00+00:00", + "source": { + "url": "http://destination.one/", + "value": "destination.one" + }, + "company": "", + "district": "", + "postoffice": "", + "phone2": "", + "seasons": [], + "subitems": [], + "hyperObjects": [] + } + ] +} diff --git a/Tests/Functional/Import/DestinationDataTest/ImportHandlesImagesTest.php b/Tests/Functional/Import/DestinationDataTest/ImportHandlesImagesTest.php new file mode 100644 index 0000000..6d3e95d --- /dev/null +++ b/Tests/Functional/Import/DestinationDataTest/ImportHandlesImagesTest.php @@ -0,0 +1,265 @@ +configurationToUseInTestInstance['SYS']['FileInfo']['fileExtensionToMimeType']['jpg'] = 'image/jpg'; + + parent::setUp(); + + $fileImportPathConfiguration = 'staedte/beispielstadt/events/'; + $this->fileImportPath = $this->getInstancePath() . '/fileadmin/' . $fileImportPathConfiguration; + GeneralUtility::mkdir_deep($this->fileImportPath); + + $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/DefaultImportConfiguration.php'); + + $this->setUpConfiguration([ + 'restUrl = https://example.com/some-path/', + 'license = example-license', + 'restType = Event', + 'restLimit = 3', + 'restMode = next_months,12', + 'restTemplate = ET2014A.json', + ]); + } + + protected function tearDown(): void + { + parent::tearDown(); + + GeneralUtility::rmdir($this->fileImportPath, true); + } + + /** + * @test + */ + public function addsNewImages(): void + { + $this->setUpResponses([ + new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ResponseWithNewImages.json') ?: ''), + 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') ?: ''), + ]); + + $this->executeCommand(); + + $this->assertPHPDataSet(__DIR__ . '/Assertions/ImportHandlesImagesAddsNewImages.php'); + + $importedFiles = GeneralUtility::getFilesInDir($this->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.' + ); + } + + /** + * @test + */ + public function addsMultipleImagesToSingleEvent(): void + { + $this->setUpResponses([ + new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ResponseWithMultipleImagesForSingleEvent.json') ?: ''), + new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ExampleImage.jpg') ?: ''), + new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ExampleImage.jpg') ?: ''), + ]); + + $this->executeCommand(); + + $this->assertPHPDataSet(__DIR__ . '/Assertions/ImportHandlesImagesAddsMultipleImagestoSingleEvent.php'); + + $importedFiles = GeneralUtility::getFilesInDir($this->fileImportPath); + self::assertIsArray($importedFiles, 'Failed to retrieve imported files from filesystem.'); + self::assertSame( + [ + '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.' + ); + } + + /** + * @test + */ + public function removesNoLongerExistingImages(): void + { + $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/ImportHandlesImagesExistingData.php'); + copy(__DIR__ . '/Fixtures/ExampleImage.jpg', $this->fileImportPath . '/theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg'); + copy(__DIR__ . '/Fixtures/ExampleImage.jpg', $this->fileImportPath . '/tueftlerzeit-sfz-rudolstadt-jpg.jpg'); + + $this->setUpResponses([ + new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ResponseWithSingleImageForSingleEvent.json') ?: ''), + new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ExampleImage.jpg') ?: ''), + ]); + + $this->executeCommand(); + + $this->assertPHPDataSet(__DIR__ . '/Assertions/ImportHandlesImagesRemovesNoLongerExistingImages.php'); + + $importedFiles = GeneralUtility::getFilesInDir($this->fileImportPath); + self::assertIsArray($importedFiles, 'Failed to retrieve imported files from filesystem.'); + self::assertSame( + [ + '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.' + ); + } + + /** + * @test + */ + public function updatesExistingImage(): void + { + $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/ImportHandlesImagesExistingData.php'); + copy(__DIR__ . '/Fixtures/ExampleImage.jpg', $this->fileImportPath . '/theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg'); + copy(__DIR__ . '/Fixtures/ExampleImage.jpg', $this->fileImportPath . '/tueftlerzeit-sfz-rudolstadt-jpg.jpg'); + + $this->setUpResponses([ + new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ResponseWithMultipleImagesForSingleEvent.json') ?: ''), + new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ExampleImage.jpg') ?: ''), + new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ExampleImage.jpg') ?: ''), + ]); + + $this->executeCommand(); + + $this->assertPHPDataSet(__DIR__ . '/Assertions/ImportHandlesImagesUpdatesExistingImage.php'); + + $importedFiles = GeneralUtility::getFilesInDir($this->fileImportPath); + self::assertIsArray($importedFiles, 'Failed to retrieve imported files from filesystem.'); + self::assertSame( + [ + '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.' + ); + } + + /** + * @test + */ + public function addsNewImageToExistingImages(): void + { + $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/ImportHandlesImagesExistingData.php'); + copy(__DIR__ . '/Fixtures/ExampleImage.jpg', $this->fileImportPath . '/theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg'); + copy(__DIR__ . '/Fixtures/ExampleImage.jpg', $this->fileImportPath . '/tueftlerzeit-sfz-rudolstadt-jpg.jpg'); + + $this->setUpResponses([ + new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ResponseWithOneMoreImageForSingleEvent.json') ?: ''), + 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') ?: ''), + ]); + + $this->executeCommand(); + + $this->assertPHPDataSet(__DIR__ . '/Assertions/ImportHandlesImagesAddsNewImageToExistingImages.php'); + + $importedFiles = GeneralUtility::getFilesInDir($this->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.' + ); + } + + /** + * @test + */ + public function updatesSortingOfImages(): void + { + $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/ImportHandlesImagesExistingData.php'); + copy(__DIR__ . '/Fixtures/ExampleImage.jpg', $this->fileImportPath . '/theater-rudolstadt_johannes-gei-er_photo-by-lisa-stern_web_-jpg.jpg'); + copy(__DIR__ . '/Fixtures/ExampleImage.jpg', $this->fileImportPath . '/tueftlerzeit-sfz-rudolstadt-jpg.jpg'); + + $this->setUpResponses([ + new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ResponseWithSortedImagesForSingleEvent.json') ?: ''), + new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ExampleImage.jpg') ?: ''), + new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/ExampleImage.jpg') ?: ''), + ]); + + $this->executeCommand(); + + $this->assertPHPDataSet(__DIR__ . '/Assertions/ImportHandlesImagesUpdatesSortingOfImages.php'); + + $importedFiles = GeneralUtility::getFilesInDir($this->fileImportPath); + self::assertIsArray($importedFiles, 'Failed to retrieve imported files from filesystem.'); + self::assertSame( + [ + '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/phpstan-baseline.neon b/phpstan-baseline.neon index 96871b5..f17ea91 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -45,11 +45,6 @@ parameters: count: 1 path: Classes/Service/Cleanup/Files.php - - - message: "#^Parameter \\#3 \\$uid_foreign of method Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\:\\:createFileRelations\\(\\) expects int, int\\|null given\\.$#" - count: 1 - path: Classes/Service/DestinationDataImportService.php - - message: "#^Method Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\\\CategoriesAssignment\\:\\:getCategories\\(\\) should return TYPO3\\\\CMS\\\\Extbase\\\\Persistence\\\\ObjectStorage\\ but returns TYPO3\\\\CMS\\\\Extbase\\\\Persistence\\\\ObjectStorage\\\\.$#" count: 2 @@ -65,6 +60,11 @@ parameters: count: 1 path: Classes/Updates/MigrateOldLocations.php + - + message: "#^Method Wrm\\\\Events\\\\Service\\\\DestinationDataImportService\\\\FilesAssignment\\:\\:getImages\\(\\) should return TYPO3\\\\CMS\\\\Extbase\\\\Persistence\\\\ObjectStorage\\ but returns TYPO3\\\\CMS\\\\Extbase\\\\Persistence\\\\ObjectStorage\\\\.$#" + count: 1 + path: Classes/Service/DestinationDataImportService/FilesAssignment.php + - message: "#^Argument of an invalid type Doctrine\\\\DBAL\\\\Result\\|int supplied for foreach, only iterables are supported\\.$#" count: 1