diff options
Diffstat (limited to 'apps/dav/tests/unit')
7 files changed, 265 insertions, 59 deletions
diff --git a/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php b/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php index ec966248e01..b04f8701c23 100644 --- a/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php +++ b/apps/dav/tests/unit/CalDAV/AbstractCalDavBackend.php @@ -7,6 +7,7 @@ * @author Joas Schilling <coding@schilljs.com> * @author Morris Jobke <hey@morrisjobke.de> * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Thomas Citharel <nextcloud@tcit.fr> * @author Thomas Müller <thomas.mueller@tmit.eu> * * @license AGPL-3.0 @@ -42,7 +43,6 @@ use OCP\Share\IManager as ShareManager; use Psr\Log\LoggerInterface; use Sabre\CalDAV\Xml\Property\SupportedCalendarComponentSet; use Sabre\DAV\Xml\Property\Href; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Test\TestCase; /** @@ -65,8 +65,6 @@ abstract class AbstractCalDavBackend extends TestCase { protected $groupManager; /** @var IEventDispatcher|\PHPUnit\Framework\MockObject\MockObject */ protected $dispatcher; - /** @var EventDispatcherInterface|\PHPUnit\Framework\MockObject\MockObject */ - protected $legacyDispatcher; /** @var ISecureRandom */ private $random; @@ -84,7 +82,6 @@ abstract class AbstractCalDavBackend extends TestCase { $this->userManager = $this->createMock(IUserManager::class); $this->groupManager = $this->createMock(IGroupManager::class); $this->dispatcher = $this->createMock(IEventDispatcher::class); - $this->legacyDispatcher = $this->createMock(EventDispatcherInterface::class); $this->principal = $this->getMockBuilder(Principal::class) ->setConstructorArgs([ $this->userManager, @@ -120,7 +117,6 @@ abstract class AbstractCalDavBackend extends TestCase { $this->random, $this->logger, $this->dispatcher, - $this->legacyDispatcher, $this->config ); @@ -147,8 +143,6 @@ abstract class AbstractCalDavBackend extends TestCase { $calendars = $this->backend->getCalendarsForUser($principal); $this->dispatcher->expects(self::any()) ->method('dispatchTyped'); - $this->legacyDispatcher->expects(self::any()) - ->method('dispatch'); foreach ($calendars as $calendar) { $this->backend->deleteCalendar($calendar['id'], true); } diff --git a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php index 3a5cf56409c..8e4bb1f7932 100644 --- a/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php +++ b/apps/dav/tests/unit/CalDAV/CalDavBackendTest.php @@ -150,9 +150,6 @@ class CalDavBackendTest extends AbstractCalDavBackend { $calendars = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER); $this->assertCount(1, $calendars); $calendar = new Calendar($this->backend, $calendars[0], $l10n, $config, $logger); - $this->legacyDispatcher->expects($this->at(0)) - ->method('dispatch') - ->with('\OCA\DAV\CalDAV\CalDavBackend::updateShares'); $this->backend->updateShares($calendar, $add, []); $calendars = $this->backend->getCalendarsForUser(self::UNIT_TEST_USER1); $this->assertCount(1, $calendars); diff --git a/apps/dav/tests/unit/CalDAV/Listener/CalendarPublicationListenerTest.php b/apps/dav/tests/unit/CalDAV/Listener/CalendarPublicationListenerTest.php new file mode 100644 index 00000000000..c42fca1a1cf --- /dev/null +++ b/apps/dav/tests/unit/CalDAV/Listener/CalendarPublicationListenerTest.php @@ -0,0 +1,79 @@ +<?php +/** + * @copyright 2022 Thomas Citharel <nextcloud@tcit.fr> + * + * @author Thomas Citharel <nextcloud@tcit.fr> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +namespace OCA\DAV\Tests\unit\CalDAV\Listeners; + +use OCA\DAV\CalDAV\Activity\Backend; +use OCA\DAV\Events\CalendarPublishedEvent; +use OCA\DAV\Events\CalendarUnpublishedEvent; +use OCA\DAV\Listener\CalendarPublicationListener; +use OCP\EventDispatcher\Event; +use PHPUnit\Framework\MockObject\MockObject; +use Psr\Log\LoggerInterface; +use Test\TestCase; + +class CalendarPublicationListenerTest extends TestCase { + + /** @var Backend|MockObject */ + private $activityBackend; + + /** @var LoggerInterface|MockObject */ + private $logger; + + private CalendarPublicationListener $calendarPublicationListener; + + /** @var CalendarPublishedEvent|MockObject */ + private $publicationEvent; + + /** @var CalendarUnpublishedEvent|MockObject */ + private $unpublicationEvent; + + protected function setUp(): void { + parent::setUp(); + + $this->activityBackend = $this->createMock(Backend::class); + $this->logger = $this->createMock(LoggerInterface::class); + $this->publicationEvent = $this->createMock(CalendarPublishedEvent::class); + $this->unpublicationEvent = $this->createMock(CalendarUnpublishedEvent::class); + $this->calendarPublicationListener = new CalendarPublicationListener($this->activityBackend, $this->logger); + } + + public function testInvalidEvent(): void { + $this->activityBackend->expects($this->never())->method('onCalendarPublication'); + $this->logger->expects($this->never())->method('debug'); + $this->calendarPublicationListener->handle(new Event()); + } + + public function testPublicationEvent(): void { + $this->publicationEvent->expects($this->once())->method('getCalendarData')->with()->willReturn([]); + $this->activityBackend->expects($this->once())->method('onCalendarPublication')->with([], true); + $this->logger->expects($this->once())->method('debug'); + $this->calendarPublicationListener->handle($this->publicationEvent); + } + + public function testUnPublicationEvent(): void { + $this->unpublicationEvent->expects($this->once())->method('getCalendarData')->with()->willReturn([]); + $this->activityBackend->expects($this->once())->method('onCalendarPublication')->with([], false); + $this->logger->expects($this->once())->method('debug'); + $this->calendarPublicationListener->handle($this->unpublicationEvent); + } +} diff --git a/apps/dav/tests/unit/CalDAV/Listener/CalendarShareUpdateListenerTest.php b/apps/dav/tests/unit/CalDAV/Listener/CalendarShareUpdateListenerTest.php new file mode 100644 index 00000000000..0252cffd5a0 --- /dev/null +++ b/apps/dav/tests/unit/CalDAV/Listener/CalendarShareUpdateListenerTest.php @@ -0,0 +1,70 @@ +<?php +/** + * @copyright 2022 Thomas Citharel <nextcloud@tcit.fr> + * + * @author Thomas Citharel <nextcloud@tcit.fr> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +namespace OCA\DAV\Tests\unit\CalDAV\Listeners; + +use OCA\DAV\CalDAV\Activity\Backend; +use OCA\DAV\Events\CalendarShareUpdatedEvent; +use OCA\DAV\Listener\CalendarShareUpdateListener; +use OCP\EventDispatcher\Event; +use PHPUnit\Framework\MockObject\MockObject; +use Psr\Log\LoggerInterface; +use Test\TestCase; + +class CalendarShareUpdateListenerTest extends TestCase { + + /** @var Backend|MockObject */ + private $activityBackend; + + /** @var LoggerInterface|MockObject */ + private $logger; + + private CalendarShareUpdateListener $calendarPublicationListener; + + /** @var CalendarShareUpdatedEvent|MockObject */ + private $event; + + protected function setUp(): void { + parent::setUp(); + + $this->activityBackend = $this->createMock(Backend::class); + $this->logger = $this->createMock(LoggerInterface::class); + $this->event = $this->createMock(CalendarShareUpdatedEvent::class); + $this->calendarPublicationListener = new CalendarShareUpdateListener($this->activityBackend, $this->logger); + } + + public function testInvalidEvent(): void { + $this->activityBackend->expects($this->never())->method('onCalendarUpdateShares'); + $this->logger->expects($this->never())->method('debug'); + $this->calendarPublicationListener->handle(new Event()); + } + + public function testEvent(): void { + $this->event->expects($this->once())->method('getCalendarData')->with()->willReturn([]); + $this->event->expects($this->once())->method('getOldShares')->with()->willReturn([]); + $this->event->expects($this->once())->method('getAdded')->with()->willReturn([]); + $this->event->expects($this->once())->method('getRemoved')->with()->willReturn([]); + $this->activityBackend->expects($this->once())->method('onCalendarUpdateShares')->with([], [], [], []); + $this->logger->expects($this->once())->method('debug'); + $this->calendarPublicationListener->handle($this->event); + } +} diff --git a/apps/dav/tests/unit/CalDAV/Listener/SubscriptionListenerTest.php b/apps/dav/tests/unit/CalDAV/Listener/SubscriptionListenerTest.php new file mode 100644 index 00000000000..709ebdac7af --- /dev/null +++ b/apps/dav/tests/unit/CalDAV/Listener/SubscriptionListenerTest.php @@ -0,0 +1,95 @@ +<?php +/** + * @copyright 2022 Thomas Citharel <nextcloud@tcit.fr> + * + * @author Thomas Citharel <nextcloud@tcit.fr> + * + * @license GNU AGPL version 3 or any later version + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + * + */ +namespace OCA\DAV\Tests\unit\CalDAV\Listeners; + +use OCA\DAV\BackgroundJob\RefreshWebcalJob; +use OCA\DAV\CalDAV\Reminder\Backend; +use OCA\DAV\CalDAV\WebcalCaching\RefreshWebcalService; +use OCA\DAV\Events\SubscriptionCreatedEvent; +use OCA\DAV\Events\SubscriptionDeletedEvent; +use OCA\DAV\Listener\SubscriptionListener; +use OCP\BackgroundJob\IJobList; +use OCP\EventDispatcher\Event; +use PHPUnit\Framework\MockObject\MockObject; +use Psr\Log\LoggerInterface; +use Test\TestCase; + +class SubscriptionListenerTest extends TestCase { + + /** @var RefreshWebcalService|MockObject */ + private $refreshWebcalService; + + /** @var Backend|MockObject */ + private $reminderBackend; + + /** @var IJobList|MockObject */ + private $jobList; + + /** @var LoggerInterface|MockObject */ + private $logger; + + private SubscriptionListener $calendarPublicationListener; + + /** @var SubscriptionCreatedEvent|MockObject */ + private $subscriptionCreatedEvent; + + /** @var SubscriptionDeletedEvent|MockObject */ + private $subscriptionDeletedEvent; + + protected function setUp(): void { + parent::setUp(); + + $this->refreshWebcalService = $this->createMock(RefreshWebcalService::class); + $this->reminderBackend = $this->createMock(Backend::class); + $this->jobList = $this->createMock(IJobList::class); + $this->logger = $this->createMock(LoggerInterface::class); + $this->subscriptionCreatedEvent = $this->createMock(SubscriptionCreatedEvent::class); + $this->subscriptionDeletedEvent = $this->createMock(SubscriptionDeletedEvent::class); + $this->calendarPublicationListener = new SubscriptionListener($this->jobList, $this->refreshWebcalService, $this->reminderBackend, $this->logger); + } + + public function testInvalidEvent(): void { + $this->refreshWebcalService->expects($this->never())->method('refreshSubscription'); + $this->jobList->expects($this->never())->method('add'); + $this->logger->expects($this->never())->method('debug'); + $this->calendarPublicationListener->handle(new Event()); + } + + public function testCreateSubscriptionEvent(): void { + $this->subscriptionCreatedEvent->expects($this->once())->method('getSubscriptionId')->with()->willReturn(5); + $this->subscriptionCreatedEvent->expects($this->once())->method('getSubscriptionData')->with()->willReturn(['principaluri' => 'principaluri', 'uri' => 'uri']); + $this->refreshWebcalService->expects($this->once())->method('refreshSubscription')->with('principaluri', 'uri'); + $this->jobList->expects($this->once())->method('add')->with(RefreshWebcalJob::class, ['principaluri' => 'principaluri', 'uri' => 'uri']); + $this->logger->expects($this->exactly(2))->method('debug'); + $this->calendarPublicationListener->handle($this->subscriptionCreatedEvent); + } + + public function testDeleteSubscriptionEvent(): void { + $this->subscriptionDeletedEvent->expects($this->once())->method('getSubscriptionId')->with()->willReturn(5); + $this->subscriptionDeletedEvent->expects($this->once())->method('getSubscriptionData')->with()->willReturn(['principaluri' => 'principaluri', 'uri' => 'uri']); + $this->jobList->expects($this->once())->method('remove')->with(RefreshWebcalJob::class, ['principaluri' => 'principaluri', 'uri' => 'uri']); + $this->reminderBackend->expects($this->once())->method('cleanRemindersForCalendar')->with(5); + $this->logger->expects($this->exactly(2))->method('debug'); + $this->calendarPublicationListener->handle($this->subscriptionDeletedEvent); + } +} diff --git a/apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php b/apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php index 80e43d279dc..23c1c2ae896 100644 --- a/apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php +++ b/apps/dav/tests/unit/CalDAV/PublicCalendarRootTest.php @@ -42,7 +42,6 @@ use OCP\IL10N; use OCP\IUserManager; use OCP\Security\ISecureRandom; use Psr\Log\LoggerInterface; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; use Test\TestCase; /** @@ -84,7 +83,6 @@ class PublicCalendarRootTest extends TestCase { $this->random = \OC::$server->getSecureRandom(); $this->logger = $this->createMock(LoggerInterface::class); $dispatcher = $this->createMock(IEventDispatcher::class); - $legacyDispatcher = $this->createMock(EventDispatcherInterface::class); $config = $this->createMock(IConfig::class); $this->principal->expects($this->any())->method('getGroupMembership') @@ -103,7 +101,6 @@ class PublicCalendarRootTest extends TestCase { $this->random, $this->logger, $dispatcher, - $legacyDispatcher, $config ); $this->l10n = $this->getMockBuilder(IL10N::class) diff --git a/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php b/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php index 7eda691d199..5bfbab07b29 100644 --- a/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php +++ b/apps/dav/tests/unit/CardDAV/CardDavBackendTest.php @@ -13,6 +13,7 @@ * @author Morris Jobke <hey@morrisjobke.de> * @author Robin Appelman <robin@icewind.nl> * @author Roeland Jago Douma <roeland@famdouma.nl> + * @author Thomas Citharel <nextcloud@tcit.fr> * @author Thomas Müller <thomas.mueller@tmit.eu> * * @license AGPL-3.0 @@ -52,8 +53,6 @@ use Sabre\DAV\Exception\BadRequest; use Sabre\DAV\PropPatch; use Sabre\VObject\Component\VCard; use Sabre\VObject\Property\Text; -use Symfony\Component\EventDispatcher\EventDispatcherInterface; -use Symfony\Component\EventDispatcher\GenericEvent; use Test\TestCase; /** @@ -77,10 +76,7 @@ class CardDavBackendTest extends TestCase { /** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject */ private $groupManager; - /** @var EventDispatcherInterface|\PHPUnit\Framework\MockObject\MockObject */ - private $legacyDispatcher; - - /** @var IEventDispatcher|\PHPUnit\Framework\MockObject\MockObject */ + /** @var IEventDispatcher|MockObject */ private $dispatcher; /** @var IDBConnection */ @@ -155,11 +151,10 @@ class CardDavBackendTest extends TestCase { ->withAnyParameters() ->willReturn([self::UNIT_TEST_GROUP]); $this->dispatcher = $this->createMock(IEventDispatcher::class); - $this->legacyDispatcher = $this->createMock(EventDispatcherInterface::class); $this->db = \OC::$server->getDatabaseConnection(); - $this->backend = new CardDavBackend($this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher, $this->legacyDispatcher); + $this->backend = new CardDavBackend($this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher); // start every test with a empty cards_properties and cards table $query = $this->db->getQueryBuilder(); $query->delete('cards_properties')->execute(); @@ -249,8 +244,8 @@ class CardDavBackendTest extends TestCase { /** @var CardDavBackend | \PHPUnit\Framework\MockObject\MockObject $backend */ $backend = $this->getMockBuilder(CardDavBackend::class) - ->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher, $this->legacyDispatcher]) - ->setMethods(['updateProperties', 'purgeProperties'])->getMock(); + ->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher]) + ->onlyMethods(['updateProperties', 'purgeProperties'])->getMock(); // create a new address book $backend->createAddressBook(self::UNIT_TEST_USER, 'Example', []); @@ -264,13 +259,9 @@ class CardDavBackendTest extends TestCase { $backend->expects($this->at(1))->method('updateProperties')->with($bookId, $uri, $this->vcardTest1); // Expect event - $this->legacyDispatcher->expects($this->at(0)) - ->method('dispatch') - ->with('\OCA\DAV\CardDAV\CardDavBackend::createCard', $this->callback(function (GenericEvent $e) use ($bookId, $uri) { - return $e->getArgument('addressBookId') === $bookId && - $e->getArgument('cardUri') === $uri && - $e->getArgument('cardData') === $this->vcardTest0; - })); + $this->dispatcher + ->expects($this->exactly(3)) + ->method('dispatchTyped'); // create a card $backend->createCard($bookId, $uri, $this->vcardTest0); @@ -290,28 +281,11 @@ class CardDavBackendTest extends TestCase { $this->assertArrayHasKey('size', $card); $this->assertEquals($this->vcardTest0, $card['carddata']); - // Expect event - $this->legacyDispatcher->expects($this->at(0)) - ->method('dispatch') - ->with('\OCA\DAV\CardDAV\CardDavBackend::updateCard', $this->callback(function (GenericEvent $e) use ($bookId, $uri) { - return $e->getArgument('addressBookId') === $bookId && - $e->getArgument('cardUri') === $uri && - $e->getArgument('cardData') === $this->vcardTest1; - })); - // update the card $backend->updateCard($bookId, $uri, $this->vcardTest1); $card = $backend->getCard($bookId, $uri); $this->assertEquals($this->vcardTest1, $card['carddata']); - // Expect event - $this->legacyDispatcher->expects($this->at(0)) - ->method('dispatch') - ->with('\OCA\DAV\CardDAV\CardDavBackend::deleteCard', $this->callback(function (GenericEvent $e) use ($bookId, $uri) { - return $e->getArgument('addressBookId') === $bookId && - $e->getArgument('cardUri') === $uri; - })); - // delete the card $backend->expects($this->once())->method('purgeProperties')->with($bookId, $card['id']); $backend->deleteCard($bookId, $uri); @@ -321,7 +295,7 @@ class CardDavBackendTest extends TestCase { public function testMultiCard() { $this->backend = $this->getMockBuilder(CardDavBackend::class) - ->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher, $this->legacyDispatcher]) + ->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher]) ->setMethods(['updateProperties'])->getMock(); // create a new address book @@ -374,8 +348,8 @@ class CardDavBackendTest extends TestCase { public function testMultipleUIDOnDifferentAddressbooks() { $this->backend = $this->getMockBuilder(CardDavBackend::class) - ->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher, $this->legacyDispatcher]) - ->setMethods(['updateProperties'])->getMock(); + ->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher]) + ->onlyMethods(['updateProperties'])->getMock(); // create 2 new address books $this->backend->createAddressBook(self::UNIT_TEST_USER, 'Example', []); @@ -396,7 +370,7 @@ class CardDavBackendTest extends TestCase { public function testMultipleUIDDenied() { $this->backend = $this->getMockBuilder(CardDavBackend::class) - ->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher, $this->legacyDispatcher]) + ->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher]) ->setMethods(['updateProperties'])->getMock(); // create a new address book @@ -417,7 +391,7 @@ class CardDavBackendTest extends TestCase { public function testNoValidUID() { $this->backend = $this->getMockBuilder(CardDavBackend::class) - ->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher, $this->legacyDispatcher]) + ->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher]) ->setMethods(['updateProperties'])->getMock(); // create a new address book @@ -434,8 +408,8 @@ class CardDavBackendTest extends TestCase { public function testDeleteWithoutCard() { $this->backend = $this->getMockBuilder(CardDavBackend::class) - ->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher, $this->legacyDispatcher]) - ->setMethods([ + ->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher]) + ->onlyMethods([ 'getCardId', 'addChange', 'purgeProperties', @@ -474,7 +448,7 @@ class CardDavBackendTest extends TestCase { public function testSyncSupport() { $this->backend = $this->getMockBuilder(CardDavBackend::class) - ->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher, $this->legacyDispatcher]) + ->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher]) ->setMethods(['updateProperties'])->getMock(); // create a new address book @@ -540,8 +514,8 @@ class CardDavBackendTest extends TestCase { $cardId = 2; $backend = $this->getMockBuilder(CardDavBackend::class) - ->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher, $this->legacyDispatcher]) - ->setMethods(['getCardId'])->getMock(); + ->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher]) + ->onlyMethods(['getCardId'])->getMock(); $backend->expects($this->any())->method('getCardId')->willReturn($cardId); @@ -630,8 +604,8 @@ class CardDavBackendTest extends TestCase { $qResult->closeCursor(); $this->assertSame(1, count($result)); - $this->assertSame(1 ,(int)$result[0]['addressbookid']); - $this->assertSame(2 ,(int)$result[0]['cardid']); + $this->assertSame(1, (int)$result[0]['addressbookid']); + $this->assertSame(2, (int)$result[0]['cardid']); } public function testGetCardId() { |