aboutsummaryrefslogtreecommitdiffstats
path: root/apps/settings/tests/Activity
diff options
context:
space:
mode:
Diffstat (limited to 'apps/settings/tests/Activity')
-rw-r--r--apps/settings/tests/Activity/SecurityFilterTest.php25
-rw-r--r--apps/settings/tests/Activity/SecurityProviderTest.php43
-rw-r--r--apps/settings/tests/Activity/SecuritySettingTest.php17
3 files changed, 36 insertions, 49 deletions
diff --git a/apps/settings/tests/Activity/SecurityFilterTest.php b/apps/settings/tests/Activity/SecurityFilterTest.php
index 637c717da02..b07c1e825b4 100644
--- a/apps/settings/tests/Activity/SecurityFilterTest.php
+++ b/apps/settings/tests/Activity/SecurityFilterTest.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -12,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();
@@ -31,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')
@@ -51,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')
@@ -63,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 9d10b1e596e..ed9de362a87 100644
--- a/apps/settings/tests/Activity/SecurityProviderTest.php
+++ b/apps/settings/tests/Activity/SecurityProviderTest.php
@@ -1,12 +1,13 @@
<?php
+
/**
* 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;
@@ -16,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);
@@ -68,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);
@@ -96,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);
@@ -104,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);
@@ -112,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 dd28d757e72..ca11e38caa8 100644
--- a/apps/settings/tests/Activity/SecuritySettingTest.php
+++ b/apps/settings/tests/Activity/SecuritySettingTest.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
@@ -12,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();
@@ -23,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')
@@ -43,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());
}