aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/tests/unit/Controller/InvitationResponseControllerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dav/tests/unit/Controller/InvitationResponseControllerTest.php')
-rw-r--r--apps/dav/tests/unit/Controller/InvitationResponseControllerTest.php75
1 files changed, 17 insertions, 58 deletions
diff --git a/apps/dav/tests/unit/Controller/InvitationResponseControllerTest.php b/apps/dav/tests/unit/Controller/InvitationResponseControllerTest.php
index 2d9132ddccb..15b18d6c1b1 100644
--- a/apps/dav/tests/unit/Controller/InvitationResponseControllerTest.php
+++ b/apps/dav/tests/unit/Controller/InvitationResponseControllerTest.php
@@ -3,32 +3,11 @@
declare(strict_types=1);
/**
- * @copyright 2018, Georg Ehrke <oc.list@georgehrke.com>
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Georg Ehrke <oc.list@georgehrke.com>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
-namespace OCA\DAV\Tests\Unit\DAV\Controller;
+namespace OCA\DAV\Tests\unit\DAV\Controller;
use OCA\DAV\CalDAV\InvitationResponse\InvitationResponseServer;
use OCA\DAV\Controller\InvitationResponseController;
@@ -39,24 +18,16 @@ use OCP\DB\QueryBuilder\IExpressionBuilder;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
use OCP\IRequest;
+use PHPUnit\Framework\MockObject\MockObject;
use Sabre\VObject\ITip\Message;
use Test\TestCase;
class InvitationResponseControllerTest extends TestCase {
- /** @var InvitationResponseController */
- private $controller;
-
- /** @var IDBConnection|\PHPUnit\Framework\MockObject\MockObject */
- private $dbConnection;
-
- /** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */
- private $request;
-
- /** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */
- private $timeFactory;
-
- /** @var InvitationResponseServer|\PHPUnit\Framework\MockObject\MockObject */
- private $responseServer;
+ private IDBConnection&MockObject $dbConnection;
+ private IRequest&MockObject $request;
+ private ITimeFactory&MockObject $timeFactory;
+ private InvitationResponseServer&MockObject $responseServer;
+ private InvitationResponseController $controller;
protected function setUp(): void {
parent::setUp();
@@ -64,9 +35,7 @@ class InvitationResponseControllerTest extends TestCase {
$this->dbConnection = $this->createMock(IDBConnection::class);
$this->request = $this->createMock(IRequest::class);
$this->timeFactory = $this->createMock(ITimeFactory::class);
- $this->responseServer = $this->getMockBuilder(InvitationResponseServer::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $this->responseServer = $this->createMock(InvitationResponseServer::class);
$this->controller = new InvitationResponseController(
'appName',
@@ -77,16 +46,14 @@ class InvitationResponseControllerTest extends TestCase {
);
}
- public function attendeeProvider(): array {
+ public static function attendeeProvider(): array {
return [
'local attendee' => [false],
'external attendee' => [true]
];
}
- /**
- * @dataProvider attendeeProvider
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('attendeeProvider')]
public function testAccept(bool $isExternalAttendee): void {
$this->buildQueryExpects('TOKEN123', [
'id' => 0,
@@ -148,9 +115,7 @@ EOF;
$this->assertTrue($called);
}
- /**
- * @dataProvider attendeeProvider
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('attendeeProvider')]
public function testAcceptSequence(bool $isExternalAttendee): void {
$this->buildQueryExpects('TOKEN123', [
'id' => 0,
@@ -212,9 +177,7 @@ EOF;
$this->assertTrue($called);
}
- /**
- * @dataProvider attendeeProvider
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('attendeeProvider')]
public function testAcceptRecurrenceId(bool $isExternalAttendee): void {
$this->buildQueryExpects('TOKEN123', [
'id' => 0,
@@ -304,9 +267,7 @@ EOF;
$this->assertEquals([], $response->getParams());
}
- /**
- * @dataProvider attendeeProvider
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('attendeeProvider')]
public function testDecline(bool $isExternalAttendee): void {
$this->buildQueryExpects('TOKEN123', [
'id' => 0,
@@ -375,9 +336,7 @@ EOF;
$this->assertEquals(['token' => 'TOKEN123'], $response->getParams());
}
- /**
- * @dataProvider attendeeProvider
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('attendeeProvider')]
public function testProcessMoreOptionsResult(bool $isExternalAttendee): void {
$this->request->expects($this->once())
->method('getParam')
@@ -445,7 +404,7 @@ EOF;
$this->assertTrue($called);
}
- private function buildQueryExpects($token, $return, $time): void {
+ private function buildQueryExpects(string $token, ?array $return, int $time): void {
$queryBuilder = $this->createMock(IQueryBuilder::class);
$stmt = $this->createMock(IResult::class);
$expr = $this->createMock(IExpressionBuilder::class);