diff options
Diffstat (limited to 'apps/files/tests/Activity/Setting/GenericTest.php')
-rw-r--r-- | apps/files/tests/Activity/Setting/GenericTest.php | 123 |
1 files changed, 38 insertions, 85 deletions
diff --git a/apps/files/tests/Activity/Setting/GenericTest.php b/apps/files/tests/Activity/Setting/GenericTest.php index a8df291cb80..df6b1e0f6d4 100644 --- a/apps/files/tests/Activity/Setting/GenericTest.php +++ b/apps/files/tests/Activity/Setting/GenericTest.php @@ -1,129 +1,82 @@ <?php + +declare(strict_types=1); /** - * @copyright Copyright (c) 2016 Joas Schilling <coding@schilljs.com> - * - * @author Joas Schilling <coding@schilljs.com> - * - * @license GNU AGPL version 3 or any later version - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as - * published by the Free Software Foundation, either version 3 of the - * License, or (at your option) any later version. - * - * 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 - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * + * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors + * SPDX-License-Identifier: AGPL-3.0-or-later */ - namespace OCA\Files\Tests\Activity\Setting; use OCA\Files\Activity\Settings\FavoriteAction; use OCA\Files\Activity\Settings\FileChanged; -use OCA\Files\Activity\Settings\FileCreated; -use OCA\Files\Activity\Settings\FileDeleted; -use OCA\Files\Activity\Settings\FileFavorite; -use OCA\Files\Activity\Settings\FileRestored; use OCP\Activity\ISetting; +use OCP\Server; use Test\TestCase; class GenericTest extends TestCase { - - public function dataSettings() { + public static function dataSettings(): array { return [ [FavoriteAction::class], [FileChanged::class], - [FileCreated::class], - [FileDeleted::class], - [FileFavorite::class], - [FileRestored::class], + [FileChanged::class], ]; } - /** - * @dataProvider dataSettings - * @param string $settingClass - */ - public function testImplementsInterface($settingClass) { - $setting = \OC::$server->query($settingClass); + #[\PHPUnit\Framework\Attributes\DataProvider('dataSettings')] + public function testImplementsInterface(string $settingClass): void { + $setting = Server::get($settingClass); $this->assertInstanceOf(ISetting::class, $setting); } - /** - * @dataProvider dataSettings - * @param string $settingClass - */ - public function testGetIdentifier($settingClass) { + #[\PHPUnit\Framework\Attributes\DataProvider('dataSettings')] + public function testGetIdentifier(string $settingClass): void { /** @var ISetting $setting */ - $setting = \OC::$server->query($settingClass); - $this->assertInternalType('string', $setting->getIdentifier()); + $setting = Server::get($settingClass); + $this->assertIsString($setting->getIdentifier()); } - /** - * @dataProvider dataSettings - * @param string $settingClass - */ - public function testGetName($settingClass) { + #[\PHPUnit\Framework\Attributes\DataProvider('dataSettings')] + public function testGetName(string $settingClass): void { /** @var ISetting $setting */ - $setting = \OC::$server->query($settingClass); - $this->assertInternalType('string', $setting->getName()); + $setting = Server::get($settingClass); + $this->assertIsString($setting->getName()); } - /** - * @dataProvider dataSettings - * @param string $settingClass - */ - public function testGetPriority($settingClass) { + #[\PHPUnit\Framework\Attributes\DataProvider('dataSettings')] + public function testGetPriority(string $settingClass): void { /** @var ISetting $setting */ - $setting = \OC::$server->query($settingClass); + $setting = Server::get($settingClass); $priority = $setting->getPriority(); - $this->assertInternalType('int', $setting->getPriority()); + $this->assertIsInt($setting->getPriority()); $this->assertGreaterThanOrEqual(0, $priority); $this->assertLessThanOrEqual(100, $priority); } - /** - * @dataProvider dataSettings - * @param string $settingClass - */ - public function testCanChangeStream($settingClass) { + #[\PHPUnit\Framework\Attributes\DataProvider('dataSettings')] + public function testCanChangeStream(string $settingClass): void { /** @var ISetting $setting */ - $setting = \OC::$server->query($settingClass); - $this->assertInternalType('bool', $setting->canChangeStream()); + $setting = Server::get($settingClass); + $this->assertIsBool($setting->canChangeStream()); } - /** - * @dataProvider dataSettings - * @param string $settingClass - */ - public function testIsDefaultEnabledStream($settingClass) { + #[\PHPUnit\Framework\Attributes\DataProvider('dataSettings')] + public function testIsDefaultEnabledStream(string $settingClass): void { /** @var ISetting $setting */ - $setting = \OC::$server->query($settingClass); - $this->assertInternalType('bool', $setting->isDefaultEnabledStream()); + $setting = Server::get($settingClass); + $this->assertIsBool($setting->isDefaultEnabledStream()); } - /** - * @dataProvider dataSettings - * @param string $settingClass - */ - public function testCanChangeMail($settingClass) { + #[\PHPUnit\Framework\Attributes\DataProvider('dataSettings')] + public function testCanChangeMail(string $settingClass): void { /** @var ISetting $setting */ - $setting = \OC::$server->query($settingClass); - $this->assertInternalType('bool', $setting->canChangeMail()); + $setting = Server::get($settingClass); + $this->assertIsBool($setting->canChangeMail()); } - /** - * @dataProvider dataSettings - * @param string $settingClass - */ - public function testIsDefaultEnabledMail($settingClass) { + #[\PHPUnit\Framework\Attributes\DataProvider('dataSettings')] + public function testIsDefaultEnabledMail(string $settingClass): void { /** @var ISetting $setting */ - $setting = \OC::$server->query($settingClass); - $this->assertInternalType('bool', $setting->isDefaultEnabledMail()); + $setting = Server::get($settingClass); + $this->assertIsBool($setting->isDefaultEnabledMail()); } } |