aboutsummaryrefslogtreecommitdiffstats
path: root/tests/Core/Command/Encryption
diff options
context:
space:
mode:
Diffstat (limited to 'tests/Core/Command/Encryption')
-rw-r--r--tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php22
-rw-r--r--tests/Core/Command/Encryption/DecryptAllTest.php17
-rw-r--r--tests/Core/Command/Encryption/DisableTest.php5
-rw-r--r--tests/Core/Command/Encryption/EnableTest.php5
-rw-r--r--tests/Core/Command/Encryption/EncryptAllTest.php11
-rw-r--r--tests/Core/Command/Encryption/SetDefaultModuleTest.php7
6 files changed, 32 insertions, 35 deletions
diff --git a/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php b/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php
index 8232db70504..0bc6cbb64cf 100644
--- a/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php
+++ b/tests/Core/Command/Encryption/ChangeKeyStorageRootTest.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -8,6 +9,7 @@
namespace Tests\Core\Command\Encryption;
use OC\Core\Command\Encryption\ChangeKeyStorageRoot;
+use OC\Encryption\Keys\Storage;
use OC\Encryption\Util;
use OC\Files\View;
use OCP\IConfig;
@@ -44,7 +46,7 @@ class ChangeKeyStorageRootTest extends TestCase {
/** @var OutputInterface | \PHPUnit\Framework\MockObject\MockObject */
protected $outputInterface;
- /** @var \OCP\UserInterface | \PHPUnit\Framework\MockObject\MockObject */
+ /** @var UserInterface|\PHPUnit\Framework\MockObject\MockObject */
protected $userInterface;
protected function setUp(): void {
@@ -76,9 +78,7 @@ class ChangeKeyStorageRootTest extends TestCase {
);
}
- /**
- * @dataProvider dataTestExecute
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestExecute')]
public function testExecute($newRoot, $answer, $successMoveKey): void {
$changeKeyStorageRoot = $this->getMockBuilder('OC\Core\Command\Encryption\ChangeKeyStorageRoot')
->setConstructorArgs(
@@ -133,7 +133,7 @@ class ChangeKeyStorageRootTest extends TestCase {
}
public function testMoveAllKeys(): void {
- /** @var \OC\Core\Command\Encryption\ChangeKeyStorageRoot $changeKeyStorageRoot */
+ /** @var ChangeKeyStorageRoot $changeKeyStorageRoot */
$changeKeyStorageRoot = $this->getMockBuilder('OC\Core\Command\Encryption\ChangeKeyStorageRoot')
->setConstructorArgs(
[
@@ -157,18 +157,18 @@ class ChangeKeyStorageRootTest extends TestCase {
->willReturn(true);
$this->view->expects($this->once())->method('file_put_contents')
- ->with('newRoot/' . \OC\Encryption\Keys\Storage::KEY_STORAGE_MARKER,
+ ->with('newRoot/' . Storage::KEY_STORAGE_MARKER,
'Nextcloud will detect this folder as key storage root only if this file exists')->willReturn(true);
$this->invokePrivate($this->changeKeyStorageRoot, 'prepareNewRoot', ['newRoot']);
}
/**
- * @dataProvider dataTestPrepareNewRootException
*
* @param bool $dirExists
* @param bool $couldCreateFile
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestPrepareNewRootException')]
public function testPrepareNewRootException($dirExists, $couldCreateFile): void {
$this->expectException(\Exception::class);
@@ -188,12 +188,12 @@ class ChangeKeyStorageRootTest extends TestCase {
}
/**
- * @dataProvider dataTestMoveSystemKeys
*
* @param bool $dirExists
* @param bool $targetExists
* @param bool $executeRename
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestMoveSystemKeys')]
public function testMoveSystemKeys($dirExists, $targetExists, $executeRename): void {
$changeKeyStorageRoot = $this->getMockBuilder('OC\Core\Command\Encryption\ChangeKeyStorageRoot')
->setConstructorArgs(
@@ -254,13 +254,13 @@ class ChangeKeyStorageRootTest extends TestCase {
}
/**
- * @dataProvider dataTestMoveUserEncryptionFolder
*
* @param bool $userExists
* @param bool $isDir
* @param bool $targetExists
* @param bool $shouldRename
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestMoveUserEncryptionFolder')]
public function testMoveUserEncryptionFolder($userExists, $isDir, $targetExists, $shouldRename): void {
$changeKeyStorageRoot = $this->getMockBuilder('OC\Core\Command\Encryption\ChangeKeyStorageRoot')
->setConstructorArgs(
@@ -306,9 +306,7 @@ class ChangeKeyStorageRootTest extends TestCase {
}
- /**
- * @dataProvider dataTestPrepareParentFolder
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestPrepareParentFolder')]
public function testPrepareParentFolder($path, $pathExists): void {
$this->view->expects($this->any())->method('file_exists')
->willReturnCallback(
diff --git a/tests/Core/Command/Encryption/DecryptAllTest.php b/tests/Core/Command/Encryption/DecryptAllTest.php
index 45b331efb59..41d9e4c713f 100644
--- a/tests/Core/Command/Encryption/DecryptAllTest.php
+++ b/tests/Core/Command/Encryption/DecryptAllTest.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -17,13 +18,13 @@ use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase;
class DecryptAllTest extends TestCase {
- /** @var \PHPUnit\Framework\MockObject\MockObject | \OCP\IConfig */
+ /** @var \PHPUnit\Framework\MockObject\MockObject|IConfig */
protected $config;
/** @var \PHPUnit\Framework\MockObject\MockObject | \OCP\Encryption\IManager */
protected $encryptionManager;
- /** @var \PHPUnit\Framework\MockObject\MockObject | \OCP\App\IAppManager */
+ /** @var \PHPUnit\Framework\MockObject\MockObject|IAppManager */
protected $appManager;
/** @var \PHPUnit\Framework\MockObject\MockObject | \Symfony\Component\Console\Input\InputInterface */
@@ -79,7 +80,7 @@ class DecryptAllTest extends TestCase {
];
$this->config->expects($this->exactly(2))
->method('setSystemValue')
- ->willReturnCallback(function () use (&$calls) {
+ ->willReturnCallback(function () use (&$calls): void {
$expected = array_shift($calls);
$this->assertEquals($expected, func_get_args());
});
@@ -109,9 +110,7 @@ class DecryptAllTest extends TestCase {
$this->invokePrivate($instance, 'resetMaintenanceAndTrashbin');
}
- /**
- * @dataProvider dataTestExecute
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestExecute')]
public function testExecute($encryptionEnabled, $continue): void {
$instance = new DecryptAll(
$this->encryptionManager,
@@ -137,7 +136,7 @@ class DecryptAllTest extends TestCase {
];
$this->config->expects($this->exactly(2))
->method('setAppValue')
- ->willReturnCallback(function () use (&$calls) {
+ ->willReturnCallback(function () use (&$calls): void {
$expected = array_shift($calls);
$this->assertEquals($expected, func_get_args());
});
@@ -188,7 +187,7 @@ class DecryptAllTest extends TestCase {
];
$this->config->expects($this->exactly(2))
->method('setAppValue')
- ->willReturnCallback(function () use (&$calls) {
+ ->willReturnCallback(function () use (&$calls): void {
$expected = array_shift($calls);
$this->assertEquals($expected, func_get_args());
});
@@ -208,7 +207,7 @@ class DecryptAllTest extends TestCase {
$this->decryptAll->expects($this->once())
->method('decryptAll')
->with($this->consoleInput, $this->consoleOutput, 'user1')
- ->willReturnCallback(function () {
+ ->willReturnCallback(function (): void {
throw new \Exception();
});
diff --git a/tests/Core/Command/Encryption/DisableTest.php b/tests/Core/Command/Encryption/DisableTest.php
index 4cbc92a5f8a..a89fd636e47 100644
--- a/tests/Core/Command/Encryption/DisableTest.php
+++ b/tests/Core/Command/Encryption/DisableTest.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -33,7 +34,7 @@ class DisableTest extends TestCase {
$this->consoleInput = $this->getMockBuilder(InputInterface::class)->getMock();
$this->consoleOutput = $this->getMockBuilder(OutputInterface::class)->getMock();
- /** @var \OCP\IConfig $config */
+ /** @var IConfig $config */
$this->command = new Disable($config);
}
@@ -46,12 +47,12 @@ class DisableTest extends TestCase {
}
/**
- * @dataProvider dataDisable
*
* @param string $oldStatus
* @param bool $isUpdating
* @param string $expectedString
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataDisable')]
public function testDisable($oldStatus, $isUpdating, $expectedString): void {
$this->config->expects($this->once())
->method('getAppValue')
diff --git a/tests/Core/Command/Encryption/EnableTest.php b/tests/Core/Command/Encryption/EnableTest.php
index e4f8ae9eacf..32d1a7576f5 100644
--- a/tests/Core/Command/Encryption/EnableTest.php
+++ b/tests/Core/Command/Encryption/EnableTest.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -55,9 +56,7 @@ class EnableTest extends TestCase {
];
}
- /**
- * @dataProvider dataEnable
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataEnable')]
public function testEnable(string $oldStatus, ?string $defaultModule, array $availableModules, bool $isUpdating, string $expectedString, string $expectedDefaultModuleString): void {
if ($isUpdating) {
$this->config->expects($this->once())
diff --git a/tests/Core/Command/Encryption/EncryptAllTest.php b/tests/Core/Command/Encryption/EncryptAllTest.php
index 1c59a3705af..6332c936a98 100644
--- a/tests/Core/Command/Encryption/EncryptAllTest.php
+++ b/tests/Core/Command/Encryption/EncryptAllTest.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -18,13 +19,13 @@ use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase;
class EncryptAllTest extends TestCase {
- /** @var \PHPUnit\Framework\MockObject\MockObject | \OCP\IConfig */
+ /** @var \PHPUnit\Framework\MockObject\MockObject|IConfig */
protected $config;
/** @var \PHPUnit\Framework\MockObject\MockObject | \OCP\Encryption\IManager */
protected $encryptionManager;
- /** @var \PHPUnit\Framework\MockObject\MockObject | \OCP\App\IAppManager */
+ /** @var \PHPUnit\Framework\MockObject\MockObject|IAppManager */
protected $appManager;
/** @var \PHPUnit\Framework\MockObject\MockObject | \Symfony\Component\Console\Input\InputInterface */
@@ -36,7 +37,7 @@ class EncryptAllTest extends TestCase {
/** @var \PHPUnit\Framework\MockObject\MockObject | \Symfony\Component\Console\Helper\QuestionHelper */
protected $questionHelper;
- /** @var \PHPUnit\Framework\MockObject\MockObject | \OCP\Encryption\IEncryptionModule */
+ /** @var \PHPUnit\Framework\MockObject\MockObject|IEncryptionModule */
protected $encryptionModule;
/** @var EncryptAll */
@@ -77,9 +78,7 @@ class EncryptAllTest extends TestCase {
$this->invokePrivate($instance, 'resetMaintenanceAndTrashbin');
}
- /**
- * @dataProvider dataTestExecute
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestExecute')]
public function testExecute($answer, $askResult): void {
$command = new EncryptAll($this->encryptionManager, $this->appManager, $this->config, $this->questionHelper);
diff --git a/tests/Core/Command/Encryption/SetDefaultModuleTest.php b/tests/Core/Command/Encryption/SetDefaultModuleTest.php
index 52f14dd4537..df38d730db3 100644
--- a/tests/Core/Command/Encryption/SetDefaultModuleTest.php
+++ b/tests/Core/Command/Encryption/SetDefaultModuleTest.php
@@ -1,4 +1,5 @@
<?php
+
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -52,7 +53,6 @@ class SetDefaultModuleTest extends TestCase {
}
/**
- * @dataProvider dataSetDefaultModule
*
* @param string $oldModule
* @param string $newModule
@@ -60,6 +60,7 @@ class SetDefaultModuleTest extends TestCase {
* @param bool $updateSuccess
* @param string $expectedString
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataSetDefaultModule')]
public function testSetDefaultModule($oldModule, $newModule, $updateModule, $updateSuccess, $expectedString): void {
$this->consoleInput->expects($this->once())
->method('getArgument')
@@ -90,7 +91,6 @@ class SetDefaultModuleTest extends TestCase {
}
/**
- * @dataProvider dataSetDefaultModule
*
* @param string $oldModule
* @param string $newModule
@@ -98,6 +98,7 @@ class SetDefaultModuleTest extends TestCase {
* @param bool $updateSuccess
* @param string $expectedString
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataSetDefaultModule')]
public function testMaintenanceMode($oldModule, $newModule, $updateModule, $updateSuccess, $expectedString): void {
$this->consoleInput->expects($this->never())
->method('getArgument')
@@ -119,7 +120,7 @@ class SetDefaultModuleTest extends TestCase {
];
$this->consoleOutput->expects($this->exactly(2))
->method('writeln')
- ->willReturnCallback(function ($message) use (&$calls) {
+ ->willReturnCallback(function ($message) use (&$calls): void {
$expected = array_shift($calls);
$this->assertStringContainsString($expected, $message);
});