aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/Encryption/ManagerTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/Encryption/ManagerTest.php')
-rw-r--r--tests/lib/Encryption/ManagerTest.php33
1 files changed, 20 insertions, 13 deletions
diff --git a/tests/lib/Encryption/ManagerTest.php b/tests/lib/Encryption/ManagerTest.php
index 5d8cf02f94d..e9b6ddae8a0 100644
--- a/tests/lib/Encryption/ManagerTest.php
+++ b/tests/lib/Encryption/ManagerTest.php
@@ -1,7 +1,14 @@
<?php
+/**
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
+ */
namespace Test\Encryption;
+use OC\Encryption\Exceptions\ModuleAlreadyExistsException;
+use OC\Encryption\Exceptions\ModuleDoesNotExistsException;
use OC\Encryption\Manager;
use OC\Encryption\Util;
use OC\Files\View;
@@ -45,16 +52,16 @@ class ManagerTest extends TestCase {
$this->manager = new Manager($this->config, $this->logger, $this->l10n, $this->view, $this->util, $this->arrayCache);
}
- public function testManagerIsDisabled() {
+ public function testManagerIsDisabled(): void {
$this->assertFalse($this->manager->isEnabled());
}
- public function testManagerIsDisabledIfEnabledButNoModules() {
+ public function testManagerIsDisabledIfEnabledButNoModules(): void {
$this->config->expects($this->any())->method('getAppValue')->willReturn(true);
$this->assertFalse($this->manager->isEnabled());
}
- public function testManagerIsDisabledIfDisabledButModules() {
+ public function testManagerIsDisabledIfDisabledButModules(): void {
$this->config->expects($this->any())->method('getAppValue')->willReturn(false);
$em = $this->createMock(IEncryptionModule::class);
$em->expects($this->any())->method('getId')->willReturn('id');
@@ -65,7 +72,7 @@ class ManagerTest extends TestCase {
$this->assertFalse($this->manager->isEnabled());
}
- public function testManagerIsEnabled() {
+ public function testManagerIsEnabled(): void {
$this->config->expects($this->any())->method('getSystemValueBool')->willReturn(true);
$this->config->expects($this->any())->method('getAppValue')->willReturn('yes');
$this->assertTrue($this->manager->isEnabled());
@@ -83,14 +90,14 @@ class ManagerTest extends TestCase {
/**
* @depends testModuleRegistration
*/
- public function testModuleReRegistration($manager) {
- $this->expectException(\OC\Encryption\Exceptions\ModuleAlreadyExistsException::class);
+ public function testModuleReRegistration($manager): void {
+ $this->expectException(ModuleAlreadyExistsException::class);
$this->expectExceptionMessage('Id "ID0" already used by encryption module "TestDummyModule0"');
$this->addNewEncryptionModule($manager, 0);
}
- public function testModuleUnRegistration() {
+ public function testModuleUnRegistration(): void {
$this->config->expects($this->any())->method('getAppValue')->willReturn(true);
$this->addNewEncryptionModule($this->manager, 0);
$this->assertCount(1, $this->manager->getEncryptionModules());
@@ -100,8 +107,8 @@ class ManagerTest extends TestCase {
}
- public function testGetEncryptionModuleUnknown() {
- $this->expectException(\OC\Encryption\Exceptions\ModuleDoesNotExistsException::class);
+ public function testGetEncryptionModuleUnknown(): void {
+ $this->expectException(ModuleDoesNotExistsException::class);
$this->expectExceptionMessage('Module with ID: unknown does not exist.');
$this->config->expects($this->any())->method('getAppValue')->willReturn(true);
@@ -110,7 +117,7 @@ class ManagerTest extends TestCase {
$this->manager->getEncryptionModule('unknown');
}
- public function testGetEncryptionModuleEmpty() {
+ public function testGetEncryptionModuleEmpty(): void {
global $defaultId;
$defaultId = null;
@@ -134,7 +141,7 @@ class ManagerTest extends TestCase {
$this->assertEquals('ID1', $this->manager->getEncryptionModule()->getId());
}
- public function testGetEncryptionModule() {
+ public function testGetEncryptionModule(): void {
global $defaultId;
$defaultId = null;
@@ -159,7 +166,7 @@ class ManagerTest extends TestCase {
$this->assertEquals('ID0', $this->manager->getDefaultEncryptionModuleId());
}
- public function testSetDefaultEncryptionModule() {
+ public function testSetDefaultEncryptionModule(): void {
global $defaultId;
$defaultId = null;
@@ -259,7 +266,7 @@ class ManagerTest extends TestCase {
$encryptionModule->expects($this->any())
->method('getDisplayName')
->willReturn('TestDummyModule' . $id);
- /** @var \OCP\Encryption\IEncryptionModule $encryptionModule */
+ /** @var IEncryptionModule $encryptionModule */
$manager->registerEncryptionModule('ID' . $id, 'TestDummyModule' . $id, function () use ($encryptionModule) {
return $encryptionModule;
});