aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/tests/unit/Controller
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dav/tests/unit/Controller')
-rw-r--r--apps/dav/tests/unit/Controller/BirthdayCalendarControllerTest.php52
-rw-r--r--apps/dav/tests/unit/Controller/DirectControllerTest.php31
-rw-r--r--apps/dav/tests/unit/Controller/InvitationResponseControllerTest.php30
-rw-r--r--apps/dav/tests/unit/Controller/UpcomingEventsControllerTest.php7
4 files changed, 46 insertions, 74 deletions
diff --git a/apps/dav/tests/unit/Controller/BirthdayCalendarControllerTest.php b/apps/dav/tests/unit/Controller/BirthdayCalendarControllerTest.php
index c7c2bf0e431..9aa0ef3a2a7 100644
--- a/apps/dav/tests/unit/Controller/BirthdayCalendarControllerTest.php
+++ b/apps/dav/tests/unit/Controller/BirthdayCalendarControllerTest.php
@@ -1,43 +1,33 @@
<?php
+
+declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2017 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\BackgroundJob\GenerateBirthdayCalendarBackgroundJob;
use OCA\DAV\CalDAV\CalDavBackend;
use OCA\DAV\Controller\BirthdayCalendarController;
+use OCP\AppFramework\Http\JSONResponse;
use OCP\BackgroundJob\IJobList;
use OCP\IConfig;
use OCP\IDBConnection;
use OCP\IRequest;
use OCP\IUser;
use OCP\IUserManager;
+use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class BirthdayCalendarControllerTest extends TestCase {
-
- /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
- private $config;
-
- /** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */
- private $request;
-
- /** @var IDBConnection|\PHPUnit\Framework\MockObject\MockObject */
- private $db;
-
- /** @var IJobList|\PHPUnit\Framework\MockObject\MockObject */
- private $jobList;
-
- /** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */
- private $userManager;
-
- /** @var CalDavBackend|\PHPUnit\Framework\MockObject\MockObject */
- private $caldav;
-
- /** @var BirthdayCalendarController|\PHPUnit\Framework\MockObject\MockObject */
- private $controller;
+ private IConfig&MockObject $config;
+ private IRequest&MockObject $request;
+ private IDBConnection&MockObject $db;
+ private IJobList&MockObject $jobList;
+ private IUserManager&MockObject $userManager;
+ private CalDavBackend&MockObject $caldav;
+ private BirthdayCalendarController $controller;
protected function setUp(): void {
parent::setUp();
@@ -74,16 +64,20 @@ class BirthdayCalendarControllerTest extends TestCase {
$closure($user3);
});
+ $calls = [
+ [GenerateBirthdayCalendarBackgroundJob::class, ['userId' => 'uid1']],
+ [GenerateBirthdayCalendarBackgroundJob::class, ['userId' => 'uid2']],
+ [GenerateBirthdayCalendarBackgroundJob::class, ['userId' => 'uid3']],
+ ];
$this->jobList->expects($this->exactly(3))
->method('add')
- ->withConsecutive(
- [GenerateBirthdayCalendarBackgroundJob::class, ['userId' => 'uid1']],
- [GenerateBirthdayCalendarBackgroundJob::class, ['userId' => 'uid2']],
- [GenerateBirthdayCalendarBackgroundJob::class, ['userId' => 'uid3']],
- );
+ ->willReturnCallback(function () use (&$calls): void {
+ $expected = array_shift($calls);
+ $this->assertEquals($expected, func_get_args());
+ });
$response = $this->controller->enable();
- $this->assertInstanceOf('OCP\AppFramework\Http\JSONResponse', $response);
+ $this->assertInstanceOf(JSONResponse::class, $response);
}
public function testDisable(): void {
@@ -97,6 +91,6 @@ class BirthdayCalendarControllerTest extends TestCase {
->method('deleteAllBirthdayCalendars');
$response = $this->controller->disable();
- $this->assertInstanceOf('OCP\AppFramework\Http\JSONResponse', $response);
+ $this->assertInstanceOf(JSONResponse::class, $response);
}
}
diff --git a/apps/dav/tests/unit/Controller/DirectControllerTest.php b/apps/dav/tests/unit/Controller/DirectControllerTest.php
index faaf67d266b..837adde1da7 100644
--- a/apps/dav/tests/unit/Controller/DirectControllerTest.php
+++ b/apps/dav/tests/unit/Controller/DirectControllerTest.php
@@ -6,7 +6,7 @@ declare(strict_types=1);
* 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\Controller\DirectController;
use OCA\DAV\Db\Direct;
@@ -20,29 +20,18 @@ use OCP\Files\File;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
use OCP\IRequest;
-use OCP\IUrlGenerator;
+use OCP\IURLGenerator;
use OCP\Security\ISecureRandom;
+use PHPUnit\Framework\MockObject\MockObject;
use Test\TestCase;
class DirectControllerTest extends TestCase {
-
- /** @var IRootFolder|\PHPUnit\Framework\MockObject\MockObject */
- private $rootFolder;
-
- /** @var DirectMapper|\PHPUnit\Framework\MockObject\MockObject */
- private $directMapper;
-
- /** @var ISecureRandom|\PHPUnit\Framework\MockObject\MockObject */
- private $random;
-
- /** @var ITimeFactory|\PHPUnit\Framework\MockObject\MockObject */
- private $timeFactory;
-
- /** @var IUrlGenerator|\PHPUnit\Framework\MockObject\MockObject */
- private $urlGenerator;
-
- /** @var IEventDispatcher|\PHPUnit\Framework\MockObject\MockObject */
- private $eventDispatcher;
+ private IRootFolder&MockObject $rootFolder;
+ private DirectMapper&MockObject $directMapper;
+ private ISecureRandom&MockObject $random;
+ private ITimeFactory&MockObject $timeFactory;
+ private IURLGenerator&MockObject $urlGenerator;
+ private IEventDispatcher&MockObject $eventDispatcher;
private DirectController $controller;
@@ -53,7 +42,7 @@ class DirectControllerTest extends TestCase {
$this->directMapper = $this->createMock(DirectMapper::class);
$this->random = $this->createMock(ISecureRandom::class);
$this->timeFactory = $this->createMock(ITimeFactory::class);
- $this->urlGenerator = $this->createMock(IUrlGenerator::class);
+ $this->urlGenerator = $this->createMock(IURLGenerator::class);
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
$this->controller = new DirectController(
diff --git a/apps/dav/tests/unit/Controller/InvitationResponseControllerTest.php b/apps/dav/tests/unit/Controller/InvitationResponseControllerTest.php
index 640c66b75e5..895a84b8404 100644
--- a/apps/dav/tests/unit/Controller/InvitationResponseControllerTest.php
+++ b/apps/dav/tests/unit/Controller/InvitationResponseControllerTest.php
@@ -7,7 +7,7 @@ declare(strict_types=1);
* 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;
@@ -18,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();
@@ -43,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',
@@ -56,7 +46,7 @@ class InvitationResponseControllerTest extends TestCase {
);
}
- public function attendeeProvider(): array {
+ public static function attendeeProvider(): array {
return [
'local attendee' => [false],
'external attendee' => [true]
@@ -424,7 +414,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);
diff --git a/apps/dav/tests/unit/Controller/UpcomingEventsControllerTest.php b/apps/dav/tests/unit/Controller/UpcomingEventsControllerTest.php
index bab0ef77bd0..527943e5221 100644
--- a/apps/dav/tests/unit/Controller/UpcomingEventsControllerTest.php
+++ b/apps/dav/tests/unit/Controller/UpcomingEventsControllerTest.php
@@ -7,7 +7,7 @@ declare(strict_types=1);
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
-namespace OCA\DAV\Tests\Unit\DAV\Service;
+namespace OCA\DAV\Tests\unit\DAV\Service;
use OCA\DAV\CalDAV\UpcomingEvent;
use OCA\DAV\CalDAV\UpcomingEventsService;
@@ -17,9 +17,8 @@ use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
class UpcomingEventsControllerTest extends TestCase {
-
- private IRequest|MockObject $request;
- private UpcomingEventsService|MockObject $service;
+ private IRequest&MockObject $request;
+ private UpcomingEventsService&MockObject $service;
protected function setUp(): void {
parent::setUp();