From 63f05bf011c1a8a506a3033ce3c9809daa7267b6 Mon Sep 17 00:00:00 2001 From: Daniel Siepmann Date: Thu, 10 Aug 2023 10:17:12 +0200 Subject: [PATCH] Add PSR-14 Event to modify event objects prior persistence A new PSR-14 event is added that allows to modify the event right before it is persisted within Destination Data One import. This for example allows to alter dates, prices, etc. Improve handling of missing end time in dates. --- Classes/Domain/Model/Date.php | 14 +-- .../Service/DestinationDataImportService.php | 18 +++- .../Events/EventImportEvent.php | 57 +++++++++++ Classes/Updates/MigrateDuplicateLocations.php | 2 +- Documentation/Changelog/3.5.0.rst | 38 ++++++++ Documentation/Features/PSR14Events.rst | 13 +++ .../ReturnsDateWithinTimeSpan.csv | 6 +- .../DestinationDataTest/AbstractTest.php | 4 +- .../RegisteredEventHandlerCanModifyEvent.php | 29 ++++++ .../EventImportEventTest.php | 59 ++++++++++++ .../RegisteredEventHandlerCanModifyEvent.php | 15 +++ .../EventListener/EventImportListener.php | 43 +++++++++ .../custom_event/Configuration/Services.php | 23 +++++ .../Extensions/custom_event/composer.json | 19 ++++ .../Extensions/custom_event/ext_emconf.php | 20 ++++ .../RegisteredEventHandlerCanModifyEvent.json | 94 +++++++++++++++++++ Tests/Unit/Domain/Model/DateTest.php | 50 +++++++++- composer.json | 3 +- ext_emconf.php | 2 +- 19 files changed, 491 insertions(+), 18 deletions(-) create mode 100644 Classes/Service/DestinationDataImportService/Events/EventImportEvent.php create mode 100644 Documentation/Changelog/3.5.0.rst create mode 100644 Documentation/Features/PSR14Events.rst create mode 100644 Tests/Functional/Psr14Events/DestinationDataImport/Assertions/RegisteredEventHandlerCanModifyEvent.php create mode 100644 Tests/Functional/Psr14Events/DestinationDataImport/EventImportEventTest.php create mode 100644 Tests/Functional/Psr14Events/DestinationDataImport/Fixtures/Database/RegisteredEventHandlerCanModifyEvent.php create mode 100644 Tests/Functional/Psr14Events/DestinationDataImport/Fixtures/Extensions/custom_event/Classes/EventListener/EventImportListener.php create mode 100644 Tests/Functional/Psr14Events/DestinationDataImport/Fixtures/Extensions/custom_event/Configuration/Services.php create mode 100644 Tests/Functional/Psr14Events/DestinationDataImport/Fixtures/Extensions/custom_event/composer.json create mode 100644 Tests/Functional/Psr14Events/DestinationDataImport/Fixtures/Extensions/custom_event/ext_emconf.php create mode 100644 Tests/Functional/Psr14Events/DestinationDataImport/Fixtures/Responses/RegisteredEventHandlerCanModifyEvent.json diff --git a/Classes/Domain/Model/Date.php b/Classes/Domain/Model/Date.php index b673a8f..b02e88a 100644 --- a/Classes/Domain/Model/Date.php +++ b/Classes/Domain/Model/Date.php @@ -15,7 +15,7 @@ class Date extends AbstractEntity protected $start; /** - * @var \DateTime + * @var \DateTime|null */ protected $end; @@ -73,7 +73,7 @@ public function getHasUsefulStartTime(): bool } /** - * @return \DateTime end + * @return \DateTime|null end */ public function getEnd() { @@ -81,23 +81,25 @@ public function getEnd() } /** - * @param \DateTime $end + * @param \DateTime|null $end * * @return void */ - public function setEnd(\DateTime $end) + public function setEnd($end) { $this->end = $end; } public function getHasUsefulEndTime(): bool { - return $this->getEnd()->format('H:i') !== '23:59'; + $end = $this->getEnd(); + return $end && $end->format('H:i') !== '23:59'; } public function getEndsOnSameDay(): bool { - return $this->getStart()->format('Y-m-d') === $this->getEnd()->format('Y-m-d'); + $end = $this->getEnd(); + return $end && $this->getStart()->format('Y-m-d') === $end->format('Y-m-d'); } /** diff --git a/Classes/Service/DestinationDataImportService.php b/Classes/Service/DestinationDataImportService.php index d581946..63b7baf 100644 --- a/Classes/Service/DestinationDataImportService.php +++ b/Classes/Service/DestinationDataImportService.php @@ -3,6 +3,7 @@ namespace Wrm\Events\Service; use Exception; +use TYPO3\CMS\Core\EventDispatcher\EventDispatcher; use TYPO3\CMS\Core\Log\Logger; use TYPO3\CMS\Core\Log\LogManager; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -22,6 +23,7 @@ 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\Events\EventImportEvent; use Wrm\Events\Service\DestinationDataImportService\FilesAssignment; use Wrm\Events\Service\DestinationDataImportService\LocationAssignment; use Wrm\Events\Service\DestinationDataImportService\Slugger; @@ -108,6 +110,11 @@ class DestinationDataImportService */ private $cacheManager; + /** + * @var EventDispatcher + */ + private $eventDispatcher; + /** * ImportService constructor. * @@ -123,6 +130,7 @@ class DestinationDataImportService * @param LocationAssignment $locationAssignment * @param Slugger $slugger * @param CacheManager $cacheManager + * @param EventDispatcher $eventDispatcher */ public function __construct( EventRepository $eventRepository, @@ -137,7 +145,8 @@ public function __construct( CategoriesAssignment $categoriesAssignment, LocationAssignment $locationAssignment, Slugger $slugger, - CacheManager $cacheManager + CacheManager $cacheManager, + EventDispatcher $eventDispatcher ) { $this->eventRepository = $eventRepository; $this->organizerRepository = $organizerRepository; @@ -152,6 +161,7 @@ public function __construct( $this->locationAssignment = $locationAssignment; $this->slugger = $slugger; $this->cacheManager = $cacheManager; + $this->eventDispatcher = $eventDispatcher; } public function import( @@ -198,6 +208,7 @@ public function processData(array $data): int // Event already exists? If not create one! $this->tmpCurrentEvent = $this->getOrCreateEvent($event['global_id'], $event['title']); + $existingEvent = clone $this->tmpCurrentEvent; // Set language UID $this->tmpCurrentEvent->setLanguageUid(-1); @@ -266,6 +277,11 @@ public function processData(array $data): int $this->setAssets($event['media_objects']); } + $this->eventDispatcher->dispatch(new EventImportEvent( + $existingEvent, + $this->tmpCurrentEvent + )); + // Update and persist $this->logger->info('Persist database'); $this->eventRepository->update($this->tmpCurrentEvent); diff --git a/Classes/Service/DestinationDataImportService/Events/EventImportEvent.php b/Classes/Service/DestinationDataImportService/Events/EventImportEvent.php new file mode 100644 index 0000000..1f1fb4e --- /dev/null +++ b/Classes/Service/DestinationDataImportService/Events/EventImportEvent.php @@ -0,0 +1,57 @@ + + * + * 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\Events; + +use Wrm\Events\Domain\Model\Event; + +final class EventImportEvent +{ + /** + * @var Event + */ + private $existingEvent; + + /** + * @var Event + */ + private $eventToImport; + + public function __construct( + Event $existingEvent, + Event $eventToImport + ) { + $this->existingEvent = $existingEvent; + $this->eventToImport = $eventToImport; + } + + public function getBaseEvent(): Event + { + return clone $this->existingEvent; + } + + public function getEventToImport(): Event + { + return $this->eventToImport; + } +} diff --git a/Classes/Updates/MigrateDuplicateLocations.php b/Classes/Updates/MigrateDuplicateLocations.php index 9ef6a69..5814887 100644 --- a/Classes/Updates/MigrateDuplicateLocations.php +++ b/Classes/Updates/MigrateDuplicateLocations.php @@ -148,7 +148,7 @@ private function getMatchingLocation( return 0; } - return (int) $uid; + return (int)$uid; } private function buildObject(array $location): Location diff --git a/Documentation/Changelog/3.5.0.rst b/Documentation/Changelog/3.5.0.rst new file mode 100644 index 0000000..0244010 --- /dev/null +++ b/Documentation/Changelog/3.5.0.rst @@ -0,0 +1,38 @@ +3.5.0 +===== + +Breaking +-------- + +Nothing + +Features +-------- + +* Add PSR-14 Events to Destination Data One import. + They allow individual installation to alter the import. + + See :ref:`psr14` for an overview of PSR-14 Events. + + Added Events: + + * Allow to modify an event object before importing. + +Fixes +----- + +* Improve handling of dates with no end. + This was always technically possible. Still support from extension was missing. + This now got improved, the date object will not throw exceptions due to ``format()`` calls on none. + Furthermore the PHPDoc now reflects that there might be null instead of ``\DateTime``. + Also the setter was adjusted to allow ``null`` values. + +Tasks +----- + +Nothing + +Deprecation +----------- + +Nothing diff --git a/Documentation/Features/PSR14Events.rst b/Documentation/Features/PSR14Events.rst new file mode 100644 index 0000000..99073fb --- /dev/null +++ b/Documentation/Features/PSR14Events.rst @@ -0,0 +1,13 @@ +.. index:: single: PSR-14 Events +.. _psr14: + +PSR-14 Events +============= + +.. index:: single: PSR-14 Events; Destination Data One Import: Event Import + +Destination Data One Import: ``EventImportEvent`` +------------------------------------------------- + +Executed during Destination Data One Import. +Allows to alter the event prior persistence. diff --git a/Tests/Functional/Frontend/DatesTestFixtures/ReturnsDateWithinTimeSpan.csv b/Tests/Functional/Frontend/DatesTestFixtures/ReturnsDateWithinTimeSpan.csv index d490d7e..0aeabce 100644 --- a/Tests/Functional/Frontend/DatesTestFixtures/ReturnsDateWithinTimeSpan.csv +++ b/Tests/Functional/Frontend/DatesTestFixtures/ReturnsDateWithinTimeSpan.csv @@ -15,11 +15,11 @@ tx_events_domain_model_event tx_events_domain_model_date ,uid,pid,event,start,end ,1,2,1,1676419200,1676484000 -,2,2,2,1676419200,0 +,2,2,2,1676419200,"\NULL" ,3,2,3,1676678400,1676743200 -,4,2,4,1676678400,0 +,4,2,4,1676678400,"\NULL" ,5,2,5,1676419200,1676678400 ,6,2,6,1676559600,1676570400 ,7,2,7,1676559600,1676678400 -,8,2,8,1676559600,0 +,8,2,8,1676559600,"\NULL" ,9,2,9,1676419200,1676570400 diff --git a/Tests/Functional/Import/DestinationDataTest/AbstractTest.php b/Tests/Functional/Import/DestinationDataTest/AbstractTest.php index 43e804c..e4159f4 100644 --- a/Tests/Functional/Import/DestinationDataTest/AbstractTest.php +++ b/Tests/Functional/Import/DestinationDataTest/AbstractTest.php @@ -8,9 +8,7 @@ abstract class AbstractTest extends AbstractFunctionalTestCase { protected function setUp(): void { - $this->coreExtensionsToLoad = [ - 'filemetadata', - ]; + $this->coreExtensionsToLoad[] = 'filemetadata'; parent::setUp(); diff --git a/Tests/Functional/Psr14Events/DestinationDataImport/Assertions/RegisteredEventHandlerCanModifyEvent.php b/Tests/Functional/Psr14Events/DestinationDataImport/Assertions/RegisteredEventHandlerCanModifyEvent.php new file mode 100644 index 0000000..eb9a91c --- /dev/null +++ b/Tests/Functional/Psr14Events/DestinationDataImport/Assertions/RegisteredEventHandlerCanModifyEvent.php @@ -0,0 +1,29 @@ + [ + [ + 'uid' => 1, + 'pid' => 2, + 'title' => 'Event for modifying event', + 'global_id' => 'e_100350503', + 'dates' => 2, + ], + ], + 'tx_events_domain_model_date' => [ + [ + 'uid' => 1, + 'pid' => 2, + 'event' => 1, + 'start' => 4097728800, + 'end' => null, + ], + [ + 'uid' => 2, + 'pid' => 2, + 'event' => 1, + 'start' => 4097815200, + 'end' => null, + ], + ], +]; diff --git a/Tests/Functional/Psr14Events/DestinationDataImport/EventImportEventTest.php b/Tests/Functional/Psr14Events/DestinationDataImport/EventImportEventTest.php new file mode 100644 index 0000000..d9a9a8b --- /dev/null +++ b/Tests/Functional/Psr14Events/DestinationDataImport/EventImportEventTest.php @@ -0,0 +1,59 @@ + + * + * 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\Tests\Functional\Psr14Events\DestinationDataImport; + +use GuzzleHttp\Psr7\Response; +use Wrm\Events\Tests\Functional\Import\DestinationDataTest\AbstractTest; + +final class EventImportEventTest extends AbstractTest +{ + protected function setUp(): void + { + $this->testExtensionsToLoad[] = 'typo3conf/ext/events/Tests/Functional/Psr14Events/DestinationDataImport/Fixtures/Extensions/custom_event'; + + parent::setUp(); + + $this->setUpConfiguration([ + 'restUrl = https://example.com/some-path/', + 'license = example-license', + 'restType = Event', + 'restLimit = 3', + 'restMode = next_months,12', + 'restTemplate = ET2014A.json', + ]); + } + + /** + * @test + */ + public function registeredEventHandlerCanModifyEvent(): void + { + $this->importPHPDataSet(__DIR__ . '/Fixtures/Database/RegisteredEventHandlerCanModifyEvent.php'); + $this->setUpResponses([new Response(200, [], file_get_contents(__DIR__ . '/Fixtures/Responses/RegisteredEventHandlerCanModifyEvent.json') ?: '')]); + + $this->executeCommand(); + + $this->assertPHPDataSet(__DIR__ . '/Assertions/RegisteredEventHandlerCanModifyEvent.php'); + } +} diff --git a/Tests/Functional/Psr14Events/DestinationDataImport/Fixtures/Database/RegisteredEventHandlerCanModifyEvent.php b/Tests/Functional/Psr14Events/DestinationDataImport/Fixtures/Database/RegisteredEventHandlerCanModifyEvent.php new file mode 100644 index 0000000..48f7be0 --- /dev/null +++ b/Tests/Functional/Psr14Events/DestinationDataImport/Fixtures/Database/RegisteredEventHandlerCanModifyEvent.php @@ -0,0 +1,15 @@ + [ + [ + 'uid' => '1', + 'pid' => '2', + 'title' => 'Example import configuration', + 'storage_pid' => 2, + 'files_folder' => '1:/staedte/beispielstadt/events/', + 'region' => '1', + 'rest_experience' => 'beispielstadt', + ], + ], +]; diff --git a/Tests/Functional/Psr14Events/DestinationDataImport/Fixtures/Extensions/custom_event/Classes/EventListener/EventImportListener.php b/Tests/Functional/Psr14Events/DestinationDataImport/Fixtures/Extensions/custom_event/Classes/EventListener/EventImportListener.php new file mode 100644 index 0000000..453fb80 --- /dev/null +++ b/Tests/Functional/Psr14Events/DestinationDataImport/Fixtures/Extensions/custom_event/Classes/EventListener/EventImportListener.php @@ -0,0 +1,43 @@ + + * + * 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 WerkraumMedia\CustomEvent\EventListener; + +use Wrm\Events\Service\DestinationDataImportService\Events\EventImportEvent; + +final class EventImportListener +{ + public function __invoke(EventImportEvent $psr14Event): void + { + $eventToImport = $psr14Event->getEventToImport(); + $dates = $psr14Event->getEventToImport()->getDates(); + foreach ($dates as $date) { + $endToSkip = clone $date->getStart(); + $endToSkip->modify('+15 minutes'); + if ($date->getEnd() == $endToSkip) { + $date->setEnd(null); + } + } + $eventToImport->setDates($dates); + } +} diff --git a/Tests/Functional/Psr14Events/DestinationDataImport/Fixtures/Extensions/custom_event/Configuration/Services.php b/Tests/Functional/Psr14Events/DestinationDataImport/Fixtures/Extensions/custom_event/Configuration/Services.php new file mode 100644 index 0000000..fba8f94 --- /dev/null +++ b/Tests/Functional/Psr14Events/DestinationDataImport/Fixtures/Extensions/custom_event/Configuration/Services.php @@ -0,0 +1,23 @@ +services() + ->defaults() + ->autowire() + ->autoconfigure() + ; + + $services->load('WerkraumMedia\\CustomEvent\\', '../Classes/*'); + $services->set(EventImportListener::class) + ->tag('event.listener', [ + 'event' => EventImportEvent::class, + ]) + ; +}; diff --git a/Tests/Functional/Psr14Events/DestinationDataImport/Fixtures/Extensions/custom_event/composer.json b/Tests/Functional/Psr14Events/DestinationDataImport/Fixtures/Extensions/custom_event/composer.json new file mode 100644 index 0000000..1a0eac1 --- /dev/null +++ b/Tests/Functional/Psr14Events/DestinationDataImport/Fixtures/Extensions/custom_event/composer.json @@ -0,0 +1,19 @@ +{ + "name": "werkraummedia/custom_event", + "description": "Integrates custom event specifics", + "type": "typo3-cms-extension", + "license": "GPL-2.0-or-later", + "require": { + "werkraummedia/events": "*" + }, + "autoload": { + "psr-4": { + "WerkraumMedia\\CustomEvent\\": "Classes/" + } + }, + "extra": { + "typo3/cms": { + "extension-key": "custom_event" + } + } +} diff --git a/Tests/Functional/Psr14Events/DestinationDataImport/Fixtures/Extensions/custom_event/ext_emconf.php b/Tests/Functional/Psr14Events/DestinationDataImport/Fixtures/Extensions/custom_event/ext_emconf.php new file mode 100644 index 0000000..a7b43b2 --- /dev/null +++ b/Tests/Functional/Psr14Events/DestinationDataImport/Fixtures/Extensions/custom_event/ext_emconf.php @@ -0,0 +1,20 @@ + 'Custom Events', + 'description' => 'Integrates custom event specifics', + 'category' => 'plugin', + 'author' => 'Daniel Siepmann', + 'author_email' => 'coding@daniel-siepmann.de', + 'state' => 'alpha', + 'createDirs' => '', + 'clearCacheOnLoad' => 0, + 'version' => '1.0.0', + 'constraints' => [ + 'depends' => [ + 'event' => '', + ], + 'conflicts' => [], + 'suggests' => [], + ], +]; diff --git a/Tests/Functional/Psr14Events/DestinationDataImport/Fixtures/Responses/RegisteredEventHandlerCanModifyEvent.json b/Tests/Functional/Psr14Events/DestinationDataImport/Fixtures/Responses/RegisteredEventHandlerCanModifyEvent.json new file mode 100644 index 0000000..c2ffb8c --- /dev/null +++ b/Tests/Functional/Psr14Events/DestinationDataImport/Fixtures/Responses/RegisteredEventHandlerCanModifyEvent.json @@ -0,0 +1,94 @@ +{ + "status": "OK", + "count": 1, + "overallcount": 1, + "channels": [], + "facetGroups": [], + "items": [ + { + "global_id": "e_100350503", + "id": "100350503", + "title": "Event for modifying event", + "type": "Event", + "categories": [ + ], + "features": [ + ], + "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" + } + ], + "city": "Rudolstadt", + "zip": "07407", + "street": "Caspar-Schulte-Straße", + "phone": "03672 - 48 96 13", + "author": "support@hubermedia.de", + "media_objects": [ + ], + "keywords": [], + "timeIntervals": [ + { + "weekdays": [ + "Saturday", + "Sunday" + ], + "start": "2099-11-02T11:00:00+01:00", + "end": "2099-11-02T11:15:00+01:00", + "repeatUntil": "2099-11-10T11:15:00+01:00", + "tz": "Europe/Berlin", + "freq": "Weekly", + "interval": 1 + } + ], + "name": "Lutherkirche", + "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": "2099-11-08T22:15:00+00:00", + "changed": "2099-12-14T08:38:00+00:00", + "source": { + "url": "http://destination.one/", + "value": "destination.one" + } + } + ] +} diff --git a/Tests/Unit/Domain/Model/DateTest.php b/Tests/Unit/Domain/Model/DateTest.php index 9688666..2ee022d 100644 --- a/Tests/Unit/Domain/Model/DateTest.php +++ b/Tests/Unit/Domain/Model/DateTest.php @@ -59,7 +59,7 @@ public function returnsThatItHasUsefulEndTime(): void /** * @test */ - public function returnsThatItDoesNotHaveUsefulEndTime(): void + public function returnsThatItDoesNotHaveUsefulEndTimeWithTime(): void { $subject = new Date(); $subject->setEnd(new \DateTime('2022-07-11T23:59:00')); @@ -67,6 +67,17 @@ public function returnsThatItDoesNotHaveUsefulEndTime(): void self::assertFalse($subject->getHasUsefulEndTime()); } + /** + * @test + */ + public function returnsThatItDoesNotHaveUsefulEndTimeWithNull(): void + { + $subject = new Date(); + $subject->setEnd(null); + + self::assertFalse($subject->getHasUsefulEndTime()); + } + /** * @test */ @@ -82,7 +93,7 @@ public function returnsThatItEndsOnSameDay(): void /** * @test */ - public function returnsThatItDoesNotEndOnSameDay(): void + public function returnsThatItDoesNotEndOnSameDayWithDifferentDates(): void { $subject = new Date(); $subject->setStart(new \DateTime('2022-07-11T14:00:00')); @@ -90,4 +101,39 @@ public function returnsThatItDoesNotEndOnSameDay(): void self::assertFalse($subject->getEndsOnSameDay()); } + + /** + * @test + */ + public function returnsThatItDoesNotEndOnSameDayWithMissingEnd(): void + { + $subject = new Date(); + $subject->setStart(new \DateTime('2022-07-11T14:00:00')); + $subject->setEnd(null); + + self::assertFalse($subject->getEndsOnSameDay()); + } + + /** + * @test + */ + public function returnsNullAsEnd(): void + { + $subject = new Date(); + $subject->setEnd(null); + + self::assertNull($subject->getEnd()); + } + + /** + * @test + */ + public function returnsEnd(): void + { + $end = new \DateTime('2022-07-13T22:00:00'); + $subject = new Date(); + $subject->setEnd($end); + + self::assertSame($end, $subject->getEnd()); + } } diff --git a/composer.json b/composer.json index 56f91fd..0843857 100644 --- a/composer.json +++ b/composer.json @@ -30,7 +30,8 @@ }, "autoload-dev": { "psr-4": { - "Wrm\\Events\\Tests\\": "Tests" + "Wrm\\Events\\Tests\\": "Tests", + "WerkraumMedia\\CustomEvent\\": "Tests/Functional/Psr14Events/DestinationDataImport/Fixtures/Extensions/custom_event/Classes/" } }, "scripts": { diff --git a/ext_emconf.php b/ext_emconf.php index e213833..f78498d 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -9,7 +9,7 @@ 'state' => 'alpha', 'createDirs' => '', 'clearCacheOnLoad' => 0, - 'version' => '3.4.0', + 'version' => '3.5.0', 'constraints' => [ 'depends' => [ 'typo3' => '10.4.00-11.5.99',