Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions apps/dav/tests/unit/CapabilitiesTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand Down
5 changes: 3 additions & 2 deletions apps/dav/tests/unit/ServerTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
Expand All @@ -22,7 +23,7 @@ class ServerTest extends \Test\TestCase {
/**
* @dataProvider providesUris
*/
public function test($uri, array $plugins): void {
public function test(string $uri, array $plugins): void {
/** @var IRequest | \PHPUnit\Framework\MockObject\MockObject $r */
$r = $this->createMock(IRequest::class);
$r->expects($this->any())->method('getRequestUri')->willReturn($uri);
Expand All @@ -33,7 +34,7 @@ public function test($uri, array $plugins): void {
$this->assertNotNull($s->server->getPlugin($plugin));
}
}
public function providesUris() {
public static function providesUris(): array {
return [
'principals' => ['principals/users/admin', ['caldav', 'oc-resource-sharing', 'carddav']],
'calendars' => ['calendars/admin', ['caldav', 'oc-resource-sharing']],
Expand Down
56 changes: 26 additions & 30 deletions apps/dav/tests/unit/Settings/CalDAVSettingsTest.php
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?php

declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
Expand All @@ -15,19 +17,10 @@
use Test\TestCase;

class CalDAVSettingsTest extends TestCase {

/** @var IConfig|MockObject */
private $config;

/** @var IInitialState|MockObject */
private $initialState;

/** @var IURLGenerator|MockObject */
private $urlGenerator;

/** @var IAppManager|MockObject */
private $appManager;

private IConfig&MockObject $config;
private IInitialState&MockObject $initialState;
private IURLGenerator&MockObject $urlGenerator;
private IAppManager&MockObject $appManager;
private CalDAVSettings $settings;

protected function setUp(): void {
Expand All @@ -42,28 +35,32 @@ protected function setUp(): void {

public function testGetForm(): void {
$this->config->method('getAppValue')
->withConsecutive(
['dav', 'sendInvitations', 'yes'],
['dav', 'generateBirthdayCalendar', 'yes'],
['dav', 'sendEventReminders', 'yes'],
['dav', 'sendEventRemindersToSharedUsers', 'yes'],
['dav', 'sendEventRemindersPush', 'yes'],
)
->will($this->onConsecutiveCalls('yes', 'no', 'yes', 'yes', 'yes'));
->willReturnMap([
['dav', 'sendInvitations', 'yes', 'yes'],
['dav', 'generateBirthdayCalendar', 'yes', 'no'],
['dav', 'sendEventReminders', 'yes', 'yes'],
['dav', 'sendEventRemindersToSharedUsers', 'yes', 'yes'],
['dav', 'sendEventRemindersPush', 'yes', 'yes'],
]);
$this->urlGenerator
->expects($this->once())
->method('linkToDocs')
->with('user-sync-calendars')
->willReturn('Some docs URL');

$calls = [
['userSyncCalendarsDocUrl', 'Some docs URL'],
['sendInvitations', true],
['generateBirthdayCalendar', false],
['sendEventReminders', true],
['sendEventRemindersToSharedUsers', true],
['sendEventRemindersPush', true],
];
$this->initialState->method('provideInitialState')
->withConsecutive(
['userSyncCalendarsDocUrl', 'Some docs URL'],
['sendInvitations', true],
['generateBirthdayCalendar', false],
['sendEventReminders', true],
['sendEventRemindersToSharedUsers', true],
['sendEventRemindersPush', true],
);
->willReturnCallback(function () use (&$calls) {
$expected = array_shift($calls);
$this->assertEquals($expected, func_get_args());
});
$result = $this->settings->getForm();

$this->assertInstanceOf(TemplateResponse::class, $result);
Expand All @@ -88,5 +85,4 @@ public function testGetSectionWithoutCaldavBackend(): void {
public function testGetPriority(): void {
$this->assertEquals(10, $this->settings->getPriority());
}

}
31 changes: 15 additions & 16 deletions apps/dav/tests/unit/SystemTag/SystemTagMappingNodeTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php

declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
Expand All @@ -14,30 +15,28 @@
use OCP\SystemTag\ISystemTagManager;
use OCP\SystemTag\ISystemTagObjectMapper;
use OCP\SystemTag\TagNotFoundException;
use PHPUnit\Framework\MockObject\MockObject;

class SystemTagMappingNodeTest extends \Test\TestCase {
private ISystemTagManager $tagManager;
private ISystemTagObjectMapper $tagMapper;
private IUser $user;
private ISystemTagManager&MockObject $tagManager;
private ISystemTagObjectMapper&MockObject $tagMapper;
private IUser&MockObject $user;

protected function setUp(): void {
parent::setUp();

$this->tagManager = $this->getMockBuilder(ISystemTagManager::class)
->getMock();
$this->tagMapper = $this->getMockBuilder(ISystemTagObjectMapper::class)
->getMock();
$this->user = $this->getMockBuilder(IUser::class)
->getMock();
$this->tagManager = $this->createMock(ISystemTagManager::class);
$this->tagMapper = $this->createMock(ISystemTagObjectMapper::class);
$this->user = $this->createMock(IUser::class);
}

public function getMappingNode($tag = null, array $writableNodeIds = []) {
if ($tag === null) {
$tag = new SystemTag(1, 'Test', true, true);
$tag = new SystemTag('1', 'Test', true, true);
}
return new SystemTagMappingNode(
$tag,
123,
'123',
'files',
$this->user,
$this->tagManager,
Expand All @@ -47,7 +46,7 @@ public function getMappingNode($tag = null, array $writableNodeIds = []) {
}

public function testGetters(): void {
$tag = new SystemTag(1, 'Test', true, false);
$tag = new SystemTag('1', 'Test', true, false);
$node = $this->getMappingNode($tag);
$this->assertEquals('1', $node->getName());
$this->assertEquals($tag, $node->getSystemTag());
Expand Down Expand Up @@ -93,16 +92,16 @@ public function testDeleteTagForbidden(): void {
$node->delete();
}

public function tagNodeDeleteProviderPermissionException() {
public static function tagNodeDeleteProviderPermissionException(): array {
return [
[
// cannot unassign invisible tag
new SystemTag(1, 'Original', false, true),
new SystemTag('1', 'Original', false, true),
'Sabre\DAV\Exception\NotFound',
],
[
// cannot unassign non-assignable tag
new SystemTag(1, 'Original', true, false),
new SystemTag('1', 'Original', true, false),
'Sabre\DAV\Exception\Forbidden',
],
];
Expand Down Expand Up @@ -141,7 +140,7 @@ public function testDeleteTagNotFound(): void {

// assuming the tag existed at the time the node was created,
// but got deleted concurrently in the database
$tag = new SystemTag(1, 'Test', true, true);
$tag = new SystemTag('1', 'Test', true, true);
$this->tagManager->expects($this->once())
->method('canUserSeeTag')
->with($tag)
Expand Down
Loading
Loading