]> source.dussan.org Git - nextcloud-server.git/commitdiff
Get rid of deprecated at matcher in dav application tests 36026/head
authorCôme Chilliet <come.chilliet@nextcloud.com>
Thu, 5 Jan 2023 17:25:31 +0000 (18:25 +0100)
committerCôme Chilliet <come.chilliet@nextcloud.com>
Thu, 5 Jan 2023 17:28:07 +0000 (18:28 +0100)
Signed-off-by: Côme Chilliet <come.chilliet@nextcloud.com>
32 files changed:
apps/dav/tests/unit/BackgroundJob/CleanupInvitationTokenJobTest.php
apps/dav/tests/unit/BackgroundJob/EventReminderJobTest.php
apps/dav/tests/unit/BackgroundJob/RegisterRegenerateBirthdayCalendarsTest.php
apps/dav/tests/unit/CalDAV/CachedSubscriptionTest.php
apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/EmailProviderTest.php
apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/PushProviderTest.php
apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php
apps/dav/tests/unit/CalDAV/ResourceBooking/AbstractPrincipalBackendTest.php
apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php
apps/dav/tests/unit/CalDAV/Search/SearchPluginTest.php
apps/dav/tests/unit/CalDAV/WebcalCaching/PluginTest.php
apps/dav/tests/unit/CardDAV/AddressBookImplTest.php
apps/dav/tests/unit/CardDAV/BirthdayServiceTest.php
apps/dav/tests/unit/CardDAV/CardDavBackendTest.php
apps/dav/tests/unit/CardDAV/ImageExportPluginTest.php
apps/dav/tests/unit/CardDAV/SyncServiceTest.php
apps/dav/tests/unit/Command/MoveCalendarTest.php
apps/dav/tests/unit/Connector/Sabre/AuthTest.php
apps/dav/tests/unit/Connector/Sabre/BearerAuthTest.php
apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php
apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php
apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php
apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php
apps/dav/tests/unit/Controller/InvitationResponseControllerTest.php
apps/dav/tests/unit/DAV/CustomPropertiesBackendTest.php
apps/dav/tests/unit/DAV/GroupPrincipalTest.php
apps/dav/tests/unit/Migration/RefreshWebcalJobRegistrarTest.php
apps/dav/tests/unit/Migration/RemoveDeletedUsersCalendarSubscriptionsTest.php
apps/dav/tests/unit/Provisioning/Apple/AppleProvisioningNodeTest.php
apps/dav/tests/unit/Provisioning/Apple/AppleProvisioningPluginTest.php
apps/dav/tests/unit/Search/EventsSearchProviderTest.php
apps/dav/tests/unit/Upload/ChunkingPluginTest.php

