summaryrefslogtreecommitdiffstats
path: root/apps/dav/tests/unit/CalDAV
diff options
context:
space:
mode:
authorCôme Chilliet <91878298+come-nc@users.noreply.github.com>2023-01-10 10:18:50 +0100
committerGitHub <noreply@github.com>2023-01-10 10:18:50 +0100
commit95520bc46790d4cdf498428a912657ef6a23bfa0 (patch)
treeb3e63db66f94d8cb8506d797872036cfe881a03c /apps/dav/tests/unit/CalDAV
parent1cfea13e943411cd98988911e9e13dd7d78682fc (diff)
parent574c6770d18f74c26ec3b72075a52333e6495a7a (diff)
downloadnextcloud-server-95520bc46790d4cdf498428a912657ef6a23bfa0.tar.gz
nextcloud-server-95520bc46790d4cdf498428a912657ef6a23bfa0.zip
Merge pull request #36026 from nextcloud/fix/remove-at-matcher-in-dav
Get rid of deprecated at matcher in dav application tests
Diffstat (limited to 'apps/dav/tests/unit/CalDAV')
-rw-r--r--apps/dav/tests/unit/CalDAV/CachedSubscriptionTest.php52
-rw-r--r--apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/EmailProviderTest.php183
-rw-r--r--apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/PushProviderTest.php35
-rw-r--r--apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php116
-rw-r--r--apps/dav/tests/unit/CalDAV/ResourceBooking/AbstractPrincipalBackendTest.php65
-rw-r--r--apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php47
-rw-r--r--apps/dav/tests/unit/CalDAV/Search/SearchPluginTest.php10
-rw-r--r--apps/dav/tests/unit/CalDAV/WebcalCaching/PluginTest.php8
8 files changed, 198 insertions, 318 deletions
diff --git a/apps/dav/tests/unit/CalDAV/CachedSubscriptionTest.php b/apps/dav/tests/unit/CalDAV/CachedSubscriptionTest.php
index dac5090dccc..6b5b5f65347 100644
--- a/apps/dav/tests/unit/CalDAV/CachedSubscriptionTest.php
+++ b/apps/dav/tests/unit/CalDAV/CachedSubscriptionTest.php
@@ -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);
diff --git a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/EmailProviderTest.php b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/EmailProviderTest.php
index 9499e9e2ef1..fb985525078 100644
--- a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/EmailProviderTest.php
+++ b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/EmailProviderTest.php
@@ -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 {
diff --git a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/PushProviderTest.php b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/PushProviderTest.php
index 64020b9dbd7..a0d5ebb3489 100644
--- a/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/PushProviderTest.php
+++ b/apps/dav/tests/unit/CalDAV/Reminder/NotificationProvider/PushProviderTest.php
@@ -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);
}
diff --git a/apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php b/apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php
index e2b5390f875..4e5413a5226 100644
--- a/apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php
+++ b/apps/dav/tests/unit/CalDAV/Reminder/ReminderServiceTest.php
@@ -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')
diff --git a/apps/dav/tests/unit/CalDAV/ResourceBooking/AbstractPrincipalBackendTest.php b/apps/dav/tests/unit/CalDAV/ResourceBooking/AbstractPrincipalBackendTest.php
index 0fffbc2cd10..0c86a9c5a29 100644
--- a/apps/dav/tests/unit/CalDAV/ResourceBooking/AbstractPrincipalBackendTest.php
+++ b/apps/dav/tests/unit/CalDAV/ResourceBooking/AbstractPrincipalBackendTest.php
@@ -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']);
}
diff --git a/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php b/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php
index 0b64704a87e..597047efb94 100644
--- a/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php
+++ b/apps/dav/tests/unit/CalDAV/Schedule/IMipPluginTest.php
@@ -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())
diff --git a/apps/dav/tests/unit/CalDAV/Search/SearchPluginTest.php b/apps/dav/tests/unit/CalDAV/Search/SearchPluginTest.php
index 81155039015..d5a1a6be31d 100644
--- a/apps/dav/tests/unit/CalDAV/Search/SearchPluginTest.php
+++ b/apps/dav/tests/unit/CalDAV/Search/SearchPluginTest.php
@@ -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([]);
diff --git a/apps/dav/tests/unit/CalDAV/WebcalCaching/PluginTest.php b/apps/dav/tests/unit/CalDAV/WebcalCaching/PluginTest.php
index 310d266cd57..441e83ccc97 100644
--- a/apps/dav/tests/unit/CalDAV/WebcalCaching/PluginTest.php
+++ b/apps/dav/tests/unit/CalDAV/WebcalCaching/PluginTest.php
@@ -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');