->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);
use Test\TestCase;
class EventReminderJobTest extends TestCase {
-
/** @var ITimeFactory|MockObject */
private $time;
* @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())
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;
$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([]);
}
$calendar->propPatch($propPatch);
}
-
+
public function testGetChild() {
$this->expectException(\Sabre\DAV\Exception\NotFound::class);
$this->expectExceptionMessage('Calendar object not found');
'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);
'uri' => 'cal',
];
- $backend->expects($this->at(0))
+ $backend->expects($this->once())
->method('getCalendarObjects')
->with(666, 1)
->willReturn([
'uri' => 'cal',
];
- $backend->expects($this->at(0))
+ $backend->expects($this->once())
->method('getMultipleCalendarObjects')
->with(666, ['foo1', 'foo2'], 1)
->willReturn([
$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');
'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);
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;
$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();
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);
$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);
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 {
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;
$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);
}
}
public function testProcessReminders():void {
- $this->backend->expects($this->at(0))
+ $this->backend->expects($this->once())
->method('getRemindersToProcess')
->with()
->willReturn([
]
]);
- $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))
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')
use Test\TestCase;
abstract class AbstractPrincipalBackendTest extends TestCase {
-
/** @var \OCA\DAV\CalDAV\ResourceBooking\ResourcePrincipalBackend|\OCA\DAV\CalDAV\ResourceBooking\RoomPrincipalBackend */
protected $principalBackend;
}
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']);
}
use OCP\IDBConnection;
use OCP\IL10N;
use OCP\IURLGenerator;
-use OCP\IUser;
use OCP\IUserManager;
use OCP\L10N\IFactory;
use OCP\Mail\IAttachment;
use Test\TestCase;
class IMipPluginTest extends TestCase {
-
- /** @var IMessage|MockObject */
+ /** @var IMessage|MockObject */
private $mailMessage;
/** @var IMailer|MockObject */
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();
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();
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();
*/
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);
* @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());
$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');
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
->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())
$plugin = new SearchPlugin();
- $server->expects($this->at(0))
+ $server->expects($this->once())
->method('on')
->with('report', [$plugin, 'report']);
$server->xml = new Service();
$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);
->willReturn([
'return' => null
]);
- $calendarHome->expects($this->at(0))
+ $calendarHome->expects($this->once())
->method('calendarSearch')
->willReturn([]);
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('');
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');
use Test\TestCase;
class AddressBookImplTest extends TestCase {
-
/** @var AddressBookImpl */
private $addressBookImpl;
}
public function testSearch() {
-
/** @var \PHPUnit\Framework\MockObject\MockObject | AddressBookImpl $addressBookImpl */
$addressBookImpl = $this->getMockBuilder(AddressBookImpl::class)
->setConstructorArgs(
$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)
->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')
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 */
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);
}
->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');
[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();
[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', '');
}
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');
}
* @package OCA\DAV\Tests\unit\CardDAV
*/
class CardDavBackendTest extends TestCase {
-
/** @var CardDavBackend */
private $backend;
}
public function testAddressBookOperations() {
-
// create a new address book
$this->backend->createAddressBook(self::UNIT_TEST_USER, 'Example', []);
}
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])
$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
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();
$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();
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();
}
use Test\TestCase;
class ImageExportPluginTest extends TestCase {
-
/** @var ResponseInterface|\PHPUnit\Framework\MockObject\MockObject */
private $response;
/** @var RequestInterface|\PHPUnit\Framework\MockObject\MockObject */
$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) {
->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')
->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());
/** @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();
* @package OCA\DAV\Tests\Command
*/
class MoveCalendarTest extends TestCase {
-
/** @var \OCP\IUserManager|MockObject $userManager */
private $userManager;
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([
$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')
$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,
]);
}
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)
* @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);
}
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);
}
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);
* @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)
$this->assertFalse($this->invokePrivate($this->auth, 'validateUserPass', ['MyTestUser', 'MyTestPassword']));
}
-
+
public function testValidateUserPassWithPasswordLoginForbidden() {
$this->expectException(\OCA\DAV\Connector\Sabre\Exception\PasswordLoginForbidden::class);
$this->auth->check($request, $response);
}
-
+
public function testAuthenticateAlreadyLoggedInWithoutTwoFactorChallengePassed() {
$this->expectException(\Sabre\DAV\Exception\NotAuthenticated::class);
$this->expectExceptionMessage('2FA challenge not passed.');
$this->auth->check($request, $response);
}
-
+
public function testAuthenticateAlreadyLoggedInWithoutCsrfTokenAndIncorrectlyDavAuthenticated() {
$this->expectException(\Sabre\DAV\Exception\NotAuthenticated::class);
$this->expectExceptionMessage('CSRF check not passed.');
$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');
->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();
->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();
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())
->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);
}
->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);
}
->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()
->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')
->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']);
->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']);
$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'],
->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'],
->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 */
->method('shareAPIEnabled')
->willReturn($sharingEnabled);
+ $getUserGroupIdsReturnMap = [];
+
if ($sharingEnabled) {
$this->shareManager->expects($this->once())
->method('allowEnumeration')
->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())
$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]);
}
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',
$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]);
$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]);
}
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);
$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]);
}
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);
$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]);
->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);
->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'));
->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');
->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(
->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);
* @group DB
*/
class CustomPropertiesBackendTest extends TestCase {
-
/** @var Tree | \PHPUnit\Framework\MockObject\MockObject */
private $tree;
);
$propFind = $this->createMock(PropFind::class);
- $propFind->expects($this->at(0))
+ $propFind->expects($this->once())
->method('get404Properties')
->with()
->willReturn([
->method('getUser')
->willReturn($user);
- $this->groupManager->expects($this->at(0))
+ $this->groupManager->expects($this->once())
->method('getUserGroupIds')
->with($user)
->willReturn(['group1', 'group2', 'group5']);
use Test\TestCase;
class RefreshWebcalJobRegistrarTest extends TestCase {
-
/** @var IDBConnection | \PHPUnit\Framework\MockObject\MockObject */
private $db;
->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')
$qb->method('execute')
->willReturn($result);
- $result->expects($this->at(0))
+ $result->expects($this->once())
->method('fetchOne')
->willReturn(count($subscriptions));
use Test\TestCase;
class AppleProvisioningNodeTest extends TestCase {
-
/** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */
private $timeFactory;
}
public function testGetProperties() {
- $this->timeFactory->expects($this->at(0))
+ $this->timeFactory->expects($this->once())
->method('getDateTime')
->willReturn(new \DateTime('2000-01-01'));
use Test\TestCase;
class AppleProvisioningPluginTest extends TestCase {
-
/** @var \Sabre\DAV\Server|\PHPUnit\Framework\MockObject\MockObject */
protected $server;
function () {
});
- $server->expects($this->at(0))
+ $server->expects($this->once())
->method('on')
->with('method:GET', [$plugin, 'httpGet'], 90);
}
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');
}
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');
->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"?>
</plist>
EOF
-);
+ );
$returnValue = $this->plugin->httpGet($this->sabreRequest, $this->sabreResponse);
use Test\TestCase;
class EventsSearchProviderTest extends TestCase {
-
/** @var IAppManager|\PHPUnit\Framework\MockObject\MockObject */
private $appManager;
}
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');
use Test\TestCase;
class ChunkingPluginTest extends TestCase {
-
-
/**
* @var \Sabre\DAV\Server | \PHPUnit\Framework\MockObject\MockObject
*/
$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');
->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')
->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')
->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')