index d3b7ca925812d26d756a4e2fbe1b6f0c8624e970..609d05041703dadf7e02c013ecabc2d157c71c43 100644 (file)
@@ -87,15 +87,15 @@ class CleanupInvitationTokenJobTest extends TestCase {
                        ->with()
                        ->willReturn($queryBuilder);
 
-               $queryBuilder->expects($this->at(0))
+               $queryBuilder->expects($this->once())
                        ->method('delete')
                        ->with('calendar_invitations')
                        ->willReturn($queryBuilder);
-               $queryBuilder->expects($this->at(3))
+               $queryBuilder->expects($this->once())
                        ->method('where')
                        ->with($function)
                        ->willReturn($queryBuilder);
-               $queryBuilder->expects($this->at(4))
+               $queryBuilder->expects($this->once())
                        ->method('execute')
                        ->with()
                        ->willReturn($stmt);
index ed3c324e7107372e2d53fa4af350864c493dd284..070b427b37999a5acf30ef2c20ba83e8b2b150c0 100644 (file)
@@ -36,7 +36,6 @@ use PHPUnit\Framework\MockObject\MockObject;
 use Test\TestCase;
 
 class EventReminderJobTest extends TestCase {
-
        /** @var ITimeFactory|MockObject */
        private $time;
 
@@ -80,17 +79,16 @@ class EventReminderJobTest extends TestCase {
         * @param bool $expectCall
         */
        public function testRun(bool $sendEventReminders, bool $sendEventRemindersMode, bool $expectCall): void {
-               $this->config->expects($this->at(0))
+               $this->config->expects($this->exactly($sendEventReminders ? 2 : 1))
                        ->method('getAppValue')
-                       ->with('dav', 'sendEventReminders', 'yes')
-                       ->willReturn($sendEventReminders ? 'yes' : 'no');
-
-               if ($sendEventReminders) {
-                       $this->config->expects($this->at(1))
-                               ->method('getAppValue')
-                               ->with('dav', 'sendEventRemindersMode', 'backgroundjob')
-                               ->willReturn($sendEventRemindersMode ? 'backgroundjob' : 'cron');
-               }
+                       ->withConsecutive(
+                               ['dav', 'sendEventReminders', 'yes'],
+                               ['dav', 'sendEventRemindersMode', 'backgroundjob'],
+                       )
+                       ->willReturnOnConsecutiveCalls(
+                               $sendEventReminders ? 'yes' : 'no',
+                               $sendEventRemindersMode ? 'backgroundjob' : 'cron'
+                       );
 
                if ($expectCall) {
                        $this->reminderService->expects($this->once())
index 00931d53f64af25b50fb303bb7164b8831c9011d..9e9f6822fe16a7fdf08c80fb0d57f0e29e473a33 100644 (file)
@@ -32,13 +32,11 @@ use OCA\DAV\BackgroundJob\GenerateBirthdayCalendarBackgroundJob;
 use OCA\DAV\BackgroundJob\RegisterRegenerateBirthdayCalendars;
 use OCP\AppFramework\Utility\ITimeFactory;
 use OCP\BackgroundJob\IJobList;
-use OCP\IConfig;
 use OCP\IUser;
 use OCP\IUserManager;
 use Test\TestCase;
 
 class RegisterRegenerateBirthdayCalendarsTest extends TestCase {
-
        /** @var ITimeFactory | \PHPUnit\Framework\MockObject\MockObject */
        private $time;
 
@@ -81,24 +79,22 @@ class RegisterRegenerateBirthdayCalendarsTest extends TestCase {
                                $closure($user3);
                        });
 
-               $this->jobList->expects($this->at(0))
-                       ->method('add')
-                       ->with(GenerateBirthdayCalendarBackgroundJob::class, [
-                               'userId' => 'uid1',
-                               'purgeBeforeGenerating' => true
-                       ]);
-               $this->jobList->expects($this->at(1))
-                       ->method('add')
-                       ->with(GenerateBirthdayCalendarBackgroundJob::class, [
-                               'userId' => 'uid2',
-                               'purgeBeforeGenerating' => true
-                       ]);
-               $this->jobList->expects($this->at(2))
+               $this->jobList->expects($this->exactly(3))
                        ->method('add')
-                       ->with(GenerateBirthdayCalendarBackgroundJob::class, [
-                               'userId' => 'uid3',
-                               'purgeBeforeGenerating' => true
-                       ]);
+                       ->withConsecutive(
+                               [GenerateBirthdayCalendarBackgroundJob::class, [
+                                       'userId' => 'uid1',
+                                       'purgeBeforeGenerating' => true
+                               ]],
+                               [GenerateBirthdayCalendarBackgroundJob::class, [
+                                       'userId' => 'uid2',
+                                       'purgeBeforeGenerating' => true
+                               ]],
+                               [GenerateBirthdayCalendarBackgroundJob::class, [
+                                       'userId' => 'uid3',
+                                       'purgeBeforeGenerating' => true
+                               ]],
+                       );
 
                $this->backgroundJob->run([]);
        }
index dac5090dccca978543e8a39637f7e7ad96699eb4..6b5b5f653478e7dc417cce7daf4e4a45fa28a451 100644 (file)
@@ -141,7 +141,7 @@ class CachedSubscriptionTest extends \Test\TestCase {
                $calendar->propPatch($propPatch);
        }
 
-       
+
        public function testGetChild() {
                $this->expectException(\Sabre\DAV\Exception\NotFound::class);
                $this->expectExceptionMessage('Calendar object not found');
@@ -154,17 +154,19 @@ class CachedSubscriptionTest extends \Test\TestCase {
                        'uri' => 'cal',
                ];
 
-               $backend->expects($this->at(0))
+               $backend->expects($this->exactly(2))
                        ->method('getCalendarObject')
-                       ->with(666, 'foo1', 1)
-                       ->willReturn([
-                               'id' => 99,
-                               'uri' => 'foo1'
-                       ]);
-               $backend->expects($this->at(1))
-                       ->method('getCalendarObject')
-                       ->with(666, 'foo2', 1)
-                       ->willReturn(null);
+                       ->withConsecutive(
+                               [666, 'foo1', 1],
+                               [666, 'foo2', 1],
+                       )
+                       ->willReturnOnConsecutiveCalls(
+                               [
+                                       'id' => 99,
+                                       'uri' => 'foo1'
+                               ],
+                               null
+                       );
 
                $calendar = new CachedSubscription($backend, $calendarInfo);
 
@@ -183,7 +185,7 @@ class CachedSubscriptionTest extends \Test\TestCase {
                        'uri' => 'cal',
                ];
 
-               $backend->expects($this->at(0))
+               $backend->expects($this->once())
                        ->method('getCalendarObjects')
                        ->with(666, 1)
                        ->willReturn([
@@ -214,7 +216,7 @@ class CachedSubscriptionTest extends \Test\TestCase {
                        'uri' => 'cal',
                ];
 
-               $backend->expects($this->at(0))
+               $backend->expects($this->once())
                        ->method('getMultipleCalendarObjects')
                        ->with(666, ['foo1', 'foo2'], 1)
                        ->willReturn([
@@ -236,7 +238,7 @@ class CachedSubscriptionTest extends \Test\TestCase {
                $this->assertInstanceOf(CachedSubscriptionObject::class, $res[1]);
        }
 
-       
+
        public function testCreateFile() {
                $this->expectException(\Sabre\DAV\Exception\MethodNotAllowed::class);
                $this->expectExceptionMessage('Creating objects in cached subscription is not allowed');
@@ -262,17 +264,19 @@ class CachedSubscriptionTest extends \Test\TestCase {
                        'uri' => 'cal',
                ];
 
-               $backend->expects($this->at(0))
-                       ->method('getCalendarObject')
-                       ->with(666, 'foo1', 1)
-                       ->willReturn([
-                               'id' => 99,
-                               'uri' => 'foo1'
-                       ]);
-               $backend->expects($this->at(1))
+               $backend->expects($this->exactly(2))
                        ->method('getCalendarObject')
-                       ->with(666, 'foo2', 1)
-                       ->willReturn(null);
+                       ->withConsecutive(
+                               [666, 'foo1', 1],
+                               [666, 'foo2', 1],
+                       )
+                       ->willReturnOnConsecutiveCalls(
+                               [
+                                       'id' => 99,
+                                       'uri' => 'foo1'
+                               ],
+                               null
+                       );
 
                $calendar = new CachedSubscription($backend, $calendarInfo);
 
index 9499e9e2ef1a79c2254738cc422601a2556865dd..fb98552507841bba0df5f98ec82d66e4aca4d8eb 100644 (file)
@@ -32,11 +32,8 @@ declare(strict_types=1);
 namespace OCA\DAV\Tests\unit\CalDAV\Reminder\NotificationProvider;
 
 use OCA\DAV\CalDAV\Reminder\NotificationProvider\EmailProvider;
-use OCP\IConfig;
 use OCP\IL10N;
-use OCP\IURLGenerator;
 use OCP\IUser;
-use OCP\L10N\IFactory as L10NFactory;
 use OCP\Mail\IEMailTemplate;
 use OCP\Mail\IMailer;
 use OCP\Mail\IMessage;
@@ -112,62 +109,47 @@ class EmailProviderTest extends AbstractNotificationProviderTest {
                $message21 = $this->getMessageMock('uid2@example.com', $template2);
                $message22 = $this->getMessageMock('uid3@example.com', $template2);
 
-               $this->mailer->expects($this->at(0))
-                       ->method('createEMailTemplate')
-                       ->with('dav.calendarReminder')
-                       ->willReturn($template1);
-
-               $this->mailer->expects($this->at(1))
-                       ->method('validateMailAddress')
-                       ->with('uid1@example.com')
-                       ->willReturn(true);
-
-               $this->mailer->expects($this->at(2))
-                       ->method('createMessage')
-                       ->with()
-                       ->willReturn($message11);
-               $this->mailer->expects($this->at(3))
-                       ->method('send')
-                       ->with($message11)
-                       ->willReturn([]);
-
-               $this->mailer->expects($this->at(4))
+               $this->mailer->expects($this->exactly(2))
                        ->method('createEMailTemplate')
                        ->with('dav.calendarReminder')
-                       ->willReturn($template2);
+                       ->willReturnOnConsecutiveCalls(
+                               $template1,
+                               $template2
+                       );
 
-               $this->mailer->expects($this->at(5))
+               $this->mailer->expects($this->exactly(4))
                        ->method('validateMailAddress')
-                       ->with('uid2@example.com')
-                       ->willReturn(true);
+                       ->withConsecutive(
+                               ['uid1@example.com'],
+                               ['uid2@example.com'],
+                               ['uid3@example.com'],
+                               ['invalid'],
+                       )
+                       ->willReturnOnConsecutiveCalls(
+                               true,
+                               true,
+                               true,
+                               false,
+                       );
 
-               $this->mailer->expects($this->at(6))
+               $this->mailer->expects($this->exactly(3))
                        ->method('createMessage')
                        ->with()
-                       ->willReturn($message21);
-               $this->mailer->expects($this->at(7))
-                       ->method('send')
-                       ->with($message21)
-                       ->willReturn([]);
-               $this->mailer->expects($this->at(8))
-                       ->method('validateMailAddress')
-                       ->with('uid3@example.com')
-                       ->willReturn(true);
+                       ->willReturnOnConsecutiveCalls(
+                               $message11,
+                               $message21,
+                               $message22
+                       );
 
-               $this->mailer->expects($this->at(9))
-                       ->method('createMessage')
-                       ->with()
-                       ->willReturn($message22);
-               $this->mailer->expects($this->at(10))
+               $this->mailer->expects($this->exactly(3))
                        ->method('send')
-                       ->with($message22)
+                       ->withConsecutive(
+                               [$message11],
+                               [$message21],
+                               [$message22],
+                       )
                        ->willReturn([]);
 
-               $this->mailer->expects($this->at(11))
-                       ->method('validateMailAddress')
-                       ->with('invalid')
-                       ->willReturn(false);
-
                $this->setupURLGeneratorMock(2);
 
                $vcalendar = $this->getNoAttendeeVCalendar();
@@ -351,42 +333,27 @@ class EmailProviderTest extends AbstractNotificationProviderTest {
        private function getTemplateMock():IEMailTemplate {
                $template = $this->createMock(IEMailTemplate::class);
 
-               $template->expects($this->at(0))
+               $template->expects($this->once())
                        ->method('addHeader')
                        ->with()
                        ->willReturn($template);
 
-               $template->expects($this->at(1))
+               $template->expects($this->once())
                        ->method('setSubject')
                        ->with()
                        ->willReturn($template);
 
-               $template->expects($this->at(2))
+               $template->expects($this->once())
                        ->method('addHeading')
                        ->with()
                        ->willReturn($template);
 
-               $template->expects($this->at(3))
+               $template->expects($this->exactly(4))
                        ->method('addBodyListItem')
                        ->with()
                        ->willReturn($template);
 
-               $template->expects($this->at(4))
-                       ->method('addBodyListItem')
-                       ->with()
-                       ->willReturn($template);
-
-               $template->expects($this->at(5))
-                       ->method('addBodyListItem')
-                       ->with()
-                       ->willReturn($template);
-
-               $template->expects($this->at(6))
-                       ->method('addBodyListItem')
-                       ->with()
-                       ->willReturn($template);
-
-               $template->expects($this->at(7))
+               $template->expects($this->once())
                        ->method('addFooter')
                        ->with()
                        ->willReturn($template);
@@ -404,24 +371,27 @@ class EmailProviderTest extends AbstractNotificationProviderTest {
                $message = $this->createMock(IMessage::class);
                $i = 0;
 
-               $message->expects($this->at($i++))
+               $message->expects($this->once())
                        ->method('setFrom')
                        ->with([\OCP\Util::getDefaultEmailAddress('reminders-noreply')])
                        ->willReturn($message);
 
                if ($replyTo) {
-                       $message->expects($this->at($i++))
+                       $message->expects($this->once())
                                ->method('setReplyTo')
                                ->with($replyTo)
                                ->willReturn($message);
+               } else {
+                       $message->expects($this->never())
+                               ->method('setReplyTo');
                }
 
-               $message->expects($this->at($i++))
+               $message->expects($this->once())
                        ->method('setTo')
                        ->with([$toMail])
                        ->willReturn($message);
 
-               $message->expects($this->at($i++))
+               $message->expects($this->once())
                        ->method('useTemplate')
                        ->with($templateMock)
                        ->willReturn($message);
@@ -500,56 +470,25 @@ class EmailProviderTest extends AbstractNotificationProviderTest {
                return $vcalendar;
        }
 
-       private function setupURLGeneratorMock(int $times = 1):void {
-               for ($i = 0; $i < $times; $i++) {
-                       $this->urlGenerator
-                               ->expects($this->at(8 * $i))
-                               ->method('imagePath')
-                               ->with('core', 'actions/info.png')
-                               ->willReturn('imagePath1');
-
-                       $this->urlGenerator
-                               ->expects($this->at(8 * $i + 1))
-                               ->method('getAbsoluteURL')
-                               ->with('imagePath1')
-                               ->willReturn('AbsURL1');
-
-                       $this->urlGenerator
-                               ->expects($this->at(8 * $i + 2))
-                               ->method('imagePath')
-                               ->with('core', 'places/calendar.png')
-                               ->willReturn('imagePath2');
-
-                       $this->urlGenerator
-                               ->expects($this->at(8 * $i + 3))
-                               ->method('getAbsoluteURL')
-                               ->with('imagePath2')
-                               ->willReturn('AbsURL2');
-
-                       $this->urlGenerator
-                               ->expects($this->at(8 * $i + 4))
-                               ->method('imagePath')
-                               ->with('core', 'actions/address.png')
-                               ->willReturn('imagePath3');
-
-                       $this->urlGenerator
-                               ->expects($this->at(8 * $i + 5))
-                               ->method('getAbsoluteURL')
-                               ->with('imagePath3')
-                               ->willReturn('AbsURL3');
-
-                       $this->urlGenerator
-                               ->expects($this->at(8 * $i + 6))
-                               ->method('imagePath')
-                               ->with('core', 'actions/more.png')
-                               ->willReturn('imagePath4');
-
-                       $this->urlGenerator
-                               ->expects($this->at(8 * $i + 7))
-                               ->method('getAbsoluteURL')
-                               ->with('imagePath4')
-                               ->willReturn('AbsURL4');
-               }
+       private function setupURLGeneratorMock(int $times = 1): void {
+               $this->urlGenerator
+                       ->expects($this->exactly($times * 4))
+                       ->method('imagePath')
+                       ->willReturnMap([
+                               ['core', 'actions/info.png', 'imagePath1'],
+                               ['core', 'places/calendar.png', 'imagePath2'],
+                               ['core', 'actions/address.png', 'imagePath3'],
+                               ['core', 'actions/more.png', 'imagePath4'],
+                       ]);
+               $this->urlGenerator
+                       ->expects($this->exactly($times * 4))
+                       ->method('getAbsoluteURL')
+                       ->willReturnMap([
+                               ['imagePath1', 'AbsURL1'],
+                               ['imagePath2', 'AbsURL2'],
+                               ['imagePath3', 'AbsURL3'],
+                               ['imagePath4', 'AbsURL4'],
+                       ]);
        }
 
        private function getUsers(): array {
index 64020b9dbd7877f120b6d9494996267a013b8239..a0d5ebb348903cb4b471b01bed8410ce88ef9e90 100644 (file)
@@ -32,16 +32,11 @@ namespace OCA\DAV\Tests\unit\CalDAV\Reminder\NotificationProvider;
 
 use OCA\DAV\CalDAV\Reminder\NotificationProvider\PushProvider;
 use OCP\AppFramework\Utility\ITimeFactory;
-use OCP\IConfig;
-use OCP\IL10N;
-use OCP\IURLGenerator;
 use OCP\IUser;
-use OCP\L10N\IFactory as L10NFactory;
 use OCP\Notification\IManager;
 use OCP\Notification\INotification;
 
 class PushProviderTest extends AbstractNotificationProviderTest {
-
        /** @var IManager|\PHPUnit\Framework\MockObject\MockObject */
        private $manager;
 
@@ -121,28 +116,22 @@ class PushProviderTest extends AbstractNotificationProviderTest {
                $notification2 = $this->createNotificationMock('uid2', $dateTime);
                $notification3 = $this->createNotificationMock('uid3', $dateTime);
 
-               $this->manager->expects($this->at(0))
-                       ->method('createNotification')
-                       ->with()
-                       ->willReturn($notification1);
-               $this->manager->expects($this->at(2))
+               $this->manager->expects($this->exactly(3))
                        ->method('createNotification')
                        ->with()
-                       ->willReturn($notification2);
-               $this->manager->expects($this->at(4))
-                       ->method('createNotification')
-                       ->with()
-                       ->willReturn($notification3);
+                       ->willReturnOnConsecutiveCalls(
+                               $notification1,
+                               $notification2,
+                               $notification3
+                       );
 
-               $this->manager->expects($this->at(1))
-                       ->method('notify')
-                       ->with($notification1);
-               $this->manager->expects($this->at(3))
-                       ->method('notify')
-                       ->with($notification2);
-               $this->manager->expects($this->at(5))
+               $this->manager->expects($this->exactly(3))
                        ->method('notify')
-                       ->with($notification3);
+                       ->withConsecutive(
+                               [$notification1],
+                               [$notification2],
+                               [$notification3],
+                       );
 
                $this->provider->send($this->vcalendar->VEVENT, $this->calendarDisplayName, [], $users);
        }
index e2b5390f875b693c58834706676bd70dd3dc8a81..4e5413a52263ab2739ea29212525bf2990df0861 100644 (file)
@@ -353,7 +353,7 @@ EOD;
        }
 
        public function testProcessReminders():void {
-               $this->backend->expects($this->at(0))
+               $this->backend->expects($this->once())
                        ->method('getRemindersToProcess')
                        ->with()
                        ->willReturn([
@@ -449,60 +449,34 @@ EOD;
                                ]
                        ]);
 
-               $this->notificationProviderManager->expects($this->at(0))
+               $this->notificationProviderManager->expects($this->exactly(5))
                        ->method('hasProvider')
-                       ->with('EMAIL')
-                       ->willReturn(true);
+                       ->willReturnMap([
+                               ['EMAIL', true],
+                               ['DISPLAY', true],
+                       ]);
 
                $provider1 = $this->createMock(INotificationProvider::class);
-               $this->notificationProviderManager->expects($this->at(1))
-                       ->method('getProvider')
-                       ->with('EMAIL')
-                       ->willReturn($provider1);
-
-               $this->notificationProviderManager->expects($this->at(2))
-                       ->method('hasProvider')
-                       ->with('EMAIL')
-                       ->willReturn(true);
-
                $provider2 = $this->createMock(INotificationProvider::class);
-               $this->notificationProviderManager->expects($this->at(3))
-                       ->method('getProvider')
-                       ->with('EMAIL')
-                       ->willReturn($provider2);
-
-               $this->notificationProviderManager->expects($this->at(4))
-                       ->method('hasProvider')
-                       ->with('DISPLAY')
-                       ->willReturn(true);
-
                $provider3 = $this->createMock(INotificationProvider::class);
-               $this->notificationProviderManager->expects($this->at(5))
-                       ->method('getProvider')
-                       ->with('DISPLAY')
-                       ->willReturn($provider3);
-
-               $this->notificationProviderManager->expects($this->at(6))
-                       ->method('hasProvider')
-                       ->with('EMAIL')
-                       ->willReturn(true);
-
                $provider4 = $this->createMock(INotificationProvider::class);
-               $this->notificationProviderManager->expects($this->at(7))
-                       ->method('getProvider')
-                       ->with('EMAIL')
-                       ->willReturn($provider4);
-
-               $this->notificationProviderManager->expects($this->at(8))
-                       ->method('hasProvider')
-                       ->with('EMAIL')
-                       ->willReturn(true);
-
                $provider5 = $this->createMock(INotificationProvider::class);
-               $this->notificationProviderManager->expects($this->at(9))
+               $this->notificationProviderManager->expects($this->exactly(5))
                        ->method('getProvider')
-                       ->with('EMAIL')
-                       ->willReturn($provider5);
+                       ->withConsecutive(
+                               ['EMAIL'],
+                               ['EMAIL'],
+                               ['DISPLAY'],
+                               ['EMAIL'],
+                               ['EMAIL'],
+                       )
+                       ->willReturnOnConsecutiveCalls(
+                               $provider1,
+                               $provider2,
+                               $provider3,
+                               $provider4,
+                               $provider5,
+                       );
 
                $user = $this->createMock(IUser::class);
                $this->userManager->expects($this->exactly(5))
@@ -551,45 +525,19 @@ EOD;
                                return true;
                        }, 'Displayname 123', $user));
 
-               $this->backend->expects($this->at(1))
-                       ->method('removeReminder')
-                       ->with(1);
-               $this->backend->expects($this->at(2))
-                       ->method('removeReminder')
-                       ->with(2);
-               $this->backend->expects($this->at(3))
-                       ->method('removeReminder')
-                       ->with(3);
-               $this->backend->expects($this->at(4))
-                       ->method('removeReminder')
-                       ->with(4);
-               $this->backend->expects($this->at(5))
-                       ->method('insertReminder')
-                       ->with(1337, 42, 'wej2z68l9h', true, 1467849600, false, 'fbdb2726bc0f7dfacac1d881c1453e20', 'ecacbf07d413c3c78d1ac7ad8c469602', 'EMAIL', true, 1467848700, false)
-                       ->willReturn(99);
-
-               $this->backend->expects($this->at(6))
-                       ->method('insertReminder')
-                       ->with(1337, 42, 'wej2z68l9h', true, 1467849600, false, 'fbdb2726bc0f7dfacac1d881c1453e20', 'ecacbf07d413c3c78d1ac7ad8c469602', 'EMAIL', true, 1467848820, true)
-                       ->willReturn(99);
-               $this->backend->expects($this->at(7))
-                       ->method('insertReminder')
-                       ->with(1337, 42, 'wej2z68l9h', true, 1467849600, false, 'fbdb2726bc0f7dfacac1d881c1453e20', 'ecacbf07d413c3c78d1ac7ad8c469602', 'EMAIL', true, 1467848940, true)
-                       ->willReturn(99);
-               $this->backend->expects($this->at(8))
-                       ->method('insertReminder')
-                       ->with(1337, 42, 'wej2z68l9h', true, 1467849600, false, 'fbdb2726bc0f7dfacac1d881c1453e20', 'ecacbf07d413c3c78d1ac7ad8c469602', 'EMAIL', true, 1467849060, true)
-                       ->willReturn(99);
-               $this->backend->expects($this->at(9))
-                       ->method('insertReminder')
-                       ->with(1337, 42, 'wej2z68l9h', true, 1467849600, false, 'fbdb2726bc0f7dfacac1d881c1453e20', 'ecacbf07d413c3c78d1ac7ad8c469602', 'EMAIL', true, 1467849180, true)
-                       ->willReturn(99);
-               $this->backend->expects($this->at(10))
+               $this->backend->expects($this->exactly(5))
                        ->method('removeReminder')
-                       ->with(5);
-               $this->backend->expects($this->at(11))
+                       ->withConsecutive([1], [2], [3], [4], [5]);
+               $this->backend->expects($this->exactly(6))
                        ->method('insertReminder')
-                       ->with(1337, 42, 'wej2z68l9h', true, 1468454400, false, 'fbdb2726bc0f7dfacac1d881c1453e20', '8996992118817f9f311ac5cc56d1cc97', 'EMAIL', true, 1467763200, false)
+                       ->withConsecutive(
+                               [1337, 42, 'wej2z68l9h', true, 1467849600, false, 'fbdb2726bc0f7dfacac1d881c1453e20', 'ecacbf07d413c3c78d1ac7ad8c469602', 'EMAIL', true, 1467848700, false],
+                               [1337, 42, 'wej2z68l9h', true, 1467849600, false, 'fbdb2726bc0f7dfacac1d881c1453e20', 'ecacbf07d413c3c78d1ac7ad8c469602', 'EMAIL', true, 1467848820, true],
+                               [1337, 42, 'wej2z68l9h', true, 1467849600, false, 'fbdb2726bc0f7dfacac1d881c1453e20', 'ecacbf07d413c3c78d1ac7ad8c469602', 'EMAIL', true, 1467848940, true],
+                               [1337, 42, 'wej2z68l9h', true, 1467849600, false, 'fbdb2726bc0f7dfacac1d881c1453e20', 'ecacbf07d413c3c78d1ac7ad8c469602', 'EMAIL', true, 1467849060, true],
+                               [1337, 42, 'wej2z68l9h', true, 1467849600, false, 'fbdb2726bc0f7dfacac1d881c1453e20', 'ecacbf07d413c3c78d1ac7ad8c469602', 'EMAIL', true, 1467849180, true],
+                               [1337, 42, 'wej2z68l9h', true, 1468454400, false, 'fbdb2726bc0f7dfacac1d881c1453e20', '8996992118817f9f311ac5cc56d1cc97', 'EMAIL', true, 1467763200, false],
+                       )
                        ->willReturn(99);
 
                $this->timeFactory->method('getDateTime')
index 0fffbc2cd10703d5d87a65387e5647ed0107ba5f..0c86a9c5a2917ae0ddb78cd453d2cbbdf56bc310 100644 (file)
@@ -35,7 +35,6 @@ use Sabre\DAV\PropPatch;
 use Test\TestCase;
 
 abstract class AbstractPrincipalBackendTest extends TestCase {
-
        /** @var \OCA\DAV\CalDAV\ResourceBooking\ResourcePrincipalBackend|\OCA\DAV\CalDAV\ResourceBooking\RoomPrincipalBackend */
        protected $principalBackend;
 
@@ -228,43 +227,43 @@ abstract class AbstractPrincipalBackendTest extends TestCase {
        }
 
        public function testSetGroupMemberSet() {
-               $this->proxyMapper->expects($this->at(0))
+               $this->proxyMapper->expects($this->once())
                        ->method('getProxiesOf')
                        ->with($this->principalPrefix . '/backend1-res1')
                        ->willReturn([]);
 
-               $this->proxyMapper->expects($this->at(1))
-                       ->method('insert')
-                       ->with($this->callback(function ($proxy) {
-                               /** @var Proxy $proxy */
-                               if ($proxy->getOwnerId() !== $this->principalPrefix . '/backend1-res1') {
-                                       return false;
-                               }
-                               if ($proxy->getProxyId() !== $this->principalPrefix . '/backend1-res2') {
-                                       return false;
-                               }
-                               if ($proxy->getPermissions() !== 3) {
-                                       return false;
-                               }
-
-                               return true;
-                       }));
-               $this->proxyMapper->expects($this->at(2))
+               $this->proxyMapper->expects($this->exactly(2))
                        ->method('insert')
-                       ->with($this->callback(function ($proxy) {
-                               /** @var Proxy $proxy */
-                               if ($proxy->getOwnerId() !== $this->principalPrefix . '/backend1-res1') {
-                                       return false;
-                               }
-                               if ($proxy->getProxyId() !== $this->principalPrefix . '/backend2-res3') {
-                                       return false;
-                               }
-                               if ($proxy->getPermissions() !== 3) {
-                                       return false;
-                               }
-
-                               return true;
-                       }));
+                       ->withConsecutive(
+                               [$this->callback(function ($proxy) {
+                                       /** @var Proxy $proxy */
+                                       if ($proxy->getOwnerId() !== $this->principalPrefix . '/backend1-res1') {
+                                               return false;
+                                       }
+                                       if ($proxy->getProxyId() !== $this->principalPrefix . '/backend1-res2') {
+                                               return false;
+                                       }
+                                       if ($proxy->getPermissions() !== 3) {
+                                               return false;
+                                       }
+
+                                       return true;
+                               })],
+                               [$this->callback(function ($proxy) {
+                                       /** @var Proxy $proxy */
+                                       if ($proxy->getOwnerId() !== $this->principalPrefix . '/backend1-res1') {
+                                               return false;
+                                       }
+                                       if ($proxy->getProxyId() !== $this->principalPrefix . '/backend2-res3') {
+                                               return false;
+                                       }
+                                       if ($proxy->getPermissions() !== 3) {
+                                               return false;
+                                       }
+
+                                       return true;
+                               })],
+                       );
 
                $this->principalBackend->setGroupMemberSet($this->principalPrefix . '/backend1-res1/calendar-proxy-write', [$this->principalPrefix . '/backend1-res2', $this->principalPrefix . '/backend2-res3']);
        }
index 0b64704a87e0916180b6442ddfcd7cf8f906c21b..597047efb940276f0c91a4c9e661cd50d992111f 100644 (file)
@@ -37,7 +37,6 @@ use OCP\IConfig;
 use OCP\IDBConnection;
 use OCP\IL10N;
 use OCP\IURLGenerator;
-use OCP\IUser;
 use OCP\IUserManager;
 use OCP\L10N\IFactory;
 use OCP\Mail\IAttachment;
@@ -52,8 +51,7 @@ use Sabre\VObject\ITip\Message;
 use Test\TestCase;
 
 class IMipPluginTest extends TestCase {
-
-               /** @var IMessage|MockObject */
+       /** @var IMessage|MockObject */
        private $mailMessage;
 
        /** @var IMailer|MockObject */
@@ -135,10 +133,11 @@ class IMipPluginTest extends TestCase {
 
        public function testDelivery() {
                $this->config
-         ->expects($this->at(1))
+                       ->expects($this->any())
                        ->method('getAppValue')
-                       ->with('dav', 'invitation_link_recipients', 'yes')
-                       ->willReturn('yes');
+                       ->willReturnMap([
+                               ['dav', 'invitation_link_recipients', 'yes', 'yes'],
+                       ]);
                $this->mailer->method('validateMailAddress')->willReturn(true);
 
                $message = $this->_testMessage();
@@ -149,10 +148,11 @@ class IMipPluginTest extends TestCase {
 
        public function testFailedDelivery() {
                $this->config
-         ->expects($this->at(1))
+                       ->expects($this->any())
                        ->method('getAppValue')
-                       ->with('dav', 'invitation_link_recipients', 'yes')
-                       ->willReturn('yes');
+                       ->willReturnMap([
+                               ['dav', 'invitation_link_recipients', 'yes', 'yes'],
+                       ]);
                $this->mailer->method('validateMailAddress')->willReturn(true);
 
                $message = $this->_testMessage();
@@ -174,10 +174,11 @@ class IMipPluginTest extends TestCase {
 
        public function testDeliveryWithNoCommonName() {
                $this->config
-         ->expects($this->at(1))
+                       ->expects($this->any())
                        ->method('getAppValue')
-                       ->with('dav', 'invitation_link_recipients', 'yes')
-                       ->willReturn('yes');
+                       ->willReturnMap([
+                               ['dav', 'invitation_link_recipients', 'yes', 'yes'],
+                       ]);
                $this->mailer->method('validateMailAddress')->willReturn(true);
 
                $message = $this->_testMessage();
@@ -198,8 +199,8 @@ class IMipPluginTest extends TestCase {
         */
        public function testNoMessageSendForPastEvents(array $veventParams, bool $expectsMail) {
                $this->config
-         ->method('getAppValue')
-         ->willReturn('yes');
+                       ->method('getAppValue')
+                       ->willReturn('yes');
                $this->mailer->method('validateMailAddress')->willReturn(true);
 
                $message = $this->_testMessage($veventParams);
@@ -234,15 +235,16 @@ class IMipPluginTest extends TestCase {
         * @dataProvider dataIncludeResponseButtons
         */
        public function testIncludeResponseButtons(string $config_setting, string $recipient, bool $has_buttons) {
-               $message = $this->_testMessage([],$recipient);
+               $message = $this->_testMessage([], $recipient);
                $this->mailer->method('validateMailAddress')->willReturn(true);
 
                $this->_expectSend($recipient, true, $has_buttons);
                $this->config
-         ->expects($this->at(1))
+                       ->expects($this->any())
                        ->method('getAppValue')
-                       ->with('dav', 'invitation_link_recipients', 'yes')
-                       ->willReturn($config_setting);
+                       ->willReturnMap([
+                               ['dav', 'invitation_link_recipients', 'yes', $config_setting],
+                       ]);
 
                $this->plugin->schedule($message);
                $this->assertEquals('1.1', $message->getScheduleStatus());
@@ -268,7 +270,7 @@ class IMipPluginTest extends TestCase {
                $this->mailer->method('validateMailAddress')->willReturn(true);
 
                $message = $this->_testMessage(['SUMMARY' => '']);
-               $this->_expectSend('frodo@hobb.it', true, true,'Invitation: Untitled event');
+               $this->_expectSend('frodo@hobb.it', true, true, 'Invitation: Untitled event');
                $this->emailTemplate->expects($this->once())
                        ->method('addHeading')
                        ->with('Invitation');
@@ -296,7 +298,6 @@ class IMipPluginTest extends TestCase {
 
 
        private function _expectSend(string $recipient = 'frodo@hobb.it', bool $expectSend = true, bool $expectButtons = true, string $subject = 'Invitation: Fellowship meeting') {
-
                // if the event is in the past, we skip out
                if (!$expectSend) {
                        $this->mailer
@@ -322,14 +323,14 @@ class IMipPluginTest extends TestCase {
                        ->method('send');
 
                if ($expectButtons) {
-                       $this->queryBuilder->expects($this->at(0))
+                       $this->queryBuilder->expects($this->once())
                                ->method('insert')
                                ->with('calendar_invitations')
                                ->willReturn($this->queryBuilder);
-                       $this->queryBuilder->expects($this->at(8))
+                       $this->queryBuilder->expects($this->once())
                                ->method('values')
                                ->willReturn($this->queryBuilder);
-                       $this->queryBuilder->expects($this->at(9))
+                       $this->queryBuilder->expects($this->once())
                                ->method('execute');
                } else {
                        $this->queryBuilder->expects($this->never())
index 811550390156bb5a2888829759e1cbf87fa582dc..d5a1a6be31d3d9a3e2a3c9855816c53da40aa3ee 100644 (file)
@@ -61,7 +61,7 @@ class SearchPluginTest extends TestCase {
 
                $plugin = new SearchPlugin();
 
-               $server->expects($this->at(0))
+               $server->expects($this->once())
                        ->method('on')
                        ->with('report', [$plugin, 'report']);
                $server->xml = new Service();
@@ -84,15 +84,15 @@ class SearchPluginTest extends TestCase {
                $report = $this->createMock(CalendarSearchReport::class);
                $report->filters = [];
                $calendarHome = $this->createMock(CalendarHome::class);
-               $this->server->expects($this->at(0))
+               $this->server->expects($this->once())
                        ->method('getRequestUri')
                        ->with()
                        ->willReturn('/re/quest/u/r/i');
-               $this->server->tree->expects($this->at(0))
+               $this->server->tree->expects($this->once())
                        ->method('getNodeForPath')
                        ->with('/re/quest/u/r/i')
                        ->willReturn($calendarHome);
-               $this->server->expects($this->at(1))
+               $this->server->expects($this->once())
                        ->method('getHTTPDepth')
                        ->with(2)
                        ->willReturn(2);
@@ -101,7 +101,7 @@ class SearchPluginTest extends TestCase {
                        ->willReturn([
                                'return' => null
                        ]);
-               $calendarHome->expects($this->at(0))
+               $calendarHome->expects($this->once())
                        ->method('calendarSearch')
                        ->willReturn([]);
 
index 310d266cd575f4267fdffdf1d633d1e552558585..441e83ccc970e3d83a48dc0bf859900ed125b30e 100644 (file)
@@ -29,12 +29,12 @@ use OCP\IRequest;
 class PluginTest extends \Test\TestCase {
        public function testDisabled() {
                $request = $this->createMock(IRequest::class);
-               $request->expects($this->at(0))
+               $request->expects($this->once())
                        ->method('isUserAgent')
                        ->with(Plugin::ENABLE_FOR_CLIENTS)
                        ->willReturn(false);
 
-               $request->expects($this->at(1))
+               $request->expects($this->once())
                        ->method('getHeader')
                        ->with('X-NC-CalDAV-Webcal-Caching')
                        ->willReturn('');
@@ -46,12 +46,12 @@ class PluginTest extends \Test\TestCase {
 
        public function testEnabled() {
                $request = $this->createMock(IRequest::class);
-               $request->expects($this->at(0))
+               $request->expects($this->once())
                        ->method('isUserAgent')
                        ->with(Plugin::ENABLE_FOR_CLIENTS)
                        ->willReturn(false);
 
-               $request->expects($this->at(1))
+               $request->expects($this->once())
                        ->method('getHeader')
                        ->with('X-NC-CalDAV-Webcal-Caching')
                        ->willReturn('On');
index eb87901f3acf30acaba06ea7952de267f65d81c1..9ee17b8d19bb824892b69027605068da9dc9d97e 100644 (file)
@@ -40,7 +40,6 @@ use Sabre\VObject\Property\Text;
 use Test\TestCase;
 
 class AddressBookImplTest extends TestCase {
-
        /** @var AddressBookImpl  */
        private $addressBookImpl;
 
@@ -94,7 +93,6 @@ class AddressBookImplTest extends TestCase {
        }
 
        public function testSearch() {
-
                /** @var \PHPUnit\Framework\MockObject\MockObject | AddressBookImpl $addressBookImpl */
                $addressBookImpl = $this->getMockBuilder(AddressBookImpl::class)
                        ->setConstructorArgs(
@@ -226,7 +224,7 @@ class AddressBookImplTest extends TestCase {
                $uri = 'bla.vcf';
                $properties = ['URI' => $uri, 'UID' => $uid, 'FN' => 'John Doe', 'ADR' => [['type' => 'HOME', 'value' => ';;street;city;;;country']]];
                $vCard = new vCard;
-               $textProperty = $vCard->createProperty('KEY','value');
+               $textProperty = $vCard->createProperty('KEY', 'value');
 
                /** @var \PHPUnit\Framework\MockObject\MockObject | AddressBookImpl $addressBookImpl */
                $addressBookImpl = $this->getMockBuilder(AddressBookImpl::class)
@@ -322,8 +320,12 @@ class AddressBookImplTest extends TestCase {
                        ->setMethods(['getUid'])
                        ->getMock();
 
-               $addressBookImpl->expects($this->at(0))->method('getUid')->willReturn('uid0');
-               $addressBookImpl->expects($this->at(1))->method('getUid')->willReturn('uid1');
+               $addressBookImpl->expects($this->exactly(2))
+                       ->method('getUid')
+                       ->willReturnOnConsecutiveCalls(
+                               'uid0',
+                               'uid1',
+                       );
 
                // simulate that 'uid0' already exists, so the second uid will be returned
                $this->backend->expects($this->exactly(2))->method('getContact')
index c1292cbace28ffac0954393f435d69c17c98d78e..23d104abe8b3b48c24383594c0ee7b3d254f19ad 100644 (file)
@@ -34,12 +34,10 @@ use OCP\IConfig;
 use OCP\IDBConnection;
 use OCP\IL10N;
 use Sabre\VObject\Component\VCalendar;
-use Sabre\VObject\Property\ICalendar\Duration;
 use Sabre\VObject\Reader;
 use Test\TestCase;
 
 class BirthdayServiceTest extends TestCase {
-
        /** @var BirthdayService */
        private $service;
        /** @var CalDavBackend | \PHPUnit\Framework\MockObject\MockObject */
@@ -71,7 +69,7 @@ class BirthdayServiceTest extends TestCase {
                                return vsprintf($string, $args);
                        });
 
-               $this->service = new BirthdayService($this->calDav,$this->cardDav,
+               $this->service = new BirthdayService($this->calDav, $this->cardDav,
                        $this->groupPrincipalBackend, $this->config,
                        $this->dbConnection, $this->l10n);
        }
@@ -172,9 +170,13 @@ class BirthdayServiceTest extends TestCase {
                        ->willReturn([
                                'id' => 1234
                        ]);
-               $this->calDav->expects($this->at(1))->method('deleteCalendarObject')->with(1234, 'default-gump.vcf.ics');
-               $this->calDav->expects($this->at(2))->method('deleteCalendarObject')->with(1234, 'default-gump.vcf-death.ics');
-               $this->calDav->expects($this->at(3))->method('deleteCalendarObject')->with(1234, 'default-gump.vcf-anniversary.ics');
+               $this->calDav->expects($this->exactly(3))
+                       ->method('deleteCalendarObject')
+                       ->withConsecutive(
+                               [1234, 'default-gump.vcf.ics'],
+                               [1234, 'default-gump.vcf-death.ics'],
+                               [1234, 'default-gump.vcf-anniversary.ics'],
+                       );
                $this->cardDav->expects($this->once())->method('getShares')->willReturn([]);
 
                $this->service->onCardDeleted(666, 'gump.vcf');
@@ -279,7 +281,7 @@ class BirthdayServiceTest extends TestCase {
                                [1234, 'default-gump.vcf.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nCALSCALE:GREGORIAN\r\nPRODID:-//Nextcloud testing//mocked object//\r\nEND:VCALENDAR\r\n"],
                                [1234, 'default-gump.vcf-death.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nCALSCALE:GREGORIAN\r\nPRODID:-//Nextcloud testing//mocked object//\r\nEND:VCALENDAR\r\n"],
                                [1234, 'default-gump.vcf-anniversary.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nCALSCALE:GREGORIAN\r\nPRODID:-//Nextcloud testing//mocked object//\r\nEND:VCALENDAR\r\n"]
-                               );
+                       );
                }
                if ($expectedOp === 'update') {
                        $vCal = new VCalendar();
@@ -292,7 +294,7 @@ class BirthdayServiceTest extends TestCase {
                                [1234, 'default-gump.vcf.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nCALSCALE:GREGORIAN\r\nPRODID:-//Nextcloud testing//mocked object//\r\nEND:VCALENDAR\r\n"],
                                [1234, 'default-gump.vcf-death.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nCALSCALE:GREGORIAN\r\nPRODID:-//Nextcloud testing//mocked object//\r\nEND:VCALENDAR\r\n"],
                                [1234, 'default-gump.vcf-anniversary.ics', "BEGIN:VCALENDAR\r\nVERSION:2.0\r\nCALSCALE:GREGORIAN\r\nPRODID:-//Nextcloud testing//mocked object//\r\nEND:VCALENDAR\r\n"]
-                               );
+                       );
                }
 
                $service->onCardChanged(666, 'gump.vcf', '');
@@ -360,27 +362,23 @@ class BirthdayServiceTest extends TestCase {
        }
 
        public function testResetForUser() {
-               $this->calDav->expects($this->at(0))
+               $this->calDav->expects($this->once())
                        ->method('getCalendarByUri')
                        ->with('principals/users/user123', 'contact_birthdays')
                        ->willReturn(['id' => 42]);
 
-               $this->calDav->expects($this->at(1))
+               $this->calDav->expects($this->once())
                        ->method('getCalendarObjects')
                        ->with(42, 0)
                        ->willReturn([['uri' => '1.ics'], ['uri' => '2.ics'], ['uri' => '3.ics']]);
 
-               $this->calDav->expects($this->at(2))
-                       ->method('deleteCalendarObject')
-                       ->with(42, '1.ics', 0);
-
-               $this->calDav->expects($this->at(3))
+               $this->calDav->expects($this->exactly(3))
                        ->method('deleteCalendarObject')
-                       ->with(42, '2.ics', 0);
-
-               $this->calDav->expects($this->at(4))
-                       ->method('deleteCalendarObject')
-                       ->with(42, '3.ics', 0);
+                       ->withConsecutive(
+                               [42, '1.ics', 0],
+                               [42, '2.ics', 0],
+                               [42, '3.ics', 0],
+                       );
 
                $this->service->resetForUser('user123');
        }
index 93901b1074019c5a5b19c7b85e83d4aae501d295..fdcc0ad0c091c8aa1be966be7d5cd9c513d7d902 100644 (file)
@@ -64,7 +64,6 @@ use Test\TestCase;
  * @package OCA\DAV\Tests\unit\CardDAV
  */
 class CardDavBackendTest extends TestCase {
-
        /** @var CardDavBackend */
        private $backend;
 
@@ -183,7 +182,6 @@ class CardDavBackendTest extends TestCase {
        }
 
        public function testAddressBookOperations() {
-
                // create a new address book
                $this->backend->createAddressBook(self::UNIT_TEST_USER, 'Example', []);
 
@@ -243,7 +241,6 @@ class CardDavBackendTest extends TestCase {
        }
 
        public function testCardOperations() {
-
                /** @var CardDavBackend | \PHPUnit\Framework\MockObject\MockObject $backend */
                $backend = $this->getMockBuilder(CardDavBackend::class)
                                ->setConstructorArgs([$this->db, $this->principal, $this->userManager, $this->groupManager, $this->dispatcher])
@@ -257,8 +254,12 @@ class CardDavBackendTest extends TestCase {
 
                $uri = $this->getUniqueID('card');
                // updateProperties is expected twice, once for createCard and once for updateCard
-               $backend->expects($this->at(0))->method('updateProperties')->with($bookId, $uri, $this->vcardTest0);
-               $backend->expects($this->at(1))->method('updateProperties')->with($bookId, $uri, $this->vcardTest1);
+               $backend->expects($this->exactly(2))
+                       ->method('updateProperties')
+                       ->withConsecutive(
+                               [$bookId, $uri, $this->vcardTest0],
+                               [$bookId, $uri, $this->vcardTest1],
+                       );
 
                // Expect event
                $this->dispatcher
@@ -666,14 +667,14 @@ class CardDavBackendTest extends TestCase {
                for ($i = 0; $i < 3; $i++) {
                        $query->insert($this->dbCardsTable)
                                        ->values(
-                                                       [
-                                                               'addressbookid' => $query->createNamedParameter(0),
-                                                               'carddata' => $query->createNamedParameter($vCards[$i]->serialize(), IQueryBuilder::PARAM_LOB),
-                                                               'uri' => $query->createNamedParameter('uri' . $i),
-                                                               'lastmodified' => $query->createNamedParameter(time()),
-                                                               'etag' => $query->createNamedParameter('etag' . $i),
-                                                               'size' => $query->createNamedParameter(120),
-                                                       ]
+                                               [
+                                                       'addressbookid' => $query->createNamedParameter(0),
+                                                       'carddata' => $query->createNamedParameter($vCards[$i]->serialize(), IQueryBuilder::PARAM_LOB),
+                                                       'uri' => $query->createNamedParameter('uri' . $i),
+                                                       'lastmodified' => $query->createNamedParameter(time()),
+                                                       'etag' => $query->createNamedParameter('etag' . $i),
+                                                       'size' => $query->createNamedParameter(120),
+                                               ]
                                        );
                        $query->execute();
                        $vCardIds[] = $query->getLastInsertId();
@@ -770,14 +771,14 @@ class CardDavBackendTest extends TestCase {
                $query = $this->db->getQueryBuilder();
                $query->insert($this->dbCardsTable)
                                ->values(
-                                               [
-                                                       'addressbookid' => $query->createNamedParameter(1),
-                                                       'carddata' => $query->createNamedParameter('carddata', IQueryBuilder::PARAM_LOB),
-                                                       'uri' => $query->createNamedParameter('uri'),
-                                                       'lastmodified' => $query->createNamedParameter(5489543),
-                                                       'etag' => $query->createNamedParameter('etag'),
-                                                       'size' => $query->createNamedParameter(120),
-                                               ]
+                                       [
+                                               'addressbookid' => $query->createNamedParameter(1),
+                                               'carddata' => $query->createNamedParameter('carddata', IQueryBuilder::PARAM_LOB),
+                                               'uri' => $query->createNamedParameter('uri'),
+                                               'lastmodified' => $query->createNamedParameter(5489543),
+                                               'etag' => $query->createNamedParameter('etag'),
+                                               'size' => $query->createNamedParameter(120),
+                                       ]
                                );
                $query->execute();
 
@@ -798,14 +799,14 @@ class CardDavBackendTest extends TestCase {
                for ($i = 0; $i < 2; $i++) {
                        $query->insert($this->dbCardsTable)
                                        ->values(
-                                                       [
-                                                               'addressbookid' => $query->createNamedParameter($i),
-                                                               'carddata' => $query->createNamedParameter('carddata' . $i, IQueryBuilder::PARAM_LOB),
-                                                               'uri' => $query->createNamedParameter('uri' . $i),
-                                                               'lastmodified' => $query->createNamedParameter(5489543),
-                                                               'etag' => $query->createNamedParameter('etag' . $i),
-                                                               'size' => $query->createNamedParameter(120),
-                                                       ]
+                                               [
+                                                       'addressbookid' => $query->createNamedParameter($i),
+                                                       'carddata' => $query->createNamedParameter('carddata' . $i, IQueryBuilder::PARAM_LOB),
+                                                       'uri' => $query->createNamedParameter('uri' . $i),
+                                                       'lastmodified' => $query->createNamedParameter(5489543),
+                                                       'etag' => $query->createNamedParameter('etag' . $i),
+                                                       'size' => $query->createNamedParameter(120),
+                                               ]
                                        );
                        $query->execute();
                }
index ed5ec544fb686d52af8495e3a5afc8961cfdad1c..56a0681f011c40e234c98b8bd12d37726ea48d2c 100644 (file)
@@ -39,7 +39,6 @@ use Sabre\HTTP\ResponseInterface;
 use Test\TestCase;
 
 class ImageExportPluginTest extends TestCase {
-
        /** @var ResponseInterface|\PHPUnit\Framework\MockObject\MockObject */
        private $response;
        /** @var RequestInterface|\PHPUnit\Framework\MockObject\MockObject */
@@ -150,16 +149,6 @@ class ImageExportPluginTest extends TestCase {
                                $this->fail();
                        });
 
-               $this->response->expects($this->at(0))
-                       ->method('setHeader')
-                       ->with('Cache-Control', 'private, max-age=3600, must-revalidate');
-               $this->response->expects($this->at(1))
-                       ->method('setHeader')
-                       ->with('Etag', '"myEtag"');
-               $this->response->expects($this->at(2))
-                       ->method('setHeader')
-                       ->with('Pragma', 'public');
-
                $size = $size === null ? -1 : $size;
 
                if ($photo) {
@@ -173,12 +162,15 @@ class ImageExportPluginTest extends TestCase {
                                ->with(1, 'card', $size, $card)
                                ->willReturn($file);
 
-                       $this->response->expects($this->at(3))
+                       $this->response->expects($this->exactly(5))
                                ->method('setHeader')
-                               ->with('Content-Type', 'image/jpeg');
-                       $this->response->expects($this->at(4))
-                               ->method('setHeader')
-                               ->with('Content-Disposition', 'attachment; filename=card.jpg');
+                               ->withConsecutive(
+                                       ['Cache-Control', 'private, max-age=3600, must-revalidate'],
+                                       ['Etag', '"myEtag"'],
+                                       ['Pragma', 'public'],
+                                       ['Content-Type', 'image/jpeg'],
+                                       ['Content-Disposition', 'attachment; filename=card.jpg'],
+                               );
 
                        $this->response->expects($this->once())
                                ->method('setStatus')
@@ -187,6 +179,13 @@ class ImageExportPluginTest extends TestCase {
                                ->method('setBody')
                                ->with('imgdata');
                } else {
+                       $this->response->expects($this->exactly(3))
+                               ->method('setHeader')
+                               ->withConsecutive(
+                                       ['Cache-Control', 'private, max-age=3600, must-revalidate'],
+                                       ['Etag', '"myEtag"'],
+                                       ['Pragma', 'public'],
+                               );
                        $this->cache->method('get')
                                ->with(1, 'card', $size, $card)
                                ->willThrowException(new NotFoundException());
index 58af8a64d0b4eea1ed010ef7f958d25bb9e7eee1..f1135b952572047594cd1b0d34b85694c92ca9cb 100644 (file)
@@ -75,8 +75,12 @@ class SyncServiceTest extends TestCase {
                /** @var CardDavBackend | \PHPUnit\Framework\MockObject\MockObject $backend */
                $backend = $this->getMockBuilder(CardDavBackend::class)->disableOriginalConstructor()->getMock();
                $backend->expects($this->exactly(1))->method('createAddressBook');
-               $backend->expects($this->at(0))->method('getAddressBooksByUri')->willReturn(null);
-               $backend->expects($this->at(1))->method('getAddressBooksByUri')->willReturn([]);
+               $backend->expects($this->exactly(2))
+                       ->method('getAddressBooksByUri')
+                       ->willReturnOnConsecutiveCalls(
+                               null,
+                               [],
+                       );
 
                /** @var IUserManager $userManager */
                $userManager = $this->getMockBuilder(IUserManager::class)->disableOriginalConstructor()->getMock();
index 5a858e140ac7e27baf16b1da5e331e489f7ac02c..3dbc56db359f91dfb73fc41f7e44dc0a009ef2ff 100644 (file)
@@ -45,7 +45,6 @@ use Test\TestCase;
  * @package OCA\DAV\Tests\Command
  */
 class MoveCalendarTest extends TestCase {
-
        /** @var \OCP\IUserManager|MockObject $userManager */
        private $userManager;
 
@@ -108,17 +107,16 @@ class MoveCalendarTest extends TestCase {
        public function testWithBadUserOrigin($userOriginExists, $userDestinationExists) {
                $this->expectException(\InvalidArgumentException::class);
 
-               $this->userManager->expects($this->at(0))
+               $this->userManager->expects($this->exactly($userOriginExists ? 2 : 1))
                        ->method('userExists')
-                       ->with('user')
-                       ->willReturn($userOriginExists);
-
-               if (!$userDestinationExists) {
-                       $this->userManager->expects($this->at(1))
-                               ->method('userExists')
-                               ->with('user2')
-                               ->willReturn($userDestinationExists);
-               }
+                       ->withConsecutive(
+                               ['user'],
+                               ['user2'],
+                       )
+                       ->willReturnOnConsecutiveCalls(
+                               $userOriginExists,
+                               $userDestinationExists,
+                       );
 
                $commandTester = new CommandTester($this->command);
                $commandTester->execute([
@@ -133,14 +131,12 @@ class MoveCalendarTest extends TestCase {
                $this->expectException(\InvalidArgumentException::class);
                $this->expectExceptionMessage('User <user> has no calendar named <personal>. You can run occ dav:list-calendars to list calendars URIs for this user.');
 
-               $this->userManager->expects($this->at(0))
-                       ->method('userExists')
-                       ->with('user')
-                       ->willReturn(true);
-
-               $this->userManager->expects($this->at(1))
+               $this->userManager->expects($this->exactly(2))
                        ->method('userExists')
-                       ->with('user2')
+                       ->withConsecutive(
+                               ['user'],
+                               ['user2'],
+                       )
                        ->willReturn(true);
 
                $this->calDav->expects($this->once())->method('getCalendarByUri')
@@ -160,24 +156,20 @@ class MoveCalendarTest extends TestCase {
                $this->expectException(\InvalidArgumentException::class);
                $this->expectExceptionMessage('User <user2> already has a calendar named <personal>.');
 
-               $this->userManager->expects($this->at(0))
+               $this->userManager->expects($this->exactly(2))
                        ->method('userExists')
-                       ->with('user')
+                       ->withConsecutive(
+                               ['user'],
+                               ['user2'],
+                       )
                        ->willReturn(true);
 
-               $this->userManager->expects($this->at(1))
-                       ->method('userExists')
-                       ->with('user2')
-                       ->willReturn(true);
-
-               $this->calDav->expects($this->at(0))->method('getCalendarByUri')
-                       ->with('principals/users/user', 'personal')
-                       ->willReturn([
-                               'id' => 1234,
-                       ]);
-
-               $this->calDav->expects($this->at(1))->method('getCalendarByUri')
-                       ->with('principals/users/user2', 'personal')
+               $this->calDav->expects($this->exactly(2))
+                       ->method('getCalendarByUri')
+                       ->withConsecutive(
+                               ['principals/users/user', 'personal'],
+                               ['principals/users/user2', 'personal'],
+                       )
                        ->willReturn([
                                'id' => 1234,
                        ]);
@@ -191,25 +183,26 @@ class MoveCalendarTest extends TestCase {
        }
 
        public function testMove() {
-               $this->userManager->expects($this->at(0))
+               $this->userManager->expects($this->exactly(2))
                        ->method('userExists')
-                       ->with('user')
+                       ->withConsecutive(
+                               ['user'],
+                               ['user2'],
+                       )
                        ->willReturn(true);
 
-               $this->userManager->expects($this->at(1))
-                       ->method('userExists')
-                       ->with('user2')
-                       ->willReturn(true);
-
-               $this->calDav->expects($this->at(0))->method('getCalendarByUri')
-                       ->with('principals/users/user', 'personal')
-                       ->willReturn([
-                               'id' => 1234,
-                       ]);
-
-               $this->calDav->expects($this->at(1))->method('getCalendarByUri')
-                       ->with('principals/users/user2', 'personal')
-                       ->willReturn(null);
+               $this->calDav->expects($this->exactly(2))
+                       ->method('getCalendarByUri')
+                       ->withConsecutive(
+                               ['principals/users/user', 'personal'],
+                               ['principals/users/user2', 'personal'],
+                       )
+                       ->willReturnOnConsecutiveCalls(
+                               [
+                                       'id' => 1234,
+                               ],
+                               null,
+                       );
 
                $this->calDav->expects($this->once())->method('getShares')
                        ->with(1234)
@@ -236,26 +229,27 @@ class MoveCalendarTest extends TestCase {
         * @dataProvider dataTestMoveWithDestinationNotPartOfGroup
         */
        public function testMoveWithDestinationNotPartOfGroup(bool $shareWithGroupMembersOnly) {
-               $this->userManager->expects($this->at(0))
-                       ->method('userExists')
-                       ->with('user')
-                       ->willReturn(true);
-
-               $this->userManager->expects($this->at(1))
+               $this->userManager->expects($this->exactly(2))
                        ->method('userExists')
-                       ->with('user2')
+                       ->withConsecutive(
+                               ['user'],
+                               ['user2'],
+                       )
                        ->willReturn(true);
 
-               $this->calDav->expects($this->at(0))->method('getCalendarByUri')
-                       ->with('principals/users/user', 'personal')
-                       ->willReturn([
-                               'id' => 1234,
-                               'uri' => 'personal'
-                       ]);
-
-               $this->calDav->expects($this->at(1))->method('getCalendarByUri')
-                       ->with('principals/users/user2', 'personal')
-                       ->willReturn(null);
+               $this->calDav->expects($this->exactly(2))
+                       ->method('getCalendarByUri')
+                       ->withConsecutive(
+                               ['principals/users/user', 'personal'],
+                               ['principals/users/user2', 'personal'],
+                       )
+                       ->willReturnOnConsecutiveCalls(
+                               [
+                                       'id' => 1234,
+                                       'uri' => 'personal',
+                               ],
+                               null,
+                       );
 
                $this->shareManager->expects($this->once())->method('shareWithGroupMembersOnly')
                        ->willReturn($shareWithGroupMembersOnly);
@@ -279,26 +273,27 @@ class MoveCalendarTest extends TestCase {
        }
 
        public function testMoveWithDestinationPartOfGroup() {
-               $this->userManager->expects($this->at(0))
+               $this->userManager->expects($this->exactly(2))
                        ->method('userExists')
-                       ->with('user')
+                       ->withConsecutive(
+                               ['user'],
+                               ['user2'],
+                       )
                        ->willReturn(true);
 
-               $this->userManager->expects($this->at(1))
-                       ->method('userExists')
-                       ->with('user2')
-                       ->willReturn(true);
-
-               $this->calDav->expects($this->at(0))->method('getCalendarByUri')
-                       ->with('principals/users/user', 'personal')
-                       ->willReturn([
-                               'id' => 1234,
-                               'uri' => 'personal'
-                       ]);
-
-               $this->calDav->expects($this->at(1))->method('getCalendarByUri')
-                       ->with('principals/users/user2', 'personal')
-                       ->willReturn(null);
+               $this->calDav->expects($this->exactly(2))
+                       ->method('getCalendarByUri')
+                       ->withConsecutive(
+                               ['principals/users/user', 'personal'],
+                               ['principals/users/user2', 'personal'],
+                       )
+                       ->willReturnOnConsecutiveCalls(
+                               [
+                                       'id' => 1234,
+                                       'uri' => 'personal',
+                               ],
+                               null,
+                       );
 
                $this->shareManager->expects($this->once())->method('shareWithGroupMembersOnly')
                        ->willReturn(true);
@@ -324,27 +319,28 @@ class MoveCalendarTest extends TestCase {
        }
 
        public function testMoveWithDestinationNotPartOfGroupAndForce() {
-               $this->userManager->expects($this->at(0))
-                       ->method('userExists')
-                       ->with('user')
-                       ->willReturn(true);
-
-               $this->userManager->expects($this->at(1))
+               $this->userManager->expects($this->exactly(2))
                        ->method('userExists')
-                       ->with('user2')
+                       ->withConsecutive(
+                               ['user'],
+                               ['user2'],
+                       )
                        ->willReturn(true);
 
-               $this->calDav->expects($this->at(0))->method('getCalendarByUri')
-                       ->with('principals/users/user', 'personal')
-                       ->willReturn([
-                               'id' => 1234,
-                               'uri' => 'personal',
-                               '{DAV:}displayname' => 'Personal'
-                       ]);
-
-               $this->calDav->expects($this->at(1))->method('getCalendarByUri')
-                       ->with('principals/users/user2', 'personal')
-                       ->willReturn(null);
+               $this->calDav->expects($this->exactly(2))
+                       ->method('getCalendarByUri')
+                       ->withConsecutive(
+                               ['principals/users/user', 'personal'],
+                               ['principals/users/user2', 'personal'],
+                       )
+                       ->willReturnOnConsecutiveCalls(
+                               [
+                                       'id' => 1234,
+                                       'uri' => 'personal',
+                                       '{DAV:}displayname' => 'Personal'
+                               ],
+                               null,
+                       );
 
                $this->shareManager->expects($this->once())->method('shareWithGroupMembersOnly')
                        ->willReturn(true);
@@ -381,27 +377,28 @@ class MoveCalendarTest extends TestCase {
         * @dataProvider dataTestMoveWithCalendarAlreadySharedToDestination
         */
        public function testMoveWithCalendarAlreadySharedToDestination(bool $force) {
-               $this->userManager->expects($this->at(0))
-                       ->method('userExists')
-                       ->with('user')
-                       ->willReturn(true);
-
-               $this->userManager->expects($this->at(1))
+               $this->userManager->expects($this->exactly(2))
                        ->method('userExists')
-                       ->with('user2')
+                       ->withConsecutive(
+                               ['user'],
+                               ['user2'],
+                       )
                        ->willReturn(true);
 
-               $this->calDav->expects($this->at(0))->method('getCalendarByUri')
-                       ->with('principals/users/user', 'personal')
-                       ->willReturn([
-                               'id' => 1234,
-                               'uri' => 'personal',
-                               '{DAV:}displayname' => 'Personal',
-                       ]);
-
-               $this->calDav->expects($this->at(1))->method('getCalendarByUri')
-                       ->with('principals/users/user2', 'personal')
-                       ->willReturn(null);
+               $this->calDav->expects($this->exactly(2))
+                       ->method('getCalendarByUri')
+                       ->withConsecutive(
+                               ['principals/users/user', 'personal'],
+                               ['principals/users/user2', 'personal'],
+                       )
+                       ->willReturnOnConsecutiveCalls(
+                               [
+                                       'id' => 1234,
+                                       'uri' => 'personal',
+                                       '{DAV:}displayname' => 'Personal'
+                               ],
+                               null,
+                       );
 
                $this->calDav->expects($this->once())->method('getShares')
                                ->with(1234)
index 9355b34d66a3799d1dc1a281210862188e1e7e46..d72e19e1641274b32ce871fb4bd10efed591e769 100644 (file)
@@ -220,7 +220,7 @@ class AuthTest extends TestCase {
                $this->assertFalse($this->invokePrivate($this->auth, 'validateUserPass', ['MyTestUser', 'MyTestPassword']));
        }
 
-       
+
        public function testValidateUserPassWithPasswordLoginForbidden() {
                $this->expectException(\OCA\DAV\Connector\Sabre\Exception\PasswordLoginForbidden::class);
 
@@ -329,7 +329,7 @@ class AuthTest extends TestCase {
                $this->auth->check($request, $response);
        }
 
-       
+
        public function testAuthenticateAlreadyLoggedInWithoutTwoFactorChallengePassed() {
                $this->expectException(\Sabre\DAV\Exception\NotAuthenticated::class);
                $this->expectExceptionMessage('2FA challenge not passed.');
@@ -383,7 +383,7 @@ class AuthTest extends TestCase {
                $this->auth->check($request, $response);
        }
 
-       
+
        public function testAuthenticateAlreadyLoggedInWithoutCsrfTokenAndIncorrectlyDavAuthenticated() {
                $this->expectException(\Sabre\DAV\Exception\NotAuthenticated::class);
                $this->expectExceptionMessage('CSRF check not passed.');
@@ -564,7 +564,7 @@ class AuthTest extends TestCase {
                $this->assertEquals([false, 'No \'Authorization: Basic\' header found. Either the client didn\'t send one, or the server is misconfigured'], $response);
        }
 
-       
+
        public function testAuthenticateNoBasicAuthenticateHeadersProvidedWithAjax() {
                $this->expectException(\Sabre\DAV\Exception\NotAuthenticated::class);
                $this->expectExceptionMessage('Cannot authenticate over ajax calls');
@@ -639,15 +639,16 @@ class AuthTest extends TestCase {
                        ->disableOriginalConstructor()
                        ->getMock();
                $server->httpRequest
-                       ->expects($this->at(0))
-                       ->method('getHeader')
-                       ->with('X-Requested-With')
-                       ->willReturn(null);
-               $server->httpRequest
-                       ->expects($this->at(1))
+                       ->expects($this->exactly(2))
                        ->method('getHeader')
-                       ->with('Authorization')
-                       ->willReturn('basic dXNlcm5hbWU6cGFzc3dvcmQ=');
+                       ->withConsecutive(
+                               ['X-Requested-With'],
+                               ['Authorization'],
+                       )
+                       ->willReturnOnConsecutiveCalls(
+                               null,
+                               'basic dXNlcm5hbWU6cGFzc3dvcmQ=',
+                       );
                $server->httpResponse = $this->getMockBuilder(ResponseInterface::class)
                        ->disableOriginalConstructor()
                        ->getMock();
@@ -678,15 +679,16 @@ class AuthTest extends TestCase {
                        ->disableOriginalConstructor()
                        ->getMock();
                $server->httpRequest
-                       ->expects($this->at(0))
-                       ->method('getHeader')
-                       ->with('X-Requested-With')
-                       ->willReturn(null);
-               $server->httpRequest
-                       ->expects($this->at(1))
+                       ->expects($this->exactly(2))
                        ->method('getHeader')
-                       ->with('Authorization')
-                       ->willReturn('basic dXNlcm5hbWU6cGFzc3dvcmQ=');
+                       ->withConsecutive(
+                               ['X-Requested-With'],
+                               ['Authorization'],
+                       )
+                       ->willReturnOnConsecutiveCalls(
+                               null,
+                               'basic dXNlcm5hbWU6cGFzc3dvcmQ=',
+                       );
                $server->httpResponse = $this->getMockBuilder(ResponseInterface::class)
                        ->disableOriginalConstructor()
                        ->getMock();
index 007b5c90295db8dfa910916007c5e31294669e6d..58a93b25447edb707f31905b6f6e562cdd91d3b0 100644 (file)
@@ -66,13 +66,12 @@ class BearerAuthTest extends TestCase {
 
        public function testValidateBearerToken() {
                $this->userSession
-                       ->expects($this->at(0))
+                       ->expects($this->exactly(2))
                        ->method('isLoggedIn')
-                       ->willReturn(false);
-               $this->userSession
-                       ->expects($this->at(2))
-                       ->method('isLoggedIn')
-                       ->willReturn(true);
+                       ->willReturnOnConsecutiveCalls(
+                               false,
+                               true,
+                       );
                $user = $this->createMock(IUser::class);
                $user
                        ->expects($this->once())
index 578576e3f0709ad6a9432baacce73275bb2c8b85..9c7ca8e932964c75c9a7150f17f123c3fe9ea293 100644 (file)
@@ -56,21 +56,14 @@ class FakeLockerPluginTest extends TestCase {
                        ->disableOriginalConstructor()
                        ->getMock();
                $server
-                       ->expects($this->at(0))
+                       ->expects($this->exactly(4))
                        ->method('on')
-                       ->with('method:LOCK', [$this->fakeLockerPlugin, 'fakeLockProvider'], 1);
-               $server
-                       ->expects($this->at(1))
-                       ->method('on')
-                       ->with('method:UNLOCK', [$this->fakeLockerPlugin, 'fakeUnlockProvider'], 1);
-               $server
-                       ->expects($this->at(2))
-                       ->method('on')
-                       ->with('propFind', [$this->fakeLockerPlugin, 'propFind']);
-               $server
-                       ->expects($this->at(3))
-                       ->method('on')
-                       ->with('validateTokens', [$this->fakeLockerPlugin, 'validateTokens']);
+                       ->withConsecutive(
+                               ['method:LOCK', [$this->fakeLockerPlugin, 'fakeLockProvider'], 1],
+                               ['method:UNLOCK', [$this->fakeLockerPlugin, 'fakeUnlockProvider'], 1],
+                               ['propFind', [$this->fakeLockerPlugin, 'propFind']],
+                               ['validateTokens', [$this->fakeLockerPlugin, 'validateTokens']],
+                       );
 
                $this->fakeLockerPlugin->initialize($server);
        }
@@ -98,12 +91,12 @@ class FakeLockerPluginTest extends TestCase {
                        ->disableOriginalConstructor()
                        ->getMock();
 
-               $propFind->expects($this->at(0))
-                       ->method('handle')
-                       ->with('{DAV:}supportedlock');
-               $propFind->expects($this->at(1))
+               $propFind->expects($this->exactly(2))
                        ->method('handle')
-                       ->with('{DAV:}lockdiscovery');
+                       ->withConsecutive(
+                               ['{DAV:}supportedlock'],
+                               ['{DAV:}lockdiscovery'],
+                       );
 
                $this->fakeLockerPlugin->propFind($propFind, $node);
        }
index f73434b33b6b1d893495cc67d3b7402f8bb1530c..5b8ed304e969d5b63cd3460471127676edb7bfe9 100644 (file)
@@ -217,14 +217,16 @@ class FilesReportPluginTest extends \Test\TestCase {
                        ->method('isAdmin')
                        ->willReturn(true);
 
-               $this->tagMapper->expects($this->at(0))
-                       ->method('getObjectIdsForTags')
-                       ->with('123', 'files')
-                       ->willReturn(['111', '222']);
-               $this->tagMapper->expects($this->at(1))
+               $this->tagMapper->expects($this->exactly(2))
                        ->method('getObjectIdsForTags')
-                       ->with('456', 'files')
-                       ->willReturn(['111', '222', '333']);
+                       ->withConsecutive(
+                               ['123', 'files'],
+                               ['456', 'files'],
+                       )
+                       ->willReturnOnConsecutiveCalls(
+                               ['111', '222'],
+                               ['111', '222', '333'],
+                       );
 
                $reportTargetNode = $this->getMockBuilder(Directory::class)
                        ->disableOriginalConstructor()
@@ -260,14 +262,16 @@ class FilesReportPluginTest extends \Test\TestCase {
                        ->disableOriginalConstructor()
                        ->getMock();
 
-               $this->userFolder->expects($this->at(0))
-                       ->method('getById')
-                       ->with('111')
-                       ->willReturn([$filesNode1]);
-               $this->userFolder->expects($this->at(1))
+               $this->userFolder->expects($this->exactly(2))
                        ->method('getById')
-                       ->with('222')
-                       ->willReturn([$filesNode2]);
+                       ->withConsecutive(
+                               ['111'],
+                               ['222'],
+                       )
+                       ->willReturnOnConsecutiveCalls(
+                               [$filesNode1],
+                               [$filesNode2],
+                       );
 
                $this->server->expects($this->any())
                        ->method('getRequestUri')
@@ -300,14 +304,16 @@ class FilesReportPluginTest extends \Test\TestCase {
                        ->method('getPath')
                        ->willReturn('/');
 
-               $this->userFolder->expects($this->at(0))
-                       ->method('getById')
-                       ->with('111')
-                       ->willReturn([$filesNode1]);
-               $this->userFolder->expects($this->at(1))
+               $this->userFolder->expects($this->exactly(2))
                        ->method('getById')
-                       ->with('222')
-                       ->willReturn([$filesNode2]);
+                       ->withConsecutive(
+                               ['111'],
+                               ['222'],
+                       )
+                       ->willReturnOnConsecutiveCalls(
+                               [$filesNode1],
+                               [$filesNode2],
+                       );
 
                /** @var \OCA\DAV\Connector\Sabre\Directory|\PHPUnit\Framework\MockObject\MockObject $reportTargetNode */
                $result = $this->plugin->findNodesByFileIds($reportTargetNode, ['111', '222']);
@@ -346,19 +352,21 @@ class FilesReportPluginTest extends \Test\TestCase {
                        ->disableOriginalConstructor()
                        ->getMock();
 
-               $this->userFolder->expects($this->at(0))
+               $this->userFolder->expects($this->once())
                        ->method('get')
                        ->with('/sub1/sub2')
                        ->willReturn($subNode);
 
-               $subNode->expects($this->at(0))
+               $subNode->expects($this->exactly(2))
                        ->method('getById')
-                       ->with('111')
-                       ->willReturn([$filesNode1]);
-               $subNode->expects($this->at(1))
-                       ->method('getById')
-                       ->with('222')
-                       ->willReturn([$filesNode2]);
+                       ->withConsecutive(
+                               ['111'],
+                               ['222'],
+                       )
+                       ->willReturnOnConsecutiveCalls(
+                               [$filesNode1],
+                               [$filesNode2],
+                       );
 
                /** @var \OCA\DAV\Connector\Sabre\Directory|\PHPUnit\Framework\MockObject\MockObject $reportTargetNode */
                $result = $this->plugin->findNodesByFileIds($reportTargetNode, ['111', '222']);
@@ -588,14 +596,16 @@ class FilesReportPluginTest extends \Test\TestCase {
                $this->tagManager->expects($this->never())
                        ->method('getTagsByIds');
 
-               $this->tagMapper->expects($this->at(0))
-                       ->method('getObjectIdsForTags')
-                       ->with('123')
-                       ->willReturn(['111', '222']);
-               $this->tagMapper->expects($this->at(1))
+               $this->tagMapper->expects($this->exactly(2))
                        ->method('getObjectIdsForTags')
-                       ->with('456')
-                       ->willReturn(['222', '333']);
+                       ->withConsecutive(
+                               ['123'],
+                               ['456'],
+                       )
+                       ->willReturnOnConsecutiveCalls(
+                               ['111', '222'],
+                               ['222', '333'],
+                       );
 
                $rules = [
                        ['name' => '{http://owncloud.org/ns}systemtag', 'value' => '123'],
@@ -676,14 +686,16 @@ class FilesReportPluginTest extends \Test\TestCase {
                        ->with(['123', '456'])
                        ->willReturn([$tag1, $tag2]);
 
-               $this->tagMapper->expects($this->at(0))
-                       ->method('getObjectIdsForTags')
-                       ->with('123')
-                       ->willReturn(['111', '222']);
-               $this->tagMapper->expects($this->at(1))
+               $this->tagMapper->expects($this->exactly(2))
                        ->method('getObjectIdsForTags')
-                       ->with('456')
-                       ->willReturn(['222', '333']);
+                       ->withConsecutive(
+                               ['123'],
+                               ['456'],
+                       )
+                       ->willReturnOnConsecutiveCalls(
+                               ['111', '222'],
+                               ['222', '333'],
+                       );
 
                $rules = [
                        ['name' => '{http://owncloud.org/ns}systemtag', 'value' => '123'],
index 2614f5416136bfdee6d12ccc9530939fc1890b62..f9e14d5c39f121e9b07850f0a768527e61b6f546 100644 (file)
@@ -458,22 +458,19 @@ class PrincipalTest extends TestCase {
                        ->method('getUID')
                        ->willReturn('bar');
                $this->userManager
-                       ->expects($this->at(0))
-                       ->method('get')
-                       ->with('foo')
-                       ->willReturn($fooUser);
-               $this->userManager
-                       ->expects($this->at(1))
+                       ->expects($this->exactly(2))
                        ->method('get')
-                       ->with('bar')
-                       ->willReturn($barUser);
+                       ->willReturnMap([
+                               ['foo', $fooUser],
+                               ['bar', $barUser],
+                       ]);
 
-               $this->proxyMapper->expects($this->at(0))
+               $this->proxyMapper->expects($this->once())
                        ->method('getProxiesOf')
                        ->with('principals/users/foo')
                        ->willReturn([]);
 
-               $this->proxyMapper->expects($this->at(1))
+               $this->proxyMapper->expects($this->once())
                        ->method('insert')
                        ->with($this->callback(function ($proxy) {
                                /** @var Proxy $proxy */
@@ -514,6 +511,8 @@ class PrincipalTest extends TestCase {
                        ->method('shareAPIEnabled')
                        ->willReturn($sharingEnabled);
 
+               $getUserGroupIdsReturnMap = [];
+
                if ($sharingEnabled) {
                        $this->shareManager->expects($this->once())
                                ->method('allowEnumeration')
@@ -529,10 +528,7 @@ class PrincipalTest extends TestCase {
                                        ->method('getUser')
                                        ->willReturn($user);
 
-                               $this->groupManager->expects($this->at(0))
-                                       ->method('getUserGroupIds')
-                                       ->with($user)
-                                       ->willReturn(['group1', 'group2', 'group5']);
+                               $getUserGroupIdsReturnMap[] = [$user, ['group1', 'group2', 'group5']];
                        }
                } else {
                        $this->config->expects($this->never())
@@ -551,12 +547,12 @@ class PrincipalTest extends TestCase {
                $user4->method('getUID')->willReturn('user4');
 
                if ($sharingEnabled) {
-                       $this->userManager->expects($this->at(0))
+                       $this->userManager->expects($this->once())
                                ->method('getByEmail')
                                ->with('user@example.com')
                                ->willReturn([$user2, $user3]);
 
-                       $this->userManager->expects($this->at(1))
+                       $this->userManager->expects($this->once())
                                ->method('searchDisplayName')
                                ->with('User 12')
                                ->willReturn([$user3, $user4]);
@@ -569,24 +565,15 @@ class PrincipalTest extends TestCase {
                }
 
                if ($sharingEnabled && $groupsOnly) {
-                       $this->groupManager->expects($this->at(1))
-                               ->method('getUserGroupIds')
-                               ->with($user2)
-                               ->willReturn(['group1', 'group3']);
-                       $this->groupManager->expects($this->at(2))
-                               ->method('getUserGroupIds')
-                               ->with($user3)
-                               ->willReturn(['group3', 'group4']);
-                       $this->groupManager->expects($this->at(3))
-                               ->method('getUserGroupIds')
-                               ->with($user3)
-                               ->willReturn(['group3', 'group4']);
-                       $this->groupManager->expects($this->at(4))
-                               ->method('getUserGroupIds')
-                               ->with($user4)
-                               ->willReturn(['group4', 'group5']);
+                       $getUserGroupIdsReturnMap[] = [$user2, ['group1', 'group3']];
+                       $getUserGroupIdsReturnMap[] = [$user3, ['group3', 'group4']];
+                       $getUserGroupIdsReturnMap[] = [$user4, ['group4', 'group5']];
                }
 
+               $this->groupManager->expects($this->any())
+                       ->method('getUserGroupIds')
+                       ->willReturnMap($getUserGroupIdsReturnMap);
+
 
                $this->assertEquals($result, $this->connector->searchPrincipals('principals/users',
                        ['{http://sabredav.org/ns}email-address' => 'user@example.com',
@@ -622,7 +609,7 @@ class PrincipalTest extends TestCase {
                $user3 = $this->createMock(IUser::class);
                $user3->method('getUID')->willReturn('user3');
 
-               $this->userManager->expects($this->at(0))
+               $this->userManager->expects($this->once())
                        ->method('getByEmail')
                        ->with('user@example.com')
                        ->willReturn([$user2, $user3]);
@@ -664,7 +651,7 @@ class PrincipalTest extends TestCase {
                $user4->method('getDisplayName')->willReturn('User 222');
                $user4->method('getSystemEMailAddress')->willReturn('user2@foo.bar456');
 
-               $this->userManager->expects($this->at(0))
+               $this->userManager->expects($this->once())
                        ->method('searchDisplayName')
                        ->with('User 2')
                        ->willReturn([$user2, $user3, $user4]);
@@ -760,15 +747,15 @@ class PrincipalTest extends TestCase {
        }
 
        public function testSearchPrincipalWithEnumerationLimitedDisplayname(): void {
-               $this->shareManager->expects($this->at(0))
+               $this->shareManager->expects($this->once())
                        ->method('shareAPIEnabled')
                        ->willReturn(true);
 
-               $this->shareManager->expects($this->at(1))
+               $this->shareManager->expects($this->once())
                        ->method('allowEnumeration')
                        ->willReturn(true);
 
-               $this->shareManager->expects($this->at(2))
+               $this->shareManager->expects($this->once())
                        ->method('limitEnumerationToGroups')
                        ->willReturn(true);
 
@@ -790,24 +777,19 @@ class PrincipalTest extends TestCase {
                $user4->method('getSystemEMailAddress')->willReturn('user2@foo.bar456');
 
 
-               $this->userSession->expects($this->at(0))
+               $this->userSession->expects($this->once())
                        ->method('getUser')
                        ->willReturn($user2);
 
-               $this->groupManager->expects($this->at(0))
-                       ->method('getUserGroupIds')
-                       ->willReturn(['group1']);
-               $this->groupManager->expects($this->at(1))
-                       ->method('getUserGroupIds')
-                       ->willReturn(['group1']);
-               $this->groupManager->expects($this->at(2))
+               $this->groupManager->expects($this->exactly(4))
                        ->method('getUserGroupIds')
-                       ->willReturn(['group1']);
-               $this->groupManager->expects($this->at(3))
-                       ->method('getUserGroupIds')
-                       ->willReturn(['group2']);
+                       ->willReturnMap([
+                               [$user2, ['group1']],
+                               [$user3, ['group1']],
+                               [$user4, ['group2']],
+                       ]);
 
-               $this->userManager->expects($this->at(0))
+               $this->userManager->expects($this->once())
                        ->method('searchDisplayName')
                        ->with('User')
                        ->willReturn([$user2, $user3, $user4]);
@@ -821,15 +803,15 @@ class PrincipalTest extends TestCase {
        }
 
        public function testSearchPrincipalWithEnumerationLimitedMail(): void {
-               $this->shareManager->expects($this->at(0))
+               $this->shareManager->expects($this->once())
                        ->method('shareAPIEnabled')
                        ->willReturn(true);
 
-               $this->shareManager->expects($this->at(1))
+               $this->shareManager->expects($this->once())
                        ->method('allowEnumeration')
                        ->willReturn(true);
 
-               $this->shareManager->expects($this->at(2))
+               $this->shareManager->expects($this->once())
                        ->method('limitEnumerationToGroups')
                        ->willReturn(true);
 
@@ -851,24 +833,19 @@ class PrincipalTest extends TestCase {
                $user4->method('getSystemEMailAddress')->willReturn('user2@foo.bar456');
 
 
-               $this->userSession->expects($this->at(0))
+               $this->userSession->expects($this->once())
                        ->method('getUser')
                        ->willReturn($user2);
 
-               $this->groupManager->expects($this->at(0))
+               $this->groupManager->expects($this->exactly(4))
                        ->method('getUserGroupIds')
-                       ->willReturn(['group1']);
-               $this->groupManager->expects($this->at(1))
-                       ->method('getUserGroupIds')
-                       ->willReturn(['group1']);
-               $this->groupManager->expects($this->at(2))
-                       ->method('getUserGroupIds')
-                       ->willReturn(['group1']);
-               $this->groupManager->expects($this->at(3))
-                       ->method('getUserGroupIds')
-                       ->willReturn(['group2']);
+                       ->willReturnMap([
+                               [$user2, ['group1']],
+                               [$user3, ['group1']],
+                               [$user4, ['group2']],
+                       ]);
 
-               $this->userManager->expects($this->at(0))
+               $this->userManager->expects($this->once())
                        ->method('getByEmail')
                        ->with('user')
                        ->willReturn([$user2, $user3, $user4]);
@@ -906,11 +883,6 @@ class PrincipalTest extends TestCase {
                                ->method('getUser')
                                ->willReturn($user);
 
-               $this->groupManager->expects($this->at(0))
-                               ->method('getUserGroupIds')
-                               ->with($user)
-                               ->willReturn(['group1', 'group2']);
-
                $user2 = $this->createMock(IUser::class);
                $user2->method('getUID')->willReturn('user2');
                $user3 = $this->createMock(IUser::class);
@@ -922,15 +894,27 @@ class PrincipalTest extends TestCase {
                                ->willReturn([$email === 'user2@foo.bar' ? $user2 : $user3]);
 
                if ($email === 'user2@foo.bar') {
-                       $this->groupManager->expects($this->at(1))
-                                       ->method('getUserGroupIds')
-                                       ->with($user2)
-                                       ->willReturn(['group1', 'group3']);
+                       $this->groupManager->expects($this->exactly(2))
+                               ->method('getUserGroupIds')
+                               ->withConsecutive(
+                                       [$user],
+                                       [$user2],
+                               )
+                               ->willReturnOnConsecutiveCalls(
+                                       ['group1', 'group2'],
+                                       ['group1', 'group3'],
+                               );
                } else {
-                       $this->groupManager->expects($this->at(1))
-                                       ->method('getUserGroupIds')
-                                       ->with($user3)
-                                       ->willReturn(['group3', 'group3']);
+                       $this->groupManager->expects($this->exactly(2))
+                               ->method('getUserGroupIds')
+                               ->withConsecutive(
+                                       [$user],
+                                       [$user3],
+                               )
+                               ->willReturnOnConsecutiveCalls(
+                                       ['group1', 'group2'],
+                                       ['group3', 'group3'],
+                               );
                }
 
                $this->assertEquals($expects, $this->connector->findByUri($uri, 'principals/users'));
index 995342db003075e887a95fadad668288ef271d6c..ad49f45f6b0c08cc677b5ade61dfd4fd44f78985 100644 (file)
@@ -304,21 +304,21 @@ class TagsPluginTest extends \Test\TestCase {
                        ->with('/dummypath')
                        ->willReturn($node);
 
-               $this->tagger->expects($this->at(0))
+               $this->tagger->expects($this->once())
                        ->method('getTagsForObjects')
                        ->with($this->equalTo([123]))
                        ->willReturn([123 => ['tagkeep', 'tagremove', self::TAG_FAVORITE]]);
 
                // then tag as tag1 and tag2
-               $this->tagger->expects($this->at(1))
-                       ->method('tagAs')
-                       ->with(123, 'tag1');
-               $this->tagger->expects($this->at(2))
+               $this->tagger->expects($this->exactly(2))
                        ->method('tagAs')
-                       ->with(123, 'tag2');
+                       ->withConsecutive(
+                               [123, 'tag1'],
+                               [123, 'tag2'],
+                       );
 
                // it will untag tag3
-               $this->tagger->expects($this->at(3))
+               $this->tagger->expects($this->once())
                        ->method('unTag')
                        ->with(123, 'tagremove');
 
@@ -355,22 +355,22 @@ class TagsPluginTest extends \Test\TestCase {
                        ->with('/dummypath')
                        ->willReturn($node);
 
-               $this->tagger->expects($this->at(0))
+               $this->tagger->expects($this->once())
                        ->method('getTagsForObjects')
                        ->with($this->equalTo([123]))
                        ->willReturn([]);
 
                // then tag as tag1 and tag2
-               $this->tagger->expects($this->at(1))
-                       ->method('tagAs')
-                       ->with(123, 'tag1');
-               $this->tagger->expects($this->at(2))
+               $this->tagger->expects($this->exactly(2))
                        ->method('tagAs')
-                       ->with(123, 'tag2');
+                       ->withConsecutive(
+                               [123, 'tag1'],
+                               [123, 'tag2'],
+                       );
 
                // properties to set
                $propPatch = new \Sabre\DAV\PropPatch([
-                       self::TAGS_PROPERTYNAME => new \OCA\DAV\Connector\Sabre\TagList(['tag1', 'tag2', 'tagkeep'])
+                       self::TAGS_PROPERTYNAME => new \OCA\DAV\Connector\Sabre\TagList(['tag1', 'tag2'])
                ]);
 
                $this->plugin->handleUpdateProperties(
index 06d68ca5360f56ac35b35617cbf0f61ebc3f8938..e8a656698d7ea3c0da82bcdf009d9a8511007c52 100644 (file)
@@ -477,19 +477,19 @@ EOF;
                        ->with()
                        ->willReturn($queryBuilder);
 
-               $queryBuilder->expects($this->at(0))
+               $queryBuilder->expects($this->once())
                        ->method('select')
                        ->with('*')
                        ->willReturn($queryBuilder);
-               $queryBuilder->expects($this->at(1))
+               $queryBuilder->expects($this->once())
                        ->method('from')
                        ->with('calendar_invitations')
                        ->willReturn($queryBuilder);
-               $queryBuilder->expects($this->at(4))
+               $queryBuilder->expects($this->once())
                        ->method('where')
                        ->with($function)
                        ->willReturn($queryBuilder);
-               $queryBuilder->expects($this->at(5))
+               $queryBuilder->expects($this->once())
                        ->method('execute')
                        ->with()
                        ->willReturn($stmt);
index 2e7939aa6144f295778668d160ffa78b1df7977a..4cfa0d1884bf77e24824436455c80135c69ee94d 100644 (file)
@@ -39,7 +39,6 @@ use Test\TestCase;
  * @group DB
  */
 class CustomPropertiesBackendTest extends TestCase {
-
        /** @var Tree | \PHPUnit\Framework\MockObject\MockObject */
        private $tree;
 
@@ -129,7 +128,7 @@ class CustomPropertiesBackendTest extends TestCase {
                );
 
                $propFind = $this->createMock(PropFind::class);
-               $propFind->expects($this->at(0))
+               $propFind->expects($this->once())
                        ->method('get404Properties')
                        ->with()
                        ->willReturn([
index 8f86961a6af68cfd5d6e730465baf0d0bd432c47..5520bbe5784221e51fb92f2c5271935728ba5add 100644 (file)
@@ -329,7 +329,7 @@ class GroupPrincipalTest extends \Test\TestCase {
                                        ->method('getUser')
                                        ->willReturn($user);
 
-                               $this->groupManager->expects($this->at(0))
+                               $this->groupManager->expects($this->once())
                                        ->method('getUserGroupIds')
                                        ->with($user)
                                        ->willReturn(['group1', 'group2', 'group5']);
index 427bf6da14541aa30a1e5db2e4d3a8bd2474ddd6..073465cd24cedbdd1f149cf473cdb9a3bdd0fe30 100644 (file)
@@ -36,7 +36,6 @@ use OCP\Migration\IOutput;
 use Test\TestCase;
 
 class RefreshWebcalJobRegistrarTest extends TestCase {
-
        /** @var IDBConnection | \PHPUnit\Framework\MockObject\MockObject */
        private $db;
 
@@ -69,77 +68,68 @@ class RefreshWebcalJobRegistrarTest extends TestCase {
                        ->method('getQueryBuilder')
                        ->willReturn($queryBuilder);
 
-               $queryBuilder->expects($this->at(0))
+               $queryBuilder->expects($this->once())
                        ->method('select')
                        ->with(['principaluri', 'uri'])
                        ->willReturn($queryBuilder);
-               $queryBuilder->expects($this->at(1))
+               $queryBuilder->expects($this->once())
                        ->method('from')
                        ->with('calendarsubscriptions')
                        ->willReturn($queryBuilder);
-               $queryBuilder->expects($this->at(2))
+               $queryBuilder->expects($this->once())
                        ->method('execute')
                        ->willReturn($statement);
 
-               $statement->expects($this->at(0))
-                       ->method('fetch')
-                       ->with(\PDO::FETCH_ASSOC)
-                       ->willReturn([
-                               'principaluri' => 'foo1',
-                               'uri' => 'bar1',
-                       ]);
-               $statement->expects($this->at(1))
+               $statement->expects($this->exactly(4))
                        ->method('fetch')
                        ->with(\PDO::FETCH_ASSOC)
-                       ->willReturn([
-                               'principaluri' => 'foo2',
-                               'uri' => 'bar2',
-                       ]);
-               $statement->expects($this->at(2))
-                       ->method('fetch')
-                       ->with(\PDO::FETCH_ASSOC)
-                       ->willReturn([
-                               'principaluri' => 'foo3',
-                               'uri' => 'bar3',
-                       ]);
-               $statement->expects($this->at(0))
-                       ->method('fetch')
-                       ->with(\PDO::FETCH_ASSOC)
-                       ->willReturn(null);
-
-               $this->jobList->expects($this->at(0))
-                       ->method('has')
-                       ->with(RefreshWebcalJob::class, [
-                               'principaluri' => 'foo1',
-                               'uri' => 'bar1',
-                       ])
-                       ->willReturn(false);
-               $this->jobList->expects($this->at(1))
-                       ->method('add')
-                       ->with(RefreshWebcalJob::class, [
-                               'principaluri' => 'foo1',
-                               'uri' => 'bar1',
-                       ]);
-               $this->jobList->expects($this->at(2))
-                       ->method('has')
-                       ->with(RefreshWebcalJob::class, [
-                               'principaluri' => 'foo2',
-                               'uri' => 'bar2',
-                       ])
-                       ->willReturn(true);
-               $this->jobList->expects($this->at(3))
+                       ->willReturnOnConsecutiveCalls(
+                               [
+                                       'principaluri' => 'foo1',
+                                       'uri' => 'bar1',
+                               ],
+                               [
+                                       'principaluri' => 'foo2',
+                                       'uri' => 'bar2',
+                               ],
+                               [
+                                       'principaluri' => 'foo3',
+                                       'uri' => 'bar3',
+                               ],
+                               null
+                       );
+
+               $this->jobList->expects($this->exactly(3))
                        ->method('has')
-                       ->with(RefreshWebcalJob::class, [
-                               'principaluri' => 'foo3',
-                               'uri' => 'bar3',
-                       ])
-                       ->willReturn(false);
-               $this->jobList->expects($this->at(4))
+                       ->withConsecutive(
+                               [RefreshWebcalJob::class, [
+                                       'principaluri' => 'foo1',
+                                       'uri' => 'bar1',
+                               ]],
+                               [RefreshWebcalJob::class, [
+                                       'principaluri' => 'foo2',
+                                       'uri' => 'bar2',
+                               ]],
+                               [RefreshWebcalJob::class, [
+                                       'principaluri' => 'foo3',
+                                       'uri' => 'bar3',
+                               ]])
+                       ->willReturnOnConsecutiveCalls(
+                               false,
+                               true,
+                               false,
+                       );
+               $this->jobList->expects($this->exactly(2))
                        ->method('add')
-                       ->with(RefreshWebcalJob::class, [
-                               'principaluri' => 'foo3',
-                               'uri' => 'bar3',
-                       ]);
+                       ->withConsecutive(
+                               [RefreshWebcalJob::class, [
+                                       'principaluri' => 'foo1',
+                                       'uri' => 'bar1',
+                               ]],
+                               [RefreshWebcalJob::class, [
+                                       'principaluri' => 'foo3',
+                                       'uri' => 'bar3',
+                               ]]);
 
                $output->expects($this->once())
                        ->method('info')
index c0d6518d2051ea002d99a5b9890020219f8e6e05..83026fc1721e4e4b6f2408197ce88b0910128fe7 100644 (file)
@@ -111,7 +111,7 @@ class RemoveDeletedUsersCalendarSubscriptionsTest extends TestCase {
                $qb->method('execute')
                        ->willReturn($result);
 
-               $result->expects($this->at(0))
+               $result->expects($this->once())
                        ->method('fetchOne')
                        ->willReturn(count($subscriptions));
 
index 2f4728f1966a1c740c636c93a97a1334592ccf76..e58022264a1aca3d56d16627dc0a278fd3c7ecaf 100644 (file)
@@ -30,7 +30,6 @@ use Sabre\DAV\PropPatch;
 use Test\TestCase;
 
 class AppleProvisioningNodeTest extends TestCase {
-
        /** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */
        private $timeFactory;
 
@@ -69,7 +68,7 @@ class AppleProvisioningNodeTest extends TestCase {
        }
 
        public function testGetProperties() {
-               $this->timeFactory->expects($this->at(0))
+               $this->timeFactory->expects($this->once())
                        ->method('getDateTime')
                        ->willReturn(new \DateTime('2000-01-01'));
 
index 5bff59cbc7c8c577ae9f66556518799fef22f4cc..b4d28a875b34c814f2ed2eec7f7df2179dd172e6 100644 (file)
@@ -36,7 +36,6 @@ use OCP\IUserSession;
 use Test\TestCase;
 
 class AppleProvisioningPluginTest extends TestCase {
-
        /** @var \Sabre\DAV\Server|\PHPUnit\Framework\MockObject\MockObject */
        protected $server;
 
@@ -96,7 +95,7 @@ class AppleProvisioningPluginTest extends TestCase {
                        function () {
                        });
 
-               $server->expects($this->at(0))
+               $server->expects($this->once())
                        ->method('on')
                        ->with('method:GET', [$plugin, 'httpGet'], 90);
 
@@ -104,36 +103,36 @@ class AppleProvisioningPluginTest extends TestCase {
        }
 
        public function testHttpGetOnHttp() {
-               $this->sabreRequest->expects($this->at(0))
+               $this->sabreRequest->expects($this->once())
                        ->method('getPath')
                        ->with()
                        ->willReturn('provisioning/apple-provisioning.mobileconfig');
 
                $user = $this->createMock(IUser::class);
-               $this->userSession->expects($this->at(0))
+               $this->userSession->expects($this->once())
                        ->method('getUser')
                        ->willReturn($user);
 
-               $this->request->expects($this->at(0))
+               $this->request->expects($this->once())
                        ->method('getServerProtocol')
                        ->wilLReturn('http');
 
-               $this->themingDefaults->expects($this->at(0))
+               $this->themingDefaults->expects($this->once())
                        ->method('getName')
                        ->willReturn('InstanceName');
 
-               $this->l10n->expects($this->at(0))
+               $this->l10n->expects($this->once())
                        ->method('t')
                        ->with('Your %s needs to be configured to use HTTPS in order to use CalDAV and CardDAV with iOS/macOS.', ['InstanceName'])
                        ->willReturn('LocalizedErrorMessage');
 
-               $this->sabreResponse->expects($this->at(0))
+               $this->sabreResponse->expects($this->once())
                        ->method('setStatus')
                        ->with(200);
-               $this->sabreResponse->expects($this->at(1))
+               $this->sabreResponse->expects($this->once())
                        ->method('setHeader')
                        ->with('Content-Type', 'text/plain; charset=utf-8');
-               $this->sabreResponse->expects($this->at(2))
+               $this->sabreResponse->expects($this->once())
                        ->method('setBody')
                        ->with('LocalizedErrorMessage');
 
@@ -143,21 +142,21 @@ class AppleProvisioningPluginTest extends TestCase {
        }
 
        public function testHttpGetOnHttps() {
-               $this->sabreRequest->expects($this->at(0))
+               $this->sabreRequest->expects($this->once())
                        ->method('getPath')
                        ->with()
                        ->willReturn('provisioning/apple-provisioning.mobileconfig');
 
                $user = $this->createMock(IUser::class);
-               $user->expects($this->at(0))
+               $user->expects($this->once())
                        ->method('getUID')
                        ->willReturn('userName');
 
-               $this->userSession->expects($this->at(0))
+               $this->userSession->expects($this->once())
                        ->method('getUser')
                        ->willReturn($user);
 
-               $this->request->expects($this->at(0))
+               $this->request->expects($this->once())
                        ->method('getServerProtocol')
                        ->wilLReturn('https');
 
@@ -165,30 +164,31 @@ class AppleProvisioningPluginTest extends TestCase {
                        ->method('getBaseUrl')
                        ->willReturn('https://nextcloud.tld/nextcloud');
 
-               $this->themingDefaults->expects($this->at(0))
+               $this->themingDefaults->expects($this->once())
                        ->method('getName')
                        ->willReturn('InstanceName');
 
-               $this->l10n->expects($this->at(0))
-                       ->method('t')
-                       ->with('Configures a CalDAV account')
-                       ->willReturn('LocalizedConfiguresCalDAV');
-
-               $this->l10n->expects($this->at(1))
+               $this->l10n->expects($this->exactly(2))
                        ->method('t')
-                       ->with('Configures a CardDAV account')
-                       ->willReturn('LocalizedConfiguresCardDAV');
-
-               $this->sabreResponse->expects($this->at(0))
+                       ->withConsecutive(
+                               ['Configures a CalDAV account'],
+                               ['Configures a CardDAV account'],
+                       )
+                       ->willReturnOnConsecutiveCalls(
+                               'LocalizedConfiguresCalDAV',
+                               'LocalizedConfiguresCardDAV',
+                       );
+
+               $this->sabreResponse->expects($this->once())
                        ->method('setStatus')
                        ->with(200);
-               $this->sabreResponse->expects($this->at(1))
-                       ->method('setHeader')
-                       ->with('Content-Disposition', 'attachment; filename="userName-apple-provisioning.mobileconfig"');
-               $this->sabreResponse->expects($this->at(2))
+               $this->sabreResponse->expects($this->exactly(2))
                        ->method('setHeader')
-                       ->with('Content-Type', 'application/xml; charset=utf-8');
-               $this->sabreResponse->expects($this->at(3))
+                       ->withConsecutive(
+                               ['Content-Disposition', 'attachment; filename="userName-apple-provisioning.mobileconfig"'],
+                               ['Content-Type', 'application/xml; charset=utf-8'],
+                       );
+               $this->sabreResponse->expects($this->once())
                        ->method('setBody')
                        ->with(<<<EOF
 <?xml version="1.0" encoding="UTF-8"?>
@@ -262,7 +262,7 @@ class AppleProvisioningPluginTest extends TestCase {
 </plist>
 
 EOF
-);
+                       );
 
                $returnValue = $this->plugin->httpGet($this->sabreRequest, $this->sabreResponse);
 
index a2f4e66fbdb86a29c4c3599281fdd268b1759b9d..601c0567f745e1db1ad130e131699984c4368c9c 100644 (file)
@@ -39,7 +39,6 @@ use Sabre\VObject\Reader;
 use Test\TestCase;
 
 class EventsSearchProviderTest extends TestCase {
-
        /** @var IAppManager|\PHPUnit\Framework\MockObject\MockObject */
        private $appManager;
 
@@ -420,15 +419,15 @@ class EventsSearchProviderTest extends TestCase {
        }
 
        public function testGetDeepLinkToCalendarApp(): void {
-               $this->urlGenerator->expects($this->at(0))
+               $this->urlGenerator->expects($this->once())
                        ->method('linkTo')
                        ->with('', 'remote.php')
                        ->willReturn('link-to-remote.php');
-               $this->urlGenerator->expects($this->at(1))
+               $this->urlGenerator->expects($this->once())
                        ->method('linkToRoute')
                        ->with('calendar.view.index')
                        ->willReturn('link-to-route-calendar/');
-               $this->urlGenerator->expects($this->at(2))
+               $this->urlGenerator->expects($this->once())
                        ->method('getAbsoluteURL')
                        ->with('link-to-route-calendar/edit/bGluay10by1yZW1vdGUucGhwL2Rhdi9jYWxlbmRhcnMvam9obi5kb2UvZm9vL2Jhci5pY3M=')
                        ->willReturn('absolute-url-to-route');
index 766b3e1f4572dffba1ff3c6da7b3bf9c73f2e270..4c22b803fc3a8962af9dd37a108c398abc3e68fe 100644 (file)
@@ -35,8 +35,6 @@ use Sabre\HTTP\ResponseInterface;
 use Test\TestCase;
 
 class ChunkingPluginTest extends TestCase {
-
-
        /**
         * @var \Sabre\DAV\Server | \PHPUnit\Framework\MockObject\MockObject
         */
@@ -97,14 +95,16 @@ class ChunkingPluginTest extends TestCase {
                $sourceNode = $this->createMock(FutureFile::class);
                $targetNode = $this->createMock(Directory::class);
 
-               $this->tree->expects($this->at(0))
-                       ->method('getNodeForPath')
-                       ->with('source')
-                       ->willReturn($sourceNode);
-               $this->tree->expects($this->at(1))
+               $this->tree->expects($this->exactly(2))
                        ->method('getNodeForPath')
-                       ->with('target')
-                       ->willReturn($targetNode);
+                       ->withConsecutive(
+                               ['source'],
+                               ['target'],
+                       )
+                       ->willReturnOnConsecutiveCalls(
+                               $sourceNode,
+                               $targetNode,
+                       );
                $this->response->expects($this->never())
                        ->method('setStatus');
 
@@ -117,14 +117,16 @@ class ChunkingPluginTest extends TestCase {
                        ->method('getSize')
                        ->willReturn(4);
 
-               $this->tree->expects($this->at(0))
-                       ->method('getNodeForPath')
-                       ->with('source')
-                       ->willReturn($sourceNode);
-               $this->tree->expects($this->at(1))
+               $this->tree->expects($this->exactly(2))
                        ->method('getNodeForPath')
-                       ->with('target')
-                       ->willThrowException(new NotFound());
+                       ->withConsecutive(
+                               ['source'],
+                               ['target'],
+                       )
+                       ->willReturnOnConsecutiveCalls(
+                               $sourceNode,
+                               $this->throwException(new NotFound()),
+                       );
                $this->tree->expects($this->any())
                        ->method('nodeExists')
                        ->with('target')
@@ -149,14 +151,17 @@ class ChunkingPluginTest extends TestCase {
                        ->method('getSize')
                        ->willReturn(4);
 
-               $this->tree->expects($this->at(0))
-                       ->method('getNodeForPath')
-                       ->with('source')
-                       ->willReturn($sourceNode);
-               $this->tree->expects($this->at(1))
+
+               $this->tree->expects($this->exactly(2))
                        ->method('getNodeForPath')
-                       ->with('target')
-                       ->willThrowException(new NotFound());
+                       ->withConsecutive(
+                               ['source'],
+                               ['target'],
+                       )
+                       ->willReturnOnConsecutiveCalls(
+                               $sourceNode,
+                               $this->throwException(new NotFound()),
+                       );
                $this->tree->expects($this->any())
                        ->method('nodeExists')
                        ->with('target')
@@ -189,14 +194,17 @@ class ChunkingPluginTest extends TestCase {
                        ->method('getSize')
                        ->willReturn(3);
 
-               $this->tree->expects($this->at(0))
-                       ->method('getNodeForPath')
-                       ->with('source')
-                       ->willReturn($sourceNode);
-               $this->tree->expects($this->at(1))
+
+               $this->tree->expects($this->exactly(2))
                        ->method('getNodeForPath')
-                       ->with('target')
-                       ->willThrowException(new NotFound());
+                       ->withConsecutive(
+                               ['source'],
+                               ['target'],
+                       )
+                       ->willReturnOnConsecutiveCalls(
+                               $sourceNode,
+                               $this->throwException(new NotFound()),
+                       );
                $this->request->expects($this->once())
                        ->method('getHeader')
                        ->with('OC-Total-Length')