aboutsummaryrefslogtreecommitdiffstats
path: root/apps/provisioning_api/tests/Controller/AppConfigControllerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/provisioning_api/tests/Controller/AppConfigControllerTest.php')
-rw-r--r--apps/provisioning_api/tests/Controller/AppConfigControllerTest.php63
1 files changed, 18 insertions, 45 deletions
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();