aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/Encryption/EncryptionWrapperTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/Encryption/EncryptionWrapperTest.php')
-rw-r--r--tests/lib/Encryption/EncryptionWrapperTest.php53
1 files changed, 21 insertions, 32 deletions
diff --git a/tests/lib/Encryption/EncryptionWrapperTest.php b/tests/lib/Encryption/EncryptionWrapperTest.php
index 8c357e2a50d..58bf5aff005 100644
--- a/tests/lib/Encryption/EncryptionWrapperTest.php
+++ b/tests/lib/Encryption/EncryptionWrapperTest.php
@@ -1,44 +1,35 @@
<?php
+
/**
- * @author Björn Schießle <schiessle@owncloud.com>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * 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, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
+ * 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\EncryptionWrapper;
use OC\Encryption\Manager;
+use OC\Files\Storage\Wrapper\Encryption;
use OC\Memcache\ArrayCache;
-use OCP\Files\Storage;
+use OCA\Files_Trashbin\Storage;
+use OCP\Files\Mount\IMountPoint;
+use OCP\Files\Storage\IDisableEncryptionStorage;
+use OCP\Files\Storage\IStorage;
use Psr\Log\LoggerInterface;
use Test\TestCase;
class EncryptionWrapperTest extends TestCase {
- /** @var EncryptionWrapper */
+ /** @var EncryptionWrapper */
private $instance;
- /** @var \PHPUnit\Framework\MockObject\MockObject | LoggerInterface */
+ /** @var \PHPUnit\Framework\MockObject\MockObject | LoggerInterface */
private $logger;
- /** @var \PHPUnit\Framework\MockObject\MockObject | \OC\Encryption\Manager */
+ /** @var \PHPUnit\Framework\MockObject\MockObject | \OC\Encryption\Manager */
private $manager;
- /** @var \PHPUnit\Framework\MockObject\MockObject | \OC\Memcache\ArrayCache */
+ /** @var \PHPUnit\Framework\MockObject\MockObject|ArrayCache */
private $arrayCache;
protected function setUp(): void {
@@ -52,11 +43,9 @@ class EncryptionWrapperTest extends TestCase {
}
- /**
- * @dataProvider provideWrapStorage
- */
- public function testWrapStorage($expectedWrapped, $wrappedStorages) {
- $storage = $this->getMockBuilder(Storage::class)
+ #[\PHPUnit\Framework\Attributes\DataProvider('provideWrapStorage')]
+ public function testWrapStorage($expectedWrapped, $wrappedStorages): void {
+ $storage = $this->getMockBuilder(IStorage::class)
->disableOriginalConstructor()
->getMock();
@@ -68,7 +57,7 @@ class EncryptionWrapperTest extends TestCase {
]);
}
- $mount = $this->getMockBuilder('OCP\Files\Mount\IMountPoint')
+ $mount = $this->getMockBuilder(IMountPoint::class)
->disableOriginalConstructor()
->getMock();
@@ -76,19 +65,19 @@ class EncryptionWrapperTest extends TestCase {
$this->assertEquals(
$expectedWrapped,
- $returnedStorage->instanceOfStorage('OC\Files\Storage\Wrapper\Encryption'),
+ $returnedStorage->instanceOfStorage(Encryption::class),
'Asserted that the storage is (not) wrapped with encryption'
);
}
- public function provideWrapStorage() {
+ public static function provideWrapStorage(): array {
return [
// Wrap when not wrapped or not wrapped with storage
[true, []],
- [true, ['OCA\Files_Trashbin\Storage']],
+ [true, [Storage::class]],
// Do not wrap shared storages
- [false, [Storage\IDisableEncryptionStorage::class]],
+ [false, [IDisableEncryptionStorage::class]],
];
}
}