diff options
author | Christoph Wurst <ChristophWurst@users.noreply.github.com> | 2021-05-07 16:47:44 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-07 16:47:44 +0200 |
commit | f8c519f5f0b52075c5b343233a5e48f9bc8cf3aa (patch) | |
tree | 6e780de6cf25cd57642e2929198f7bb7078a7839 /apps/dav/tests | |
parent | ed2d6eee1e45a54167d628eb31fc12b0d019c0d5 (diff) | |
parent | f5462650f1480bf23a58285e0e4476957a0720db (diff) | |
download | nextcloud-server-f8c519f5f0b52075c5b343233a5e48f9bc8cf3aa.tar.gz nextcloud-server-f8c519f5f0b52075c5b343233a5e48f9bc8cf3aa.zip |
Merge pull request #26913 from nextcloud/chore/dav-calendar-object-untyped-events
Drop some more untyped events from the dav code
Diffstat (limited to 'apps/dav/tests')
-rw-r--r-- | apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php | 9 | ||||
-rw-r--r-- | apps/dav/tests/unit/CalDAV/CalDavBackendTest.php | 82 | ||||
-rw-r--r-- | apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php | 18 |
3 files changed, 64 insertions, 45 deletions
diff --git a/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php b/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php index b512847a7e8..17ac839b5f2 100644 --- a/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php +++ b/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php @@ -32,6 +32,7 @@ use OCA\DAV\CalDAV\CalDavBackend; use OCA\DAV\CalDAV\Proxy\ProxyMapper; use OCA\DAV\Connector\Sabre\Principal; use OCA\DAV\Events\CalendarDeletedEvent; +use OCA\DAV\Events\CalendarObjectCreatedEvent; use OCP\App\IAppManager; use OCP\EventDispatcher\IEventDispatcher; use OCP\IConfig; @@ -206,9 +207,11 @@ END:VCALENDAR EOD; $uri0 = $this->getUniqueID('event'); - $this->legacyDispatcher->expects($this->at(0)) - ->method('dispatch') - ->with('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject'); + $this->dispatcher->expects(self::once()) + ->method('dispatchTyped') + ->with(self::callback(function ($event) { + return $event instanceof CalendarObjectCreatedEvent; + })); $this->backend->createCalendarObject($calendarId, $uri0, $calData); diff --git a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php index 25966aa5c95..097fbd79fe3 100644 --- a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php +++ b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php @@ -37,6 +37,8 @@ use DateTimeZone; use OCA\DAV\CalDAV\CalDavBackend; use OCA\DAV\CalDAV\Calendar; use OCA\DAV\Events\CalendarDeletedEvent; +use OCA\DAV\Events\CalendarObjectCreatedEvent; +use OCA\DAV\Events\CalendarUpdatedEvent; use OCP\IConfig; use OCP\IL10N; use Sabre\DAV\Exception\NotFound; @@ -186,9 +188,11 @@ END:VEVENT END:VCALENDAR EOD; - $this->legacyDispatcher->expects($this->at(0)) - ->method('dispatch') - ->with('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject'); + $this->dispatcher->expects(self::once()) + ->method('dispatchTyped') + ->with(self::callback(function ($event) { + return $event instanceof CalendarObjectCreatedEvent; + })); $this->backend->createCalendarObject($calendarId, $uri, $calData); /** @var IACL $child */ @@ -232,9 +236,11 @@ END:VEVENT END:VCALENDAR EOD; - $this->legacyDispatcher->expects($this->at(0)) - ->method('dispatch') - ->with('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject'); + $this->dispatcher->expects(self::once()) + ->method('dispatchTyped') + ->with(self::callback(function ($event) { + return $event instanceof CalendarObjectCreatedEvent; + })); $this->backend->createCalendarObject($calendarId, $uri, $calData); // get all the cards @@ -270,17 +276,21 @@ DTEND;VALUE=DATE-TIME:20130912T140000Z END:VEVENT END:VCALENDAR EOD; - $this->legacyDispatcher->expects($this->at(0)) - ->method('dispatch') - ->with('\OCA\DAV\CalDAV\CalDavBackend::updateCalendarObject'); + $this->dispatcher->expects(self::once()) + ->method('dispatchTyped') + ->with(self::callback(function ($event) { + return $event instanceof CalendarUpdatedEvent; + })); $this->backend->updateCalendarObject($calendarId, $uri, $calData); $calendarObject = $this->backend->getCalendarObject($calendarId, $uri); $this->assertEquals($calData, $calendarObject['calendardata']); // delete the card - $this->legacyDispatcher->expects($this->at(0)) - ->method('dispatch') - ->with('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject'); + $this->dispatcher->expects(self::once()) + ->method('dispatchTyped') + ->with(self::callback(function ($event) { + return $event instanceof CalendarDeletedEvent; + })); $this->backend->deleteCalendarObject($calendarId, $uri); $calendarObjects = $this->backend->getCalendarObjects($calendarId); $this->assertCount(0, $calendarObjects); @@ -373,19 +383,25 @@ END:VCALENDAR EOD; $uri0 = static::getUniqueID('card'); - $this->legacyDispatcher->expects($this->at(0)) - ->method('dispatch') - ->with('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject'); + $this->dispatcher->expects(self::once()) + ->method('dispatchTyped') + ->with(self::callback(function ($event) { + return $event instanceof CalendarObjectCreatedEvent; + })); $this->backend->createCalendarObject($calendarId, $uri0, $calData[0]); $uri1 = static::getUniqueID('card'); - $this->legacyDispatcher->expects($this->at(0)) - ->method('dispatch') - ->with('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject'); + $this->dispatcher->expects(self::once()) + ->method('dispatchTyped') + ->with(self::callback(function ($event) { + return $event instanceof CalendarObjectCreatedEvent; + })); $this->backend->createCalendarObject($calendarId, $uri1, $calData[1]); $uri2 = static::getUniqueID('card'); - $this->legacyDispatcher->expects($this->at(0)) - ->method('dispatch') - ->with('\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject'); + $this->dispatcher->expects(self::once()) + ->method('dispatchTyped') + ->with(self::callback(function ($event) { + return $event instanceof CalendarObjectCreatedEvent; + })); $this->backend->createCalendarObject($calendarId, $uri2, $calData[2]); // get all the cards @@ -412,17 +428,23 @@ EOD; $this->assertEquals($calData[2], $calendarObjects[1]['calendardata']); // delete the card - $this->legacyDispatcher->expects($this->at(0)) - ->method('dispatch') - ->with('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject'); + $this->dispatcher->expects(self::once()) + ->method('dispatchTyped') + ->with(self::callback(function ($event) { + return $event instanceof CalendarDeletedEvent; + })); $this->backend->deleteCalendarObject($calendarId, $uri0); - $this->legacyDispatcher->expects($this->at(0)) - ->method('dispatch') - ->with('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject'); + $this->dispatcher->expects(self::once()) + ->method('dispatchTyped') + ->with(self::callback(function ($event) { + return $event instanceof CalendarDeletedEvent; + })); $this->backend->deleteCalendarObject($calendarId, $uri1); - $this->legacyDispatcher->expects($this->at(0)) - ->method('dispatch') - ->with('\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject'); + $this->dispatcher->expects(self::once()) + ->method('dispatchTyped') + ->with(self::callback(function ($event) { + return $event instanceof CalendarDeletedEvent; + })); $this->backend->deleteCalendarObject($calendarId, $uri2); $calendarObjects = $this->backend->getCalendarObjects($calendarId); $this->assertCount(0, $calendarObjects); diff --git a/apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php b/apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php index 2d4cbfd0c8c..ce5b5acdd69 100644 --- a/apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php +++ b/apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php @@ -211,17 +211,15 @@ EOD; ->method('cleanRemindersForEvent') ->with(44); - $action = '\OCA\DAV\CalDAV\CalDavBackend::deleteCalendarObject'; $objectData = [ 'id' => '44', 'component' => 'vevent', ]; - $this->reminderService->onTouchCalendarObject($action, $objectData); + $this->reminderService->onCalendarObjectDelete($objectData); } public function testOnCalendarObjectCreateSingleEntry():void { - $action = '\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject'; $objectData = [ 'calendardata' => self::CALENDAR_DATA, 'id' => '42', @@ -242,11 +240,10 @@ EOD; ->with() ->willReturn(\DateTime::createFromFormat(\DateTime::ATOM, '2016-06-08T00:00:00+00:00')); - $this->reminderService->onTouchCalendarObject($action, $objectData); + $this->reminderService->onCalendarObjectCreate($objectData); } public function testOnCalendarObjectCreateSingleEntryWithRepeat(): void { - $action = '\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject'; $objectData = [ 'calendardata' => self::CALENDAR_DATA_REPEAT, 'id' => '42', @@ -270,11 +267,10 @@ EOD; ->with() ->willReturn(\DateTime::createFromFormat(\DateTime::ATOM, '2016-06-08T00:00:00+00:00')); - $this->reminderService->onTouchCalendarObject($action, $objectData); + $this->reminderService->onCalendarObjectCreate($objectData); } public function testOnCalendarObjectCreateRecurringEntry(): void { - $action = '\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject'; $objectData = [ 'calendardata' => self::CALENDAR_DATA_RECURRING, 'id' => '42', @@ -295,11 +291,10 @@ EOD; ->with() ->willReturn(\DateTime::createFromFormat(\DateTime::ATOM, '2016-06-29T00:00:00+00:00')); - $this->reminderService->onTouchCalendarObject($action, $objectData); + $this->reminderService->onCalendarObjectCreate($objectData); } public function testOnCalendarObjectCreateEmpty():void { - $action = '\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject'; $objectData = [ 'calendardata' => self::CALENDAR_DATA_NO_ALARM, 'id' => '42', @@ -310,11 +305,10 @@ EOD; $this->backend->expects($this->never()) ->method('insertReminder'); - $this->reminderService->onTouchCalendarObject($action, $objectData); + $this->reminderService->onCalendarObjectCreate($objectData); } public function testOnCalendarObjectCreateRecurringEntryWithRepeat():void { - $action = '\OCA\DAV\CalDAV\CalDavBackend::createCalendarObject'; $objectData = [ 'calendardata' => self::CALENDAR_DATA_RECURRING_REPEAT, 'id' => '42', @@ -339,7 +333,7 @@ EOD; ->with() ->willReturn(\DateTime::createFromFormat(\DateTime::ATOM, '2016-06-29T00:00:00+00:00')); - $this->reminderService->onTouchCalendarObject($action, $objectData); + $this->reminderService->onCalendarObjectCreate($objectData); } public function testProcessReminders():void { |