aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/tests/unit/CalDAV/Schedule/PluginTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dav/tests/unit/CalDAV/Schedule/PluginTest.php')
-rw-r--r--apps/dav/tests/unit/CalDAV/Schedule/PluginTest.php70
1 files changed, 30 insertions, 40 deletions
diff --git a/apps/dav/tests/unit/CalDAV/Schedule/PluginTest.php b/apps/dav/tests/unit/CalDAV/Schedule/PluginTest.php
index f656a0fa33c..524ac556e19 100644
--- a/apps/dav/tests/unit/CalDAV/Schedule/PluginTest.php
+++ b/apps/dav/tests/unit/CalDAV/Schedule/PluginTest.php
@@ -1,5 +1,6 @@
<?php
+declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -35,21 +36,11 @@ use Sabre\Xml\Service;
use Test\TestCase;
class PluginTest extends TestCase {
-
- /** @var Plugin */
- private $plugin;
-
- /** @var Server|MockObject */
- private $server;
-
- /** @var IConfig|MockObject */
- private $config;
-
- /** @var LoggerInterface&MockObject */
- private $logger;
-
- /** @var DefaultCalendarValidator */
- private $calendarValidator;
+ private Plugin $plugin;
+ private Server&MockObject $server;
+ private IConfig&MockObject $config;
+ private LoggerInterface&MockObject $logger;
+ private DefaultCalendarValidator $calendarValidator;
protected function setUp(): void {
parent::setUp();
@@ -59,9 +50,7 @@ class PluginTest extends TestCase {
$this->calendarValidator = new DefaultCalendarValidator();
$this->server = $this->createMock(Server::class);
- $this->server->httpResponse = $this->getMockBuilder(ResponseInterface::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->server->httpResponse = $this->createMock(ResponseInterface::class);
$this->server->xml = new Service();
$this->plugin = new Plugin($this->config, $this->logger, $this->calendarValidator);
@@ -69,23 +58,26 @@ class PluginTest extends TestCase {
}
public function testInitialize(): void {
-
- $this->server->expects($this->exactly(10))
+ $calls = [
+ // Sabre\CalDAV\Schedule\Plugin events
+ ['method:POST', [$this->plugin, 'httpPost'], 100],
+ ['propFind', [$this->plugin, 'propFind'], 100],
+ ['propPatch', [$this->plugin, 'propPatch'], 100],
+ ['calendarObjectChange', [$this->plugin, 'calendarObjectChange'], 100],
+ ['beforeUnbind', [$this->plugin, 'beforeUnbind'], 100],
+ ['schedule', [$this->plugin, 'scheduleLocalDelivery'], 100],
+ ['getSupportedPrivilegeSet', [$this->plugin, 'getSupportedPrivilegeSet'], 100],
+ // OCA\DAV\CalDAV\Schedule\Plugin events
+ ['propFind', [$this->plugin, 'propFindDefaultCalendarUrl'], 90],
+ ['afterWriteContent', [$this->plugin, 'dispatchSchedulingResponses'], 100],
+ ['afterCreateFile', [$this->plugin, 'dispatchSchedulingResponses'], 100],
+ ];
+ $this->server->expects($this->exactly(count($calls)))
->method('on')
- ->withConsecutive(
- // Sabre\CalDAV\Schedule\Plugin events
- ['method:POST', [$this->plugin, 'httpPost']],
- ['propFind', [$this->plugin, 'propFind']],
- ['propPatch', [$this->plugin, 'propPatch']],
- ['calendarObjectChange', [$this->plugin, 'calendarObjectChange']],
- ['beforeUnbind', [$this->plugin, 'beforeUnbind']],
- ['schedule', [$this->plugin, 'scheduleLocalDelivery']],
- ['getSupportedPrivilegeSet', [$this->plugin, 'getSupportedPrivilegeSet']],
- // OCA\DAV\CalDAV\Schedule\Plugin events
- ['propFind', [$this->plugin, 'propFindDefaultCalendarUrl'], 90],
- ['afterWriteContent', [$this->plugin, 'dispatchSchedulingResponses']],
- ['afterCreateFile', [$this->plugin, 'dispatchSchedulingResponses']]
- );
+ ->willReturnCallback(function () use (&$calls): void {
+ $expected = array_shift($calls);
+ $this->assertEquals($expected, func_get_args());
+ });
$this->plugin->initialize($this->server);
}
@@ -168,7 +160,7 @@ class PluginTest extends TestCase {
$this->assertFalse($this->invokePrivate($this->plugin, 'getAttendeeRSVP', [$property3]));
}
- public function propFindDefaultCalendarUrlProvider(): array {
+ public static function propFindDefaultCalendarUrlProvider(): array {
return [
[
'principals/users/myuser',
@@ -259,9 +251,7 @@ class PluginTest extends TestCase {
];
}
- /**
- * @dataProvider propFindDefaultCalendarUrlProvider
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('propFindDefaultCalendarUrlProvider')]
public function testPropFindDefaultCalendarUrl(string $principalUri, ?string $calendarHome, bool $isResource, string $calendarUri, string $displayName, bool $exists, bool $deleted = false, bool $hasExistingCalendars = false, bool $propertiesForPath = true): void {
$propFind = new PropFind(
$principalUri,
@@ -270,7 +260,7 @@ class PluginTest extends TestCase {
],
0
);
- /** @var IPrincipal|MockObject $node */
+ /** @var IPrincipal&MockObject $node */
$node = $this->getMockBuilder(IPrincipal::class)
->disableOriginalConstructor()
->getMock();
@@ -367,7 +357,7 @@ class PluginTest extends TestCase {
}
}
- /** @var Tree|MockObject $tree */
+ /** @var Tree&MockObject $tree */
$tree = $this->createMock(Tree::class);
$tree->expects($this->once())
->method('getNodeForPath')