aboutsummaryrefslogtreecommitdiffstats
path: root/apps/provisioning_api/tests
diff options
context:
space:
mode:
Diffstat (limited to 'apps/provisioning_api/tests')
-rw-r--r--apps/provisioning_api/tests/CapabilitiesTest.php15
-rw-r--r--apps/provisioning_api/tests/Controller/AppConfigControllerTest.php63
-rw-r--r--apps/provisioning_api/tests/Controller/AppsControllerTest.php15
-rw-r--r--apps/provisioning_api/tests/Controller/GroupsControllerTest.php56
-rw-r--r--apps/provisioning_api/tests/Controller/UsersControllerTest.php142
-rw-r--r--apps/provisioning_api/tests/Middleware/ProvisioningApiMiddlewareTest.php40
6 files changed, 119 insertions, 212 deletions
diff --git a/apps/provisioning_api/tests/CapabilitiesTest.php b/apps/provisioning_api/tests/CapabilitiesTest.php
index e3c14f37ed7..67a0335829c 100644
--- a/apps/provisioning_api/tests/CapabilitiesTest.php
+++ b/apps/provisioning_api/tests/CapabilitiesTest.php
@@ -1,9 +1,11 @@
<?php
+
+declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2021 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
-namespace OCA\Provisioning_API\Tests\unit;
+namespace OCA\Provisioning_API\Tests;
use OCA\FederatedFileSharing\FederatedShareProvider;
use OCA\Provisioning_API\Capabilities;
@@ -21,11 +23,8 @@ use Test\TestCase;
*/
class CapabilitiesTest extends TestCase {
- /** @var Capabilities */
- protected $capabilities;
-
- /** @var IAppManager|MockObject */
- protected $appManager;
+ protected IAppManager&MockObject $appManager;
+ protected Capabilities $capabilities;
public function setUp(): void {
parent::setUp();
@@ -38,7 +37,7 @@ class CapabilitiesTest extends TestCase {
->willReturn('1.12');
}
- public function getCapabilitiesProvider() {
+ public static function getCapabilitiesProvider(): array {
return [
[true, false, false, true, false],
[true, true, false, true, false],
@@ -52,7 +51,7 @@ class CapabilitiesTest extends TestCase {
/**
* @dataProvider getCapabilitiesProvider
*/
- public function testGetCapabilities($federationAppEnabled, $federatedFileSharingAppEnabled, $lookupServerEnabled, $expectedFederatedScopeEnabled, $expectedPublishedScopeEnabled): void {
+ public function testGetCapabilities(bool $federationAppEnabled, bool $federatedFileSharingAppEnabled, bool $lookupServerEnabled, bool $expectedFederatedScopeEnabled, bool $expectedPublishedScopeEnabled): void {
$this->appManager->expects($this->any())
->method('isEnabledForUser')
->will($this->returnValueMap([
diff --git a/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php b/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php
index 41739b6283f..3d2c1645d25 100644
--- a/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php
+++ b/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php
@@ -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
@@ -30,7 +32,6 @@ use function json_encode;
* @package OCA\Provisioning_API\Tests
*/
class AppConfigControllerTest extends TestCase {
-
private IAppConfig&MockObject $appConfig;
private IUserSession&MockObject $userSession;
private IL10N&MockObject $l10n;
@@ -51,7 +52,7 @@ class AppConfigControllerTest extends TestCase {
/**
* @param string[] $methods
- * @return AppConfigController|\PHPUnit\Framework\MockObject\MockObject
+ * @return AppConfigController|MockObject
*/
protected function getInstance(array $methods = []) {
$request = $this->createMock(IRequest::class);
@@ -79,7 +80,7 @@ class AppConfigControllerTest extends TestCase {
$this->settingManager,
$this->appManager,
])
- ->setMethods($methods)
+ ->onlyMethods($methods)
->getMock();
}
}
@@ -95,7 +96,7 @@ class AppConfigControllerTest extends TestCase {
$this->assertEquals(['data' => ['apps']], $result->getData());
}
- public function dataGetKeys() {
+ public static function dataGetKeys(): array {
return [
['app1 ', null, new \InvalidArgumentException('error'), Http::STATUS_FORBIDDEN],
['app2', ['keys'], null, Http::STATUS_OK],
@@ -104,12 +105,8 @@ class AppConfigControllerTest extends TestCase {
/**
* @dataProvider dataGetKeys
- * @param string $app
- * @param array|null $keys
- * @param \Exception|null $throws
- * @param int $status
*/
- public function testGetKeys($app, $keys, $throws, $status): void {
+ public function testGetKeys(string $app, ?array $keys, ?\Throwable $throws, int $status): void {
$api = $this->getInstance(['verifyAppId']);
if ($throws instanceof \Exception) {
$api->expects($this->once())
@@ -140,7 +137,7 @@ class AppConfigControllerTest extends TestCase {
}
}
- public function dataGetValue() {
+ public static function dataGetValue(): array {
return [
['app1', 'key', 'default', null, new \InvalidArgumentException('error'), Http::STATUS_FORBIDDEN],
['app2', 'key', 'default', 'return', null, Http::STATUS_OK],
@@ -149,14 +146,8 @@ class AppConfigControllerTest extends TestCase {
/**
* @dataProvider dataGetValue
- * @param string $app
- * @param string|null $key
- * @param string|null $default
- * @param string|null $return
- * @param \Exception|null $throws
- * @param int $status
*/
- public function testGetValue($app, $key, $default, $return, $throws, $status): void {
+ public function testGetValue(string $app, string $key, string $default, ?string $return, ?\Throwable $throws, int $status): void {
$api = $this->getInstance(['verifyAppId']);
if ($throws instanceof \Exception) {
$api->expects($this->once())
@@ -184,7 +175,7 @@ class AppConfigControllerTest extends TestCase {
}
}
- public function dataSetValue() {
+ public static function dataSetValue(): array {
return [
['app1', 'key', 'default', new \InvalidArgumentException('error1'), null, Http::STATUS_FORBIDDEN],
['app2', 'key', 'default', null, new \InvalidArgumentException('error2'), Http::STATUS_FORBIDDEN],
@@ -201,14 +192,8 @@ class AppConfigControllerTest extends TestCase {
/**
* @dataProvider dataSetValue
- * @param string $app
- * @param string|null $key
- * @param string|null $value
- * @param \Exception|null $appThrows
- * @param \Exception|null $keyThrows
- * @param int|\Throwable $status
*/
- public function testSetValue($app, $key, $value, $appThrows, $keyThrows, $status, int|\Throwable $type = IAppConfig::VALUE_MIXED): void {
+ public function testSetValue(string $app, string $key, string $value, ?\Throwable $appThrows, ?\Throwable $keyThrows, int $status, int|\Throwable $type = IAppConfig::VALUE_MIXED): void {
$adminUser = $this->createMock(IUser::class);
$adminUser->expects($this->once())
->method('getUid')
@@ -297,7 +282,7 @@ class AppConfigControllerTest extends TestCase {
}
}
- public function dataDeleteValue() {
+ public static function dataDeleteValue(): array {
return [
['app1', 'key', new \InvalidArgumentException('error1'), null, Http::STATUS_FORBIDDEN],
['app2', 'key', null, new \InvalidArgumentException('error2'), Http::STATUS_FORBIDDEN],
@@ -307,13 +292,8 @@ class AppConfigControllerTest extends TestCase {
/**
* @dataProvider dataDeleteValue
- * @param string $app
- * @param string|null $key
- * @param \Exception|null $appThrows
- * @param \Exception|null $keyThrows
- * @param int $status
*/
- public function testDeleteValue($app, $key, $appThrows, $keyThrows, $status): void {
+ public function testDeleteValue(string $app, string $key, ?\Throwable $appThrows, ?\Throwable $keyThrows, int $status): void {
$api = $this->getInstance(['verifyAppId', 'verifyConfigKey']);
if ($appThrows instanceof \Exception) {
$api->expects($this->once())
@@ -367,7 +347,7 @@ class AppConfigControllerTest extends TestCase {
$this->addToAssertionCount(1);
}
- public function dataVerifyAppIdThrows() {
+ public static function dataVerifyAppIdThrows(): array {
return [
['activity..'],
['activity/'],
@@ -378,16 +358,15 @@ class AppConfigControllerTest extends TestCase {
/**
* @dataProvider dataVerifyAppIdThrows
- * @param string $app
*/
- public function testVerifyAppIdThrows($app): void {
+ public function testVerifyAppIdThrows(string $app): void {
$this->expectException(\InvalidArgumentException::class);
$api = $this->getInstance();
$this->invokePrivate($api, 'verifyAppId', [$app]);
}
- public function dataVerifyConfigKey() {
+ public static function dataVerifyConfigKey(): array {
return [
['activity', 'abc', ''],
['dav', 'public_route', ''],
@@ -398,17 +377,14 @@ class AppConfigControllerTest extends TestCase {
/**
* @dataProvider dataVerifyConfigKey
- * @param string $app
- * @param string $key
- * @param string $value
*/
- public function testVerifyConfigKey($app, $key, $value): void {
+ public function testVerifyConfigKey(string $app, string $key, string $value): void {
$api = $this->getInstance();
$this->invokePrivate($api, 'verifyConfigKey', [$app, $key, $value]);
$this->addToAssertionCount(1);
}
- public function dataVerifyConfigKeyThrows() {
+ public static function dataVerifyConfigKeyThrows(): array {
return [
['activity', 'installed_version', ''],
['calendar', 'enabled', ''],
@@ -424,11 +400,8 @@ class AppConfigControllerTest extends TestCase {
/**
* @dataProvider dataVerifyConfigKeyThrows
- * @param string $app
- * @param string $key
- * @param string $value
*/
- public function testVerifyConfigKeyThrows($app, $key, $value): void {
+ public function testVerifyConfigKeyThrows(string $app, string $key, string $value): void {
$this->expectException(\InvalidArgumentException::class);
$api = $this->getInstance();
diff --git a/apps/provisioning_api/tests/Controller/AppsControllerTest.php b/apps/provisioning_api/tests/Controller/AppsControllerTest.php
index bbcabfddd8b..f56be7c4c36 100644
--- a/apps/provisioning_api/tests/Controller/AppsControllerTest.php
+++ b/apps/provisioning_api/tests/Controller/AppsControllerTest.php
@@ -24,12 +24,9 @@ use OCP\Server;
* @package OCA\Provisioning_API\Tests
*/
class AppsControllerTest extends TestCase {
- /** @var IAppManager */
- private $appManager;
- /** @var AppsController */
- private $api;
- /** @var IUserSession */
- private $userSession;
+ private IAppManager $appManager;
+ private AppsController $api;
+ private IUserSession $userSession;
protected function setUp(): void {
parent::setUp();
@@ -38,9 +35,7 @@ class AppsControllerTest extends TestCase {
$this->groupManager = Server::get(IGroupManager::class);
$this->userSession = Server::get(IUserSession::class);
- $request = $this->getMockBuilder(IRequest::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $request = $this->createMock(IRequest::class);
$this->api = new AppsController(
'provisioning_api',
@@ -96,7 +91,7 @@ class AppsControllerTest extends TestCase {
$this->assertEquals(count($disabled), count($data['apps']));
}
-
+
public function testGetAppsInvalidFilter(): void {
$this->expectException(OCSException::class);
$this->expectExceptionCode(101);
diff --git a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php
index 29b098429e8..e4f8b3af183 100644
--- a/apps/provisioning_api/tests/Controller/GroupsControllerTest.php
+++ b/apps/provisioning_api/tests/Controller/GroupsControllerTest.php
@@ -22,30 +22,20 @@ use OCP\IUserManager;
use OCP\IUserSession;
use OCP\L10N\IFactory;
use OCP\UserInterface;
+use PHPUnit\Framework\MockObject\MockObject;
use Psr\Log\LoggerInterface;
class GroupsControllerTest extends \Test\TestCase {
- /** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */
- protected $request;
- /** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */
- protected $userManager;
- /** @var IConfig|\PHPUnit\Framework\MockObject\MockObject */
- protected $config;
- /** @var Manager|\PHPUnit\Framework\MockObject\MockObject */
- protected $groupManager;
- /** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject */
- protected $userSession;
- /** @var IAccountManager|\PHPUnit\Framework\MockObject\MockObject */
- protected $accountManager;
- /** @var ISubAdmin|\PHPUnit\Framework\MockObject\MockObject */
- protected $subAdminManager;
- /** @var IFactory|\PHPUnit\Framework\MockObject\MockObject */
- protected $l10nFactory;
- /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */
- protected $logger;
-
- /** @var GroupsController|\PHPUnit\Framework\MockObject\MockObject */
- protected $api;
+ protected IRequest&MockObject $request;
+ protected IUserManager&MockObject $userManager;
+ protected IConfig&MockObject $config;
+ protected Manager&MockObject $groupManager;
+ protected IUserSession&MockObject $userSession;
+ protected IAccountManager&MockObject $accountManager;
+ protected ISubAdmin&MockObject $subAdminManager;
+ protected IFactory&MockObject $l10nFactory;
+ protected LoggerInterface&MockObject $logger;
+ protected GroupsController&MockObject $api;
private IRootFolder $rootFolder;
@@ -82,16 +72,12 @@ class GroupsControllerTest extends \Test\TestCase {
$this->rootFolder,
$this->logger
])
- ->setMethods(['fillStorageInfo'])
+ ->onlyMethods(['fillStorageInfo'])
->getMock();
}
- /**
- * @param string $gid
- * @return IGroup|\PHPUnit\Framework\MockObject\MockObject
- */
- private function createGroup($gid) {
- $group = $this->getMockBuilder('\OCP\IGroup')->disableOriginalConstructor()->getMock();
+ private function createGroup(string $gid): IGroup&MockObject {
+ $group = $this->createMock(\OCP\IGroup::class);
$group
->method('getGID')
->willReturn($gid);
@@ -116,7 +102,7 @@ class GroupsControllerTest extends \Test\TestCase {
/**
* @param string $uid
- * @return IUser|\PHPUnit\Framework\MockObject\MockObject
+ * @return IUser&MockObject
*/
private function createUser($uid) {
$user = $this->getMockBuilder(IUser::class)->disableOriginalConstructor()->getMock();
@@ -165,7 +151,7 @@ class GroupsControllerTest extends \Test\TestCase {
});
}
- public function dataGetGroups() {
+ public static function dataGetGroups(): array {
return [
[null, 0, 0],
['foo', 0, 0],
@@ -177,12 +163,8 @@ class GroupsControllerTest extends \Test\TestCase {
/**
* @dataProvider dataGetGroups
- *
- * @param string|null $search
- * @param int|null $limit
- * @param int|null $offset
*/
- public function testGetGroups($search, $limit, $offset): void {
+ public function testGetGroups(?string $search, int $limit, int $offset): void {
$groups = [$this->createGroup('group1'), $this->createGroup('group2')];
$search = $search === null ? '' : $search;
@@ -509,7 +491,7 @@ class GroupsControllerTest extends \Test\TestCase {
->method('getUserGroups')
->willReturn([$group]);
- /** @var \PHPUnit\Framework\MockObject\MockObject */
+ /** @var MockObject */
$this->subAdminManager->expects($this->any())
->method('isSubAdminOfGroup')
->willReturn(false);
@@ -554,7 +536,7 @@ class GroupsControllerTest extends \Test\TestCase {
->method('getUserGroups')
->willReturn([$group]);
- /** @var \PHPUnit\Framework\MockObject\MockObject */
+ /** @var MockObject */
$this->subAdminManager->expects($this->any())
->method('isSubAdminOfGroup')
->willReturn(false);
diff --git a/apps/provisioning_api/tests/Controller/UsersControllerTest.php b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
index 7d4f99356b3..80d6d0f6152 100644
--- a/apps/provisioning_api/tests/Controller/UsersControllerTest.php
+++ b/apps/provisioning_api/tests/Controller/UsersControllerTest.php
@@ -46,41 +46,24 @@ use RuntimeException;
use Test\TestCase;
class UsersControllerTest extends TestCase {
- /** @var IUserManager|MockObject */
- protected $userManager;
- /** @var IConfig|MockObject */
- protected $config;
- /** @var Manager|MockObject */
- protected $groupManager;
- /** @var IUserSession|MockObject */
- protected $userSession;
- /** @var LoggerInterface|MockObject */
- protected $logger;
- /** @var UsersController|MockObject */
- protected $api;
- /** @var IAccountManager|MockObject */
- protected $accountManager;
- /** @var ISubAdmin|MockObject */
- protected $subAdminManager;
- /** @var IURLGenerator|MockObject */
- protected $urlGenerator;
- /** @var IRequest|MockObject */
- protected $request;
- /** @var IFactory|MockObject */
- private $l10nFactory;
- /** @var NewUserMailHelper|MockObject */
- private $newUserMailHelper;
- /** @var ISecureRandom|MockObject */
- private $secureRandom;
- /** @var RemoteWipe|MockObject */
- private $remoteWipe;
- /** @var KnownUserService|MockObject */
- private $knownUserService;
- /** @var IEventDispatcher|MockObject */
- private $eventDispatcher;
+ protected IUserManager&MockObject $userManager;
+ protected IConfig&MockObject $config;
+ protected Manager&MockObject $groupManager;
+ protected IUserSession&MockObject $userSession;
+ protected LoggerInterface&MockObject $logger;
+ protected UsersController&MockObject $api;
+ protected IAccountManager&MockObject $accountManager;
+ protected ISubAdmin&MockObject $subAdminManager;
+ protected IURLGenerator&MockObject $urlGenerator;
+ protected IRequest&MockObject $request;
+ private IFactory&MockObject $l10nFactory;
+ private NewUserMailHelper&MockObject $newUserMailHelper;
+ private ISecureRandom&MockObject $secureRandom;
+ private RemoteWipe&MockObject $remoteWipe;
+ private KnownUserService&MockObject $knownUserService;
+ private IEventDispatcher&MockObject $eventDispatcher;
private IRootFolder $rootFolder;
- /** @var IPhoneNumberUtil */
- private $phoneNumberUtil;
+ private IPhoneNumberUtil $phoneNumberUtil;
protected function setUp(): void {
parent::setUp();
@@ -449,10 +432,6 @@ class UsersControllerTest extends TestCase {
$this->groupManager
->expects($this->exactly(2))
->method('groupExists')
- ->withConsecutive(
- ['ExistingGroup'],
- ['NonExistingGroup']
- )
->willReturnMap([
['ExistingGroup', true],
['NonExistingGroup', false]
@@ -798,18 +777,20 @@ class UsersControllerTest extends TestCase {
->method('get')
->with('ExistingGroup')
->willReturn($group);
+
+ $calls = [
+ ['Successful addUser call with userid: NewUser', ['app' => 'ocs_api']],
+ ['Added userid NewUser to group ExistingGroup', ['app' => 'ocs_api']],
+ ];
$this->logger
->expects($this->exactly(2))
->method('info')
- ->withConsecutive(
- ['Successful addUser call with userid: NewUser', ['app' => 'ocs_api']],
- ['Added userid NewUser to group ExistingGroup', ['app' => 'ocs_api']]
- );
+ ->willReturnCallback(function () use (&$calls) {
+ $expected = array_shift($calls);
+ $this->assertEquals($expected, func_get_args());
+ });
- $this->assertTrue(key_exists(
- 'id',
- $this->api->addUser('NewUser', 'PasswordOfTheNewUser', '', '', ['ExistingGroup'])->getData()
- ));
+ $this->assertArrayHasKey('id', $this->api->addUser('NewUser', 'PasswordOfTheNewUser', '', '', ['ExistingGroup'])->getData());
}
@@ -966,11 +947,10 @@ class UsersControllerTest extends TestCase {
$this->groupManager
->expects($this->exactly(2))
->method('groupExists')
- ->withConsecutive(
- ['ExistingGroup1'],
- ['ExistingGroup2']
- )
- ->willReturn(true);
+ ->willReturnMap([
+ ['ExistingGroup1', true],
+ ['ExistingGroup2', true]
+ ]);
$user = $this->getMockBuilder(IUser::class)
->disableOriginalConstructor()
->getMock();
@@ -996,24 +976,23 @@ class UsersControllerTest extends TestCase {
$this->groupManager
->expects($this->exactly(4))
->method('get')
- ->withConsecutive(
- ['ExistingGroup1'],
- ['ExistingGroup2'],
- ['ExistingGroup1'],
- ['ExistingGroup2']
- )
->willReturnMap([
['ExistingGroup1', $existingGroup1],
['ExistingGroup2', $existingGroup2]
]);
+
+ $calls = [
+ ['Successful addUser call with userid: NewUser', ['app' => 'ocs_api']],
+ ['Added userid NewUser to group ExistingGroup1', ['app' => 'ocs_api']],
+ ['Added userid NewUser to group ExistingGroup2', ['app' => 'ocs_api']],
+ ];
$this->logger
->expects($this->exactly(3))
->method('info')
- ->withConsecutive(
- ['Successful addUser call with userid: NewUser', ['app' => 'ocs_api']],
- ['Added userid NewUser to group ExistingGroup1', ['app' => 'ocs_api']],
- ['Added userid NewUser to group ExistingGroup2', ['app' => 'ocs_api']]
- );
+ ->willReturnCallback(function () use (&$calls) {
+ $expected = array_shift($calls);
+ $this->assertEquals($expected, func_get_args());
+ });
$subAdminManager = $this->getMockBuilder('OC\SubAdmin')
->disableOriginalConstructor()->getMock();
$this->groupManager
@@ -1023,16 +1002,12 @@ class UsersControllerTest extends TestCase {
$subAdminManager
->expects($this->exactly(2))
->method('isSubAdminOfGroup')
- ->withConsecutive(
- [$loggedInUser, $existingGroup1],
- [$loggedInUser, $existingGroup2]
- )
- ->willReturn(true);
+ ->willReturnMap([
+ [$loggedInUser, $existingGroup1, true],
+ [$loggedInUser, $existingGroup2, true],
+ ]);
- $this->assertTrue(key_exists(
- 'id',
- $this->api->addUser('NewUser', 'PasswordOfTheNewUser', '', '', ['ExistingGroup1', 'ExistingGroup2'])->getData()
- ));
+ $this->assertArrayHasKey('id', $this->api->addUser('NewUser', 'PasswordOfTheNewUser', '', '', ['ExistingGroup1', 'ExistingGroup2'])->getData());
}
@@ -1541,7 +1516,7 @@ class UsersControllerTest extends TestCase {
$this->assertEquals($expected, $this->invokePrivate($this->api, 'getUserData', ['UID']));
}
- public function dataSearchByPhoneNumbers(): array {
+ public static function dataSearchByPhoneNumbers(): array {
return [
'Invalid country' => ['Not a country code', ['12345' => ['NaN']], 400, null, null, []],
'No number to search' => ['DE', ['12345' => ['NaN']], 200, null, null, []],
@@ -1556,10 +1531,6 @@ class UsersControllerTest extends TestCase {
/**
* @dataProvider dataSearchByPhoneNumbers
- * @param string $location
- * @param array $search
- * @param int $status
- * @param array $expected
*/
public function testSearchByPhoneNumbers(string $location, array $search, int $status, ?array $searchUsers, ?array $userMatches, array $expected): void {
$knownTo = 'knownTo';
@@ -1870,7 +1841,7 @@ class UsersControllerTest extends TestCase {
$this->api->editUser('UserToEdit', 'email', 'demo.org');
}
- public function selfEditChangePropertyProvider() {
+ public static function selfEditChangePropertyProvider(): array {
return [
[IAccountManager::PROPERTY_TWITTER, '@oldtwitter', '@newtwitter'],
[IAccountManager::PROPERTY_FEDIVERSE, '@oldFediverse@floss.social', '@newFediverse@floss.social'],
@@ -2294,7 +2265,7 @@ class UsersControllerTest extends TestCase {
$this->assertEquals([], $this->api->editUser('UserToEdit', 'language', 'de')->getData());
}
- public function dataEditUserSelfEditChangeLanguageButForced() {
+ public static function dataEditUserSelfEditChangeLanguageButForced(): array {
return [
['de'],
[true],
@@ -3942,11 +3913,10 @@ class UsersControllerTest extends TestCase {
$api->expects($this->exactly(2))
->method('getUserData')
- ->withConsecutive(
- ['uid', false],
- ['currentuser', true],
- )
- ->willReturn($expected);
+ ->willReturnMap([
+ ['uid', false, $expected],
+ ['currentuser', true, $expected],
+ ]);
$this->assertSame($expected, $api->getUser('uid')->getData());
@@ -4263,7 +4233,7 @@ class UsersControllerTest extends TestCase {
}
- public function dataGetEditableFields() {
+ public static function dataGetEditableFields(): array {
return [
[false, true, ISetDisplayNameBackend::class, [
IAccountManager::PROPERTY_EMAIL,
@@ -4388,10 +4358,6 @@ class UsersControllerTest extends TestCase {
/**
* @dataProvider dataGetEditableFields
- *
- * @param bool $allowedToChangeDisplayName
- * @param string $userBackend
- * @param array $expected
*/
public function testGetEditableFields(bool $allowedToChangeDisplayName, bool $allowedToChangeEmail, string $userBackend, array $expected): void {
$this->config->method('getSystemValue')->willReturnCallback(fn (string $key, mixed $default) => match ($key) {
diff --git a/apps/provisioning_api/tests/Middleware/ProvisioningApiMiddlewareTest.php b/apps/provisioning_api/tests/Middleware/ProvisioningApiMiddlewareTest.php
index d097febb04f..d40aab90d66 100644
--- a/apps/provisioning_api/tests/Middleware/ProvisioningApiMiddlewareTest.php
+++ b/apps/provisioning_api/tests/Middleware/ProvisioningApiMiddlewareTest.php
@@ -24,34 +24,29 @@ class ProvisioningApiMiddlewareTest extends TestCase {
$this->reflector = $this->createMock(IControllerMethodReflector::class);
}
- public function dataAnnotation() {
+ public static function dataAnnotation(): array {
return [
[false, false, false, false, false],
- [false, false, true, false, false],
- [false, true, true, false, false],
- [ true, false, false, false, true],
- [ true, false, true, false, false],
- [ true, true, false, false, false],
- [ true, true, true, false, false],
+ [false, false, true, false, false],
+ [false, true, true, false, false],
+ [true, false, false, false, true],
+ [true, false, true, false, false],
+ [true, true, false, false, false],
+ [true, true, true, false, false],
[false, false, false, true, false],
- [false, false, true, true, false],
- [false, true, true, true, false],
- [ true, false, false, true, false],
- [ true, false, true, true, false],
- [ true, true, false, true, false],
- [ true, true, true, true, false],
+ [false, false, true, true, false],
+ [false, true, true, true, false],
+ [true, false, false, true, false],
+ [true, false, true, true, false],
+ [true, true, false, true, false],
+ [true, true, true, true, false],
];
}
/**
* @dataProvider dataAnnotation
- *
- * @param bool $subadminRequired
- * @param bool $isAdmin
- * @param bool $isSubAdmin
- * @param bool $shouldThrowException
*/
- public function testBeforeController($subadminRequired, $isAdmin, $isSubAdmin, $hasSettingAuthorizationAnnotation, $shouldThrowException): void {
+ public function testBeforeController(bool $subadminRequired, bool $isAdmin, bool $isSubAdmin, bool $hasSettingAuthorizationAnnotation, bool $shouldThrowException): void {
$middleware = new ProvisioningApiMiddleware(
$this->reflector,
$isAdmin,
@@ -80,7 +75,7 @@ class ProvisioningApiMiddlewareTest extends TestCase {
}
}
- public function dataAfterException() {
+ public static function dataAfterException(): array {
return [
[new NotSubAdminException(), false],
[new \Exception('test', 42), true],
@@ -89,11 +84,8 @@ class ProvisioningApiMiddlewareTest extends TestCase {
/**
* @dataProvider dataAfterException
- *
- * @param \Exception $e
- * @param bool $forwared
*/
- public function testAfterException(\Exception $exception, $forwared): void {
+ public function testAfterException(\Exception $exception, bool $forwared): void {
$middleware = new ProvisioningApiMiddleware(
$this->reflector,
false,