2016-12-04 06:41:14 -05:00
|
|
|
<?php
|
2025-05-29 06:19:28 -04:00
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2016-12-04 06:41:14 -05:00
|
|
|
/**
|
2024-05-28 10:42:42 -04:00
|
|
|
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
2016-12-04 06:41:14 -05:00
|
|
|
*/
|
|
|
|
|
namespace OCA\Files\Tests\Activity\Setting;
|
|
|
|
|
|
|
|
|
|
use OCA\Files\Activity\Settings\FavoriteAction;
|
|
|
|
|
use OCA\Files\Activity\Settings\FileChanged;
|
|
|
|
|
use OCP\Activity\ISetting;
|
2025-02-03 09:34:01 -05:00
|
|
|
use OCP\Server;
|
2016-12-04 06:41:14 -05:00
|
|
|
use Test\TestCase;
|
|
|
|
|
|
|
|
|
|
class GenericTest extends TestCase {
|
2025-05-29 06:19:28 -04:00
|
|
|
public static function dataSettings(): array {
|
2016-12-04 06:41:14 -05:00
|
|
|
return [
|
|
|
|
|
[FavoriteAction::class],
|
|
|
|
|
[FileChanged::class],
|
2020-08-11 19:43:12 -04:00
|
|
|
[FileChanged::class],
|
2016-12-04 06:41:14 -05:00
|
|
|
];
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-07 08:21:48 -05:00
|
|
|
#[\PHPUnit\Framework\Attributes\DataProvider(methodName: 'dataSettings')]
|
2025-05-29 06:19:28 -04:00
|
|
|
public function testImplementsInterface(string $settingClass): void {
|
2025-02-03 09:34:01 -05:00
|
|
|
$setting = Server::get($settingClass);
|
2016-12-04 06:41:14 -05:00
|
|
|
$this->assertInstanceOf(ISetting::class, $setting);
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-07 08:21:48 -05:00
|
|
|
#[\PHPUnit\Framework\Attributes\DataProvider(methodName: 'dataSettings')]
|
2025-05-29 06:19:28 -04:00
|
|
|
public function testGetIdentifier(string $settingClass): void {
|
2016-12-04 06:41:14 -05:00
|
|
|
/** @var ISetting $setting */
|
2025-02-03 09:34:01 -05:00
|
|
|
$setting = Server::get($settingClass);
|
2019-11-27 09:27:18 -05:00
|
|
|
$this->assertIsString($setting->getIdentifier());
|
2016-12-04 06:41:14 -05:00
|
|
|
}
|
|
|
|
|
|
2026-01-07 08:21:48 -05:00
|
|
|
#[\PHPUnit\Framework\Attributes\DataProvider(methodName: 'dataSettings')]
|
2025-05-29 06:19:28 -04:00
|
|
|
public function testGetName(string $settingClass): void {
|
2016-12-04 06:41:14 -05:00
|
|
|
/** @var ISetting $setting */
|
2025-02-03 09:34:01 -05:00
|
|
|
$setting = Server::get($settingClass);
|
2019-11-27 09:27:18 -05:00
|
|
|
$this->assertIsString($setting->getName());
|
2016-12-04 06:41:14 -05:00
|
|
|
}
|
|
|
|
|
|
2026-01-07 08:21:48 -05:00
|
|
|
#[\PHPUnit\Framework\Attributes\DataProvider(methodName: 'dataSettings')]
|
2025-05-29 06:19:28 -04:00
|
|
|
public function testGetPriority(string $settingClass): void {
|
2016-12-04 06:41:14 -05:00
|
|
|
/** @var ISetting $setting */
|
2025-02-03 09:34:01 -05:00
|
|
|
$setting = Server::get($settingClass);
|
2016-12-04 06:41:14 -05:00
|
|
|
$priority = $setting->getPriority();
|
2019-11-27 09:27:18 -05:00
|
|
|
$this->assertIsInt($setting->getPriority());
|
2016-12-04 06:41:14 -05:00
|
|
|
$this->assertGreaterThanOrEqual(0, $priority);
|
|
|
|
|
$this->assertLessThanOrEqual(100, $priority);
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-07 08:21:48 -05:00
|
|
|
#[\PHPUnit\Framework\Attributes\DataProvider(methodName: 'dataSettings')]
|
2025-05-29 06:19:28 -04:00
|
|
|
public function testCanChangeStream(string $settingClass): void {
|
2016-12-04 06:41:14 -05:00
|
|
|
/** @var ISetting $setting */
|
2025-02-03 09:34:01 -05:00
|
|
|
$setting = Server::get($settingClass);
|
2019-11-27 09:27:18 -05:00
|
|
|
$this->assertIsBool($setting->canChangeStream());
|
2016-12-04 06:41:14 -05:00
|
|
|
}
|
|
|
|
|
|
2026-01-07 08:21:48 -05:00
|
|
|
#[\PHPUnit\Framework\Attributes\DataProvider(methodName: 'dataSettings')]
|
2025-05-29 06:19:28 -04:00
|
|
|
public function testIsDefaultEnabledStream(string $settingClass): void {
|
2016-12-04 06:41:14 -05:00
|
|
|
/** @var ISetting $setting */
|
2025-02-03 09:34:01 -05:00
|
|
|
$setting = Server::get($settingClass);
|
2019-11-27 09:27:18 -05:00
|
|
|
$this->assertIsBool($setting->isDefaultEnabledStream());
|
2016-12-04 06:41:14 -05:00
|
|
|
}
|
|
|
|
|
|
2026-01-07 08:21:48 -05:00
|
|
|
#[\PHPUnit\Framework\Attributes\DataProvider(methodName: 'dataSettings')]
|
2025-05-29 06:19:28 -04:00
|
|
|
public function testCanChangeMail(string $settingClass): void {
|
2016-12-04 06:41:14 -05:00
|
|
|
/** @var ISetting $setting */
|
2025-02-03 09:34:01 -05:00
|
|
|
$setting = Server::get($settingClass);
|
2019-11-27 09:27:18 -05:00
|
|
|
$this->assertIsBool($setting->canChangeMail());
|
2016-12-04 06:41:14 -05:00
|
|
|
}
|
|
|
|
|
|
2026-01-07 08:21:48 -05:00
|
|
|
#[\PHPUnit\Framework\Attributes\DataProvider(methodName: 'dataSettings')]
|
2025-05-29 06:19:28 -04:00
|
|
|
public function testIsDefaultEnabledMail(string $settingClass): void {
|
2016-12-04 06:41:14 -05:00
|
|
|
/** @var ISetting $setting */
|
2025-02-03 09:34:01 -05:00
|
|
|
$setting = Server::get($settingClass);
|
2019-11-27 09:27:18 -05:00
|
|
|
$this->assertIsBool($setting->isDefaultEnabledMail());
|
2016-12-04 06:41:14 -05:00
|
|
|
}
|
|
|
|
|
}
|