diff options
author | Joas Schilling <coding@schilljs.com> | 2021-06-04 10:57:41 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2021-06-04 10:57:41 +0200 |
commit | e1e5026df28b9311e241788ba86b4ab2fcec3592 (patch) | |
tree | 9a311418950bdd51ac9eb9b8ee5dc5bba5583018 /apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php | |
parent | 181aab416a5f3032034273b5eaa2eb6654982482 (diff) | |
download | nextcloud-server-e1e5026df28b9311e241788ba86b4ab2fcec3592.tar.gz nextcloud-server-e1e5026df28b9311e241788ba86b4ab2fcec3592.zip |
Fix dispatcher handling in CalDavBackendTest
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php')
-rw-r--r-- | apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php | 29 |
1 files changed, 12 insertions, 17 deletions
diff --git a/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php b/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php index eb0530a8b3d..8ac4aa37899 100644 --- a/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php +++ b/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php @@ -33,7 +33,9 @@ use OCA\DAV\CalDAV\Proxy\ProxyMapper; use OCA\DAV\Connector\Sabre\Principal; use OCA\DAV\Events\CalendarCreatedEvent; use OCA\DAV\Events\CalendarDeletedEvent; +use OCA\DAV\Events\CalendarMovedToTrashEvent; use OCA\DAV\Events\CalendarObjectCreatedEvent; +use OCA\DAV\Events\SubscriptionCreatedEvent; use OCP\App\IAppManager; use OCP\EventDispatcher\IEventDispatcher; use OCP\IConfig; @@ -66,9 +68,9 @@ abstract class AbstractCalDavBackend extends TestCase { protected $userManager; /** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject */ protected $groupManager; - /** @var EventDispatcherInterface|\PHPUnit\Framework\MockObject\MockObject */ - protected $dispatcher; /** @var IEventDispatcher|\PHPUnit\Framework\MockObject\MockObject */ + protected $dispatcher; + /** @var EventDispatcherInterface|\PHPUnit\Framework\MockObject\MockObject */ protected $legacyDispatcher; /** @var ISecureRandom */ @@ -147,11 +149,10 @@ abstract class AbstractCalDavBackend extends TestCase { private function cleanupForPrincipal($principal): void { $calendars = $this->backend->getCalendarsForUser($principal); - $this->legacyDispatcher->expects(self::exactly(count($calendars))) - ->method('dispatchTyped') - ->with(self::callback(function ($event) { - return $event instanceof CalendarDeletedEvent; - })); + $this->dispatcher->expects(self::any()) + ->method('dispatchTyped'); + $this->legacyDispatcher->expects(self::any()) + ->method('dispatch'); foreach ($calendars as $calendar) { $this->backend->deleteCalendar($calendar['id'], true); } @@ -162,11 +163,8 @@ abstract class AbstractCalDavBackend extends TestCase { } protected function createTestCalendar() { - $this->dispatcher->expects(self::once()) - ->method('dispatchTyped') - ->with(self::callback(function ($event) { - return $event instanceof CalendarCreatedEvent; - })); + $this->dispatcher->expects(self::any()) + ->method('dispatchTyped'); $this->backend->createCalendar(self::UNIT_TEST_USER, 'Example', [ '{http://apple.com/ns/ical/}calendar-color' => '#1C4587FF' @@ -221,11 +219,8 @@ END:VCALENDAR EOD; $uri0 = $this->getUniqueID('event'); - $this->dispatcher->expects(self::once()) - ->method('dispatchTyped') - ->with(self::callback(function ($event) { - return $event instanceof CalendarObjectCreatedEvent; - })); + $this->dispatcher->expects(self::atLeastOnce()) + ->method('dispatchTyped'); $this->backend->createCalendarObject($calendarId, $uri0, $calData); |