aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/tests/unit/DAV/SystemPrincipalBackendTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/dav/tests/unit/DAV/SystemPrincipalBackendTest.php')
-rw-r--r--apps/dav/tests/unit/DAV/SystemPrincipalBackendTest.php84
1 files changed, 22 insertions, 62 deletions
diff --git a/apps/dav/tests/unit/DAV/SystemPrincipalBackendTest.php b/apps/dav/tests/unit/DAV/SystemPrincipalBackendTest.php
index 05e6699cc4c..3df861accf2 100644
--- a/apps/dav/tests/unit/DAV/SystemPrincipalBackendTest.php
+++ b/apps/dav/tests/unit/DAV/SystemPrincipalBackendTest.php
@@ -1,47 +1,27 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- * @author Thomas Citharel <nextcloud@tcit.fr>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- *
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * 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, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\DAV\Tests\unit\DAV;
use OCA\DAV\DAV\SystemPrincipalBackend;
+use Sabre\DAV\Exception;
use Test\TestCase;
class SystemPrincipalBackendTest extends TestCase {
- /**
- * @dataProvider providesPrefix
- * @param $expected
- * @param $prefix
- */
- public function testGetPrincipalsByPrefix($expected, $prefix) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('providesPrefix')]
+ public function testGetPrincipalsByPrefix(array $expected, string $prefix): void {
$backend = new SystemPrincipalBackend();
$result = $backend->getPrincipalsByPrefix($prefix);
$this->assertEquals($expected, $result);
}
- public function providesPrefix() {
+ public static function providesPrefix(): array {
return [
[[], ''],
[[[
@@ -56,18 +36,14 @@ class SystemPrincipalBackendTest extends TestCase {
];
}
- /**
- * @dataProvider providesPath
- * @param $expected
- * @param $path
- */
- public function testGetPrincipalByPath($expected, $path) {
+ #[\PHPUnit\Framework\Attributes\DataProvider('providesPath')]
+ public function testGetPrincipalByPath(?array $expected, string $path): void {
$backend = new SystemPrincipalBackend();
$result = $backend->getPrincipalByPath($path);
$this->assertEquals($expected, $result);
}
- public function providesPath() {
+ public static function providesPath(): array {
return [
[null, ''],
[null, 'principals'],
@@ -79,60 +55,44 @@ class SystemPrincipalBackendTest extends TestCase {
];
}
- /**
- * @dataProvider providesPrincipalForGetGroupMemberSet
- *
- * @param string $principal
- * @throws \Sabre\DAV\Exception
- */
- public function testGetGroupMemberSetExceptional($principal) {
- $this->expectException(\Sabre\DAV\Exception::class);
+ #[\PHPUnit\Framework\Attributes\DataProvider('providesPrincipalForGetGroupMemberSet')]
+ public function testGetGroupMemberSetExceptional(?string $principal): void {
+ $this->expectException(Exception::class);
$this->expectExceptionMessage('Principal not found');
$backend = new SystemPrincipalBackend();
$backend->getGroupMemberSet($principal);
}
- public function providesPrincipalForGetGroupMemberSet() {
+ public static function providesPrincipalForGetGroupMemberSet(): array {
return [
[null],
['principals/system'],
];
}
- /**
- * @throws \Sabre\DAV\Exception
- */
- public function testGetGroupMemberSet() {
+ public function testGetGroupMemberSet(): void {
$backend = new SystemPrincipalBackend();
$result = $backend->getGroupMemberSet('principals/system/system');
$this->assertEquals(['principals/system/system'], $result);
}
- /**
- * @dataProvider providesPrincipalForGetGroupMembership
- *
- * @param string $principal
- * @throws \Sabre\DAV\Exception
- */
- public function testGetGroupMembershipExceptional($principal) {
- $this->expectException(\Sabre\DAV\Exception::class);
+ #[\PHPUnit\Framework\Attributes\DataProvider('providesPrincipalForGetGroupMembership')]
+ public function testGetGroupMembershipExceptional(string $principal): void {
+ $this->expectException(Exception::class);
$this->expectExceptionMessage('Principal not found');
$backend = new SystemPrincipalBackend();
$backend->getGroupMembership($principal);
}
- public function providesPrincipalForGetGroupMembership() {
+ public static function providesPrincipalForGetGroupMembership(): array {
return [
['principals/system/a'],
];
}
- /**
- * @throws \Sabre\DAV\Exception
- */
- public function testGetGroupMembership() {
+ public function testGetGroupMembership(): void {
$backend = new SystemPrincipalBackend();
$result = $backend->getGroupMembership('principals/system/system');
$this->assertEquals([], $result);