aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/Lockdown/Filesystem/NullStorageTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lib/Lockdown/Filesystem/NullStorageTest.php')
-rw-r--r--tests/lib/Lockdown/Filesystem/NullStorageTest.php104
1 files changed, 44 insertions, 60 deletions
diff --git a/tests/lib/Lockdown/Filesystem/NullStorageTest.php b/tests/lib/Lockdown/Filesystem/NullStorageTest.php
index b46066ac536..fa019ada4e5 100644
--- a/tests/lib/Lockdown/Filesystem/NullStorageTest.php
+++ b/tests/lib/Lockdown/Filesystem/NullStorageTest.php
@@ -1,24 +1,8 @@
<?php
+
/**
- * @copyright 2016, Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @license GNU AGPL version 3 or any later version
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * 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
- * along with this program. If not, see <http://www.gnu.org/licenses/>.
- *
+ * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace Test\Lockdown\Filesystem;
@@ -28,7 +12,7 @@ use OC\Files\FileInfo;
use OC\ForbiddenException;
use OC\Lockdown\Filesystem\NullCache;
use OC\Lockdown\Filesystem\NullStorage;
-use OCP\Files\Storage;
+use OCP\Files\Storage\IStorage;
use Test\TestCase;
class NullStorageTest extends TestCase {
@@ -41,179 +25,179 @@ class NullStorageTest extends TestCase {
$this->storage = new NullStorage([]);
}
- public function testGetId() {
+ public function testGetId(): void {
$this->assertSame('null', $this->storage->getId());
}
- public function testMkdir() {
+ public function testMkdir(): void {
$this->expectException(ForbiddenException::class);
$this->expectExceptionMessage('This request is not allowed to access the filesystem');
$this->storage->mkdir('foo');
}
- public function testRmdir() {
+ public function testRmdir(): void {
$this->expectException(ForbiddenException::class);
$this->expectExceptionMessage('This request is not allowed to access the filesystem');
$this->storage->rmdir('foo');
}
- public function testOpendir() {
+ public function testOpendir(): void {
$this->assertInstanceOf(IteratorDirectory::class, $this->storage->opendir('foo'));
}
- public function testIs_dir() {
+ public function testIs_dir(): void {
$this->assertTrue($this->storage->is_dir(''));
$this->assertFalse($this->storage->is_dir('foo'));
}
- public function testIs_file() {
+ public function testIs_file(): void {
$this->assertFalse($this->storage->is_file('foo'));
}
- public function testStat() {
+ public function testStat(): void {
$this->expectException(ForbiddenException::class);
$this->expectExceptionMessage('This request is not allowed to access the filesystem');
$this->storage->stat('foo');
}
- public function testFiletype() {
+ public function testFiletype(): void {
$this->assertSame('dir', $this->storage->filetype(''));
$this->assertFalse($this->storage->filetype('foo'));
}
- public function testFilesize() {
+ public function testFilesize(): void {
$this->expectException(ForbiddenException::class);
$this->expectExceptionMessage('This request is not allowed to access the filesystem');
$this->storage->filesize('foo');
}
- public function testIsCreatable() {
+ public function testIsCreatable(): void {
$this->assertFalse($this->storage->isCreatable('foo'));
}
- public function testIsReadable() {
+ public function testIsReadable(): void {
$this->assertTrue($this->storage->isReadable(''));
$this->assertFalse($this->storage->isReadable('foo'));
}
- public function testIsUpdatable() {
+ public function testIsUpdatable(): void {
$this->assertFalse($this->storage->isUpdatable('foo'));
}
- public function testIsDeletable() {
+ public function testIsDeletable(): void {
$this->assertFalse($this->storage->isDeletable('foo'));
}
- public function testIsSharable() {
+ public function testIsSharable(): void {
$this->assertFalse($this->storage->isSharable('foo'));
}
- public function testGetPermissions() {
- $this->assertNull($this->storage->getPermissions('foo'));
+ public function testGetPermissions(): void {
+ $this->assertEquals(0, $this->storage->getPermissions('foo'));
}
- public function testFile_exists() {
+ public function testFile_exists(): void {
$this->assertTrue($this->storage->file_exists(''));
$this->assertFalse($this->storage->file_exists('foo'));
}
- public function testFilemtime() {
+ public function testFilemtime(): void {
$this->assertFalse($this->storage->filemtime('foo'));
}
- public function testFile_get_contents() {
+ public function testFile_get_contents(): void {
$this->expectException(ForbiddenException::class);
$this->expectExceptionMessage('This request is not allowed to access the filesystem');
$this->storage->file_get_contents('foo');
}
- public function testFile_put_contents() {
+ public function testFile_put_contents(): void {
$this->expectException(ForbiddenException::class);
$this->expectExceptionMessage('This request is not allowed to access the filesystem');
$this->storage->file_put_contents('foo', 'bar');
}
- public function testUnlink() {
+ public function testUnlink(): void {
$this->expectException(ForbiddenException::class);
$this->expectExceptionMessage('This request is not allowed to access the filesystem');
$this->storage->unlink('foo');
}
- public function testRename() {
+ public function testRename(): void {
$this->expectException(ForbiddenException::class);
$this->expectExceptionMessage('This request is not allowed to access the filesystem');
$this->storage->rename('foo', 'bar');
}
- public function testCopy() {
+ public function testCopy(): void {
$this->expectException(ForbiddenException::class);
$this->expectExceptionMessage('This request is not allowed to access the filesystem');
$this->storage->copy('foo', 'bar');
}
- public function testFopen() {
+ public function testFopen(): void {
$this->expectException(ForbiddenException::class);
$this->expectExceptionMessage('This request is not allowed to access the filesystem');
$this->storage->fopen('foo', 'R');
}
- public function testGetMimeType() {
+ public function testGetMimeType(): void {
$this->expectException(ForbiddenException::class);
$this->expectExceptionMessage('This request is not allowed to access the filesystem');
$this->storage->getMimeType('foo');
}
- public function testHash() {
+ public function testHash(): void {
$this->expectException(ForbiddenException::class);
$this->expectExceptionMessage('This request is not allowed to access the filesystem');
$this->storage->hash('md5', 'foo', true);
}
- public function testFree_space() {
+ public function testFree_space(): void {
$this->assertSame(FileInfo::SPACE_UNKNOWN, $this->storage->free_space('foo'));
}
- public function testTouch() {
+ public function testTouch(): void {
$this->expectException(ForbiddenException::class);
$this->expectExceptionMessage('This request is not allowed to access the filesystem');
$this->storage->touch('foo');
}
- public function testGetLocalFile() {
+ public function testGetLocalFile(): void {
$this->assertFalse($this->storage->getLocalFile('foo'));
}
- public function testHasUpdated() {
+ public function testHasUpdated(): void {
$this->assertFalse($this->storage->hasUpdated('foo', 42));
}
- public function testGetETag() {
+ public function testGetETag(): void {
$this->assertSame('', $this->storage->getETag('foo'));
}
- public function testIsLocal() {
+ public function testIsLocal(): void {
$this->assertFalse($this->storage->isLocal());
}
- public function testGetDirectDownload() {
+ public function testGetDirectDownload(): void {
$this->assertFalse($this->storage->getDirectDownload('foo'));
}
- public function testCopyFromStorage() {
- $sourceStorage = $this->createMock(Storage::class);
+ public function testCopyFromStorage(): void {
+ $sourceStorage = $this->createMock(IStorage::class);
$this->expectException(ForbiddenException::class);
$this->expectExceptionMessage('This request is not allowed to access the filesystem');
@@ -221,8 +205,8 @@ class NullStorageTest extends TestCase {
$this->storage->copyFromStorage($sourceStorage, 'foo', 'bar');
}
- public function testMoveFromStorage() {
- $sourceStorage = $this->createMock(Storage::class);
+ public function testMoveFromStorage(): void {
+ $sourceStorage = $this->createMock(IStorage::class);
$this->expectException(ForbiddenException::class);
$this->expectExceptionMessage('This request is not allowed to access the filesystem');
@@ -235,11 +219,11 @@ class NullStorageTest extends TestCase {
return true;
}
- public function testGetOwner() {
- $this->assertNull($this->storage->getOwner('foo'));
+ public function testGetOwner(): void {
+ $this->assertFalse($this->storage->getOwner('foo'));
}
- public function testGetCache() {
+ public function testGetCache(): void {
$this->assertInstanceOf(NullCache::class, $this->storage->getCache('foo'));
}
}