aboutsummaryrefslogtreecommitdiffstats
path: root/apps/encryption/tests/Crypto/EncryptionTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'apps/encryption/tests/Crypto/EncryptionTest.php')
-rw-r--r--apps/encryption/tests/Crypto/EncryptionTest.php59
1 files changed, 20 insertions, 39 deletions
diff --git a/apps/encryption/tests/Crypto/EncryptionTest.php b/apps/encryption/tests/Crypto/EncryptionTest.php
index 7f3d9d1f348..37e484550ef 100644
--- a/apps/encryption/tests/Crypto/EncryptionTest.php
+++ b/apps/encryption/tests/Crypto/EncryptionTest.php
@@ -1,5 +1,7 @@
<?php
+declare(strict_types=1);
+
/**
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
@@ -26,34 +28,18 @@ use Symfony\Component\Console\Output\OutputInterface;
use Test\TestCase;
class EncryptionTest extends TestCase {
- /** @var Encryption */
- private $instance;
-
- /** @var KeyManager|\PHPUnit\Framework\MockObject\MockObject */
- private $keyManagerMock;
-
- /** @var EncryptAll|\PHPUnit\Framework\MockObject\MockObject */
- private $encryptAllMock;
-
- /** @var DecryptAll|\PHPUnit\Framework\MockObject\MockObject */
- private $decryptAllMock;
-
- /** @var Session|\PHPUnit\Framework\MockObject\MockObject */
- private $sessionMock;
-
- /** @var Crypt|\PHPUnit\Framework\MockObject\MockObject */
- private $cryptMock;
-
- /** @var Util|\PHPUnit\Framework\MockObject\MockObject */
- private $utilMock;
- /** @var LoggerInterface|\PHPUnit\Framework\MockObject\MockObject */
- private $loggerMock;
+ protected Encryption $instance;
- /** @var IL10N|\PHPUnit\Framework\MockObject\MockObject */
- private $l10nMock;
-
- private IStorage&MockObject $storageMock;
+ protected KeyManager&MockObject $keyManagerMock;
+ protected EncryptAll&MockObject $encryptAllMock;
+ protected DecryptAll&MockObject $decryptAllMock;
+ protected Session&MockObject $sessionMock;
+ protected Crypt&MockObject $cryptMock;
+ protected Util&MockObject $utilMock;
+ protected LoggerInterface&MockObject $loggerMock;
+ protected IL10N&MockObject $l10nMock;
+ protected IStorage&MockObject $storageMock;
protected function setUp(): void {
parent::setUp();
@@ -166,16 +152,14 @@ class EncryptionTest extends TestCase {
return $publicKeys;
}
- /**
- * @dataProvider dataProviderForTestGetPathToRealFile
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataProviderForTestGetPathToRealFile')]
public function testGetPathToRealFile($path, $expected): void {
$this->assertSame($expected,
self::invokePrivate($this->instance, 'getPathToRealFile', [$path])
);
}
- public function dataProviderForTestGetPathToRealFile() {
+ public static function dataProviderForTestGetPathToRealFile(): array {
return [
['/user/files/foo/bar.txt', '/user/files/foo/bar.txt'],
['/user/files/foo.txt', '/user/files/foo.txt'],
@@ -184,9 +168,7 @@ class EncryptionTest extends TestCase {
];
}
- /**
- * @dataProvider dataTestBegin
- */
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestBegin')]
public function testBegin($mode, $header, $legacyCipher, $defaultCipher, $fileKey, $expected): void {
$this->sessionMock->expects($this->once())
->method('decryptAllModeActivated')
@@ -228,7 +210,7 @@ class EncryptionTest extends TestCase {
}
}
- public function dataTestBegin() {
+ public static function dataTestBegin(): array {
return [
['w', ['cipher' => 'myCipher'], 'legacyCipher', 'defaultCipher', 'fileKey', 'defaultCipher'],
['r', ['cipher' => 'myCipher'], 'legacyCipher', 'defaultCipher', 'fileKey', 'myCipher'],
@@ -279,11 +261,11 @@ class EncryptionTest extends TestCase {
}
/**
- * @dataProvider dataTestUpdate
*
* @param string $fileKey
* @param boolean $expected
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestUpdate')]
public function testUpdate($fileKey, $expected): void {
$this->keyManagerMock->expects($this->once())
->method('getFileKey')->willReturn($fileKey);
@@ -305,7 +287,7 @@ class EncryptionTest extends TestCase {
);
}
- public function dataTestUpdate() {
+ public static function dataTestUpdate(): array {
return [
['', false],
['fileKey', true]
@@ -368,9 +350,8 @@ class EncryptionTest extends TestCase {
/**
* by default the encryption module should encrypt regular files, files in
* files_versions and files in files_trashbin
- *
- * @dataProvider dataTestShouldEncrypt
*/
+ #[\PHPUnit\Framework\Attributes\DataProvider('dataTestShouldEncrypt')]
public function testShouldEncrypt($path, $shouldEncryptHomeStorage, $isHomeStorage, $expected): void {
$this->utilMock->expects($this->once())->method('shouldEncryptHomeStorage')
->willReturn($shouldEncryptHomeStorage);
@@ -387,7 +368,7 @@ class EncryptionTest extends TestCase {
);
}
- public function dataTestShouldEncrypt() {
+ public static function dataTestShouldEncrypt(): array {
return [
['/user1/files/foo.txt', true, true, true],
['/user1/files_versions/foo.txt', true, true, true],