diff options
Diffstat (limited to 'apps/settings/tests/Activity')
-rw-r--r-- | apps/settings/tests/Activity/SecurityFilterTest.php | 47 | ||||
-rw-r--r-- | apps/settings/tests/Activity/SecurityProviderTest.php | 66 | ||||
-rw-r--r-- | apps/settings/tests/Activity/SecuritySettingTest.php | 39 |
3 files changed, 42 insertions, 110 deletions
diff --git a/apps/settings/tests/Activity/SecurityFilterTest.php b/apps/settings/tests/Activity/SecurityFilterTest.php index 6903cf5f3c2..b07c1e825b4 100644 --- a/apps/settings/tests/Activity/SecurityFilterTest.php +++ b/apps/settings/tests/Activity/SecurityFilterTest.php @@ -1,25 +1,8 @@ <?php + /** - * @copyright Copyright (c) 2016 Christoph Wurst <christoph@winzerhof-wurst.at> - * - * @author Christoph Wurst <christoph@winzerhof-wurst.at> - * @author Roeland Jago Douma <roeland@famdouma.nl> - * - * @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\Settings\Tests; @@ -30,15 +13,9 @@ use PHPUnit\Framework\MockObject\MockObject; use Test\TestCase; class SecurityFilterTest extends TestCase { - - /** @var IURLGenerator|MockObject */ - private $urlGenerator; - - /** @var IL10N|MockObject */ - private $l10n; - - /** @var SecurityFilter */ - private $filter; + private IURLGenerator&MockObject $urlGenerator; + private IL10N&MockObject $l10n; + private SecurityFilter $filter; protected function setUp(): void { parent::setUp(); @@ -49,15 +26,15 @@ class SecurityFilterTest extends TestCase { $this->filter = new SecurityFilter($this->urlGenerator, $this->l10n); } - public function testAllowedApps() { + public function testAllowedApps(): void { $this->assertEquals([], $this->filter->allowedApps()); } - public function testFilterTypes() { + public function testFilterTypes(): void { $this->assertEquals(['security'], $this->filter->filterTypes(['comments', 'security'])); } - public function testGetIcon() { + public function testGetIcon(): void { $this->urlGenerator->expects($this->once()) ->method('imagePath') ->with('core', 'actions/password.svg') @@ -69,11 +46,11 @@ class SecurityFilterTest extends TestCase { $this->assertEquals('abs/path/to/icon.svg', $this->filter->getIcon()); } - public function testGetIdentifier() { + public function testGetIdentifier(): void { $this->assertEquals('security', $this->filter->getIdentifier()); } - public function testGetName() { + public function testGetName(): void { $this->l10n->expects($this->once()) ->method('t') ->with('Security') @@ -81,7 +58,7 @@ class SecurityFilterTest extends TestCase { $this->assertEquals('translated', $this->filter->getName()); } - public function testGetPriority() { + public function testGetPriority(): void { $this->assertEquals(30, $this->filter->getPriority()); } } diff --git a/apps/settings/tests/Activity/SecurityProviderTest.php b/apps/settings/tests/Activity/SecurityProviderTest.php index 4499e470c2b..ed9de362a87 100644 --- a/apps/settings/tests/Activity/SecurityProviderTest.php +++ b/apps/settings/tests/Activity/SecurityProviderTest.php @@ -1,31 +1,13 @@ <?php + /** - * @copyright Copyright (c) 2016 Christoph Wurst <christoph@winzerhof-wurst.at> - * - * @author Christoph Wurst <christoph@winzerhof-wurst.at> - * @author Joas Schilling <coding@schilljs.com> - * @author Roeland Jago Douma <roeland@famdouma.nl> - * - * @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\Settings\Tests; -use InvalidArgumentException; use OCA\Settings\Activity\SecurityProvider; +use OCP\Activity\Exceptions\UnknownActivityException; use OCP\Activity\IEvent; use OCP\Activity\IManager; use OCP\IL10N; @@ -35,51 +17,41 @@ use PHPUnit\Framework\MockObject\MockObject; use Test\TestCase; class SecurityProviderTest extends TestCase { - - /** @var IFactory|MockObject */ - private $l10n; - - /** @var IURLGenerator|MockObject */ - private $urlGenerator; - - /** @var IManager|MockObject */ - private $activityManager; - - /** @var SecurityProvider */ - private $provider; + private IFactory&MockObject $l10nFactory; + private IURLGenerator&MockObject $urlGenerator; + private IManager&MockObject $activityManager; + private SecurityProvider $provider; protected function setUp(): void { parent::setUp(); - $this->l10n = $this->createMock(IFactory::class); + $this->l10nFactory = $this->createMock(IFactory::class); $this->urlGenerator = $this->createMock(IURLGenerator::class); $this->activityManager = $this->createMock(IManager::class); - $this->provider = new SecurityProvider($this->l10n, $this->urlGenerator, $this->activityManager); + $this->provider = new SecurityProvider($this->l10nFactory, $this->urlGenerator, $this->activityManager); } - public function testParseUnrelated() { + public function testParseUnrelated(): void { $lang = 'ru'; $event = $this->createMock(IEvent::class); $event->expects($this->once()) ->method('getType') ->willReturn('comments'); - $this->expectException(InvalidArgumentException::class); + $this->expectException(UnknownActivityException::class); $this->provider->parse($lang, $event); } - public function subjectData() { + public static function subjectData(): array { return [ ['twofactor_success'], ['twofactor_failed'], ]; } - /** - * @dataProvider subjectData - */ - public function testParse($subject) { + #[\PHPUnit\Framework\Attributes\DataProvider('subjectData')] + public function testParse(string $subject): void { $lang = 'ru'; $event = $this->createMock(IEvent::class); $l = $this->createMock(IL10N::class); @@ -87,7 +59,7 @@ class SecurityProviderTest extends TestCase { $event->expects($this->once()) ->method('getType') ->willReturn('security'); - $this->l10n->expects($this->once()) + $this->l10nFactory->expects($this->once()) ->method('get') ->with('settings', $lang) ->willReturn($l); @@ -115,7 +87,7 @@ class SecurityProviderTest extends TestCase { $this->provider->parse($lang, $event); } - public function testParseInvalidSubject() { + public function testParseInvalidSubject(): void { $lang = 'ru'; $l = $this->createMock(IL10N::class); $event = $this->createMock(IEvent::class); @@ -123,7 +95,7 @@ class SecurityProviderTest extends TestCase { $event->expects($this->once()) ->method('getType') ->willReturn('security'); - $this->l10n->expects($this->once()) + $this->l10nFactory->expects($this->once()) ->method('get') ->with('settings', $lang) ->willReturn($l); @@ -131,7 +103,7 @@ class SecurityProviderTest extends TestCase { ->method('getSubject') ->willReturn('unrelated'); - $this->expectException(InvalidArgumentException::class); + $this->expectException(UnknownActivityException::class); $this->provider->parse($lang, $event); } } diff --git a/apps/settings/tests/Activity/SecuritySettingTest.php b/apps/settings/tests/Activity/SecuritySettingTest.php index 840f228b0c1..ca11e38caa8 100644 --- a/apps/settings/tests/Activity/SecuritySettingTest.php +++ b/apps/settings/tests/Activity/SecuritySettingTest.php @@ -1,25 +1,8 @@ <?php + /** - * @copyright Copyright (c) 2016 Christoph Wurst <christoph@winzerhof-wurst.at> - * - * @author Christoph Wurst <christoph@winzerhof-wurst.at> - * @author Roeland Jago Douma <roeland@famdouma.nl> - * - * @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\Settings\Tests; @@ -30,8 +13,8 @@ use Test\TestCase; class SecuritySettingTest extends TestCase { private $l10n; - /** @var SecuritySetting */ - private $setting; + /** @var */ + private SecuritySetting $setting; protected function setUp(): void { parent::setUp(); @@ -41,19 +24,19 @@ class SecuritySettingTest extends TestCase { $this->setting = new SecuritySetting($this->l10n); } - public function testCanChangeMail() { + public function testCanChangeMail(): void { $this->assertFalse($this->setting->canChangeMail()); } - public function testCanChangeStream() { + public function testCanChangeStream(): void { $this->assertFalse($this->setting->canChangeStream()); } - public function testGetIdentifier() { + public function testGetIdentifier(): void { $this->assertEquals('security', $this->setting->getIdentifier()); } - public function testGetName() { + public function testGetName(): void { $this->l10n->expects($this->once()) ->method('t') ->with('Security') @@ -61,11 +44,11 @@ class SecuritySettingTest extends TestCase { $this->assertEquals('Sicherheit', $this->setting->getName()); } - public function testGetPriority() { + public function testGetPriority(): void { $this->assertEquals(30, $this->setting->getPriority()); } - public function testIsDefaultEnabled() { + public function testIsDefaultEnabled(): void { $this->assertTrue($this->setting->isDefaultEnabledMail()); $this->assertTrue($this->setting->isDefaultEnabledStream()); } |