aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/Files/Storage/Wrapper/PermissionsMaskTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/Files/Storage/Wrapper/PermissionsMaskTest.php')
-rw-r--r--tests/lib/Files/Storage/Wrapper/PermissionsMaskTest.php54
1 files changed, 28 insertions, 26 deletions
diff --git a/tests/lib/Files/Storage/Wrapper/PermissionsMaskTest.php b/tests/lib/Files/Storage/Wrapper/PermissionsMaskTest.php
index ea01a0e3e94..a2f3460c58c 100644
--- a/tests/lib/Files/Storage/Wrapper/PermissionsMaskTest.php
+++ b/tests/lib/Files/Storage/Wrapper/PermissionsMaskTest.php
@@ -1,13 +1,15 @@
<?php
+
/**
- * Copyright (c) 2014 Robin Appelman <icewind@owncloud.com>
- * This file is licensed under the Affero General Public License version 3 or
- * later.
- * See the COPYING-README file.
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Files\Storage\Wrapper;
+use OC\Files\Storage\Temporary;
+use OC\Files\Storage\Wrapper\PermissionsMask;
use OC\Files\Storage\Wrapper\Wrapper;
use OCP\Constants;
use OCP\Files\Cache\IScanner;
@@ -17,13 +19,13 @@ use OCP\Files\Cache\IScanner;
*/
class PermissionsMaskTest extends \Test\Files\Storage\Storage {
/**
- * @var \OC\Files\Storage\Temporary
+ * @var Temporary
*/
private $sourceStorage;
protected function setUp(): void {
parent::setUp();
- $this->sourceStorage = new \OC\Files\Storage\Temporary([]);
+ $this->sourceStorage = new Temporary([]);
$this->instance = $this->getMaskedStorage(Constants::PERMISSION_ALL);
}
@@ -33,19 +35,19 @@ class PermissionsMaskTest extends \Test\Files\Storage\Storage {
}
protected function getMaskedStorage($mask) {
- return new \OC\Files\Storage\Wrapper\PermissionsMask([
+ return new PermissionsMask([
'storage' => $this->sourceStorage,
'mask' => $mask
]);
}
- public function testMkdirNoCreate() {
+ public function testMkdirNoCreate(): void {
$storage = $this->getMaskedStorage(Constants::PERMISSION_ALL - Constants::PERMISSION_CREATE);
$this->assertFalse($storage->mkdir('foo'));
$this->assertFalse($storage->file_exists('foo'));
}
- public function testRmdirNoDelete() {
+ public function testRmdirNoDelete(): void {
$storage = $this->getMaskedStorage(Constants::PERMISSION_ALL - Constants::PERMISSION_DELETE);
$this->assertTrue($storage->mkdir('foo'));
$this->assertTrue($storage->file_exists('foo'));
@@ -53,25 +55,25 @@ class PermissionsMaskTest extends \Test\Files\Storage\Storage {
$this->assertTrue($storage->file_exists('foo'));
}
- public function testTouchNewFileNoCreate() {
+ public function testTouchNewFileNoCreate(): void {
$storage = $this->getMaskedStorage(Constants::PERMISSION_ALL - Constants::PERMISSION_CREATE);
$this->assertFalse($storage->touch('foo'));
$this->assertFalse($storage->file_exists('foo'));
}
- public function testTouchNewFileNoUpdate() {
+ public function testTouchNewFileNoUpdate(): void {
$storage = $this->getMaskedStorage(Constants::PERMISSION_ALL - Constants::PERMISSION_UPDATE);
$this->assertTrue($storage->touch('foo'));
$this->assertTrue($storage->file_exists('foo'));
}
- public function testTouchExistingFileNoUpdate() {
+ public function testTouchExistingFileNoUpdate(): void {
$this->sourceStorage->touch('foo');
$storage = $this->getMaskedStorage(Constants::PERMISSION_ALL - Constants::PERMISSION_UPDATE);
$this->assertFalse($storage->touch('foo'));
}
- public function testUnlinkNoDelete() {
+ public function testUnlinkNoDelete(): void {
$storage = $this->getMaskedStorage(Constants::PERMISSION_ALL - Constants::PERMISSION_DELETE);
$this->assertTrue($storage->touch('foo'));
$this->assertTrue($storage->file_exists('foo'));
@@ -79,35 +81,35 @@ class PermissionsMaskTest extends \Test\Files\Storage\Storage {
$this->assertTrue($storage->file_exists('foo'));
}
- public function testPutContentsNewFileNoUpdate() {
+ public function testPutContentsNewFileNoUpdate(): void {
$storage = $this->getMaskedStorage(Constants::PERMISSION_ALL - Constants::PERMISSION_UPDATE);
$this->assertEquals(3, $storage->file_put_contents('foo', 'bar'));
$this->assertEquals('bar', $storage->file_get_contents('foo'));
}
- public function testPutContentsNewFileNoCreate() {
+ public function testPutContentsNewFileNoCreate(): void {
$storage = $this->getMaskedStorage(Constants::PERMISSION_ALL - Constants::PERMISSION_CREATE);
$this->assertFalse($storage->file_put_contents('foo', 'bar'));
}
- public function testPutContentsExistingFileNoUpdate() {
+ public function testPutContentsExistingFileNoUpdate(): void {
$this->sourceStorage->touch('foo');
$storage = $this->getMaskedStorage(Constants::PERMISSION_ALL - Constants::PERMISSION_UPDATE);
$this->assertFalse($storage->file_put_contents('foo', 'bar'));
}
- public function testFopenExistingFileNoUpdate() {
+ public function testFopenExistingFileNoUpdate(): void {
$this->sourceStorage->touch('foo');
$storage = $this->getMaskedStorage(Constants::PERMISSION_ALL - Constants::PERMISSION_UPDATE);
$this->assertFalse($storage->fopen('foo', 'w'));
}
- public function testFopenNewFileNoCreate() {
+ public function testFopenNewFileNoCreate(): void {
$storage = $this->getMaskedStorage(Constants::PERMISSION_ALL - Constants::PERMISSION_CREATE);
$this->assertFalse($storage->fopen('foo', 'w'));
}
- public function testScanNewFiles() {
+ public function testScanNewFiles(): void {
$storage = $this->getMaskedStorage(Constants::PERMISSION_READ + Constants::PERMISSION_CREATE);
$storage->file_put_contents('foo', 'bar');
$storage->getScanner()->scan('');
@@ -116,7 +118,7 @@ class PermissionsMaskTest extends \Test\Files\Storage\Storage {
$this->assertEquals(Constants::PERMISSION_READ, $storage->getCache()->get('foo')->getPermissions());
}
- public function testScanNewWrappedFiles() {
+ public function testScanNewWrappedFiles(): void {
$storage = $this->getMaskedStorage(Constants::PERMISSION_READ + Constants::PERMISSION_CREATE);
$wrappedStorage = new Wrapper(['storage' => $storage]);
$wrappedStorage->file_put_contents('foo', 'bar');
@@ -126,9 +128,9 @@ class PermissionsMaskTest extends \Test\Files\Storage\Storage {
$this->assertEquals(Constants::PERMISSION_READ, $storage->getCache()->get('foo')->getPermissions());
}
- public function testScanNewFilesNested() {
+ public function testScanNewFilesNested(): void {
$storage = $this->getMaskedStorage(Constants::PERMISSION_READ + Constants::PERMISSION_CREATE + Constants::PERMISSION_UPDATE);
- $nestedStorage = new \OC\Files\Storage\Wrapper\PermissionsMask([
+ $nestedStorage = new PermissionsMask([
'storage' => $storage,
'mask' => Constants::PERMISSION_READ + Constants::PERMISSION_CREATE
]);
@@ -141,7 +143,7 @@ class PermissionsMaskTest extends \Test\Files\Storage\Storage {
$this->assertEquals(Constants::PERMISSION_READ, $wrappedStorage->getCache()->get('foo')->getPermissions());
}
- public function testScanUnchanged() {
+ public function testScanUnchanged(): void {
$this->sourceStorage->mkdir('foo');
$this->sourceStorage->file_put_contents('foo/bar.txt', 'bar');
@@ -150,7 +152,7 @@ class PermissionsMaskTest extends \Test\Files\Storage\Storage {
$storage = $this->getMaskedStorage(Constants::PERMISSION_READ);
$scanner = $storage->getScanner();
$called = false;
- $scanner->listen('\OC\Files\Cache\Scanner', 'addToCache', function () use (&$called) {
+ $scanner->listen('\OC\Files\Cache\Scanner', 'addToCache', function () use (&$called): void {
$called = true;
});
$scanner->scan('foo', IScanner::SCAN_RECURSIVE, IScanner::REUSE_ETAG | IScanner::REUSE_SIZE);
@@ -158,7 +160,7 @@ class PermissionsMaskTest extends \Test\Files\Storage\Storage {
$this->assertFalse($called);
}
- public function testScanUnchangedWrapped() {
+ public function testScanUnchangedWrapped(): void {
$this->sourceStorage->mkdir('foo');
$this->sourceStorage->file_put_contents('foo/bar.txt', 'bar');
@@ -168,7 +170,7 @@ class PermissionsMaskTest extends \Test\Files\Storage\Storage {
$wrappedStorage = new Wrapper(['storage' => $storage]);
$scanner = $wrappedStorage->getScanner();
$called = false;
- $scanner->listen('\OC\Files\Cache\Scanner', 'addToCache', function () use (&$called) {
+ $scanner->listen('\OC\Files\Cache\Scanner', 'addToCache', function () use (&$called): void {
$called = true;
});
$scanner->scan('foo', IScanner::SCAN_RECURSIVE, IScanner::REUSE_ETAG | IScanner::REUSE_SIZE);