From 256a8d8903ef3a81a425f417c0eb626f42036a25 Mon Sep 17 00:00:00 2001 From: provokateurin Date: Thu, 19 Sep 2024 18:19:16 +0200 Subject: test: Fix IStorage return types Signed-off-by: provokateurin --- tests/lib/Files/Cache/CacheTest.php | 2 +- tests/lib/Files/Mount/ManagerTest.php | 2 +- tests/lib/Files/Storage/CopyDirectoryTest.php | 2 +- tests/lib/Files/ViewTest.php | 48 +++++++++++++++++++---- tests/lib/Lockdown/Filesystem/NullStorageTest.php | 2 +- 5 files changed, 45 insertions(+), 11 deletions(-) (limited to 'tests') diff --git a/tests/lib/Files/Cache/CacheTest.php b/tests/lib/Files/Cache/CacheTest.php index 55ac5c10144..d1279af29ad 100644 --- a/tests/lib/Files/Cache/CacheTest.php +++ b/tests/lib/Files/Cache/CacheTest.php @@ -17,7 +17,7 @@ use OCP\IDBConnection; use OCP\IUser; class LongId extends \OC\Files\Storage\Temporary { - public function getId() { + public function getId(): string { return 'long:' . str_repeat('foo', 50) . parent::getId(); } } diff --git a/tests/lib/Files/Mount/ManagerTest.php b/tests/lib/Files/Mount/ManagerTest.php index fe166988687..12338c18dbd 100644 --- a/tests/lib/Files/Mount/ManagerTest.php +++ b/tests/lib/Files/Mount/ManagerTest.php @@ -11,7 +11,7 @@ use OC\Files\SetupManagerFactory; use OC\Files\Storage\Temporary; class LongId extends Temporary { - public function getId() { + public function getId(): string { return 'long:' . str_repeat('foo', 50) . parent::getId(); } } diff --git a/tests/lib/Files/Storage/CopyDirectoryTest.php b/tests/lib/Files/Storage/CopyDirectoryTest.php index 6133361c626..c08bb6f6482 100644 --- a/tests/lib/Files/Storage/CopyDirectoryTest.php +++ b/tests/lib/Files/Storage/CopyDirectoryTest.php @@ -10,7 +10,7 @@ namespace Test\Files\Storage; use OC\Files\Storage\Temporary; class StorageNoRecursiveCopy extends Temporary { - public function copy($path1, $path2) { + public function copy($path1, $path2): bool { if ($this->is_dir($path1)) { return false; } diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php index 133f6d123cf..e393476bd05 100644 --- a/tests/lib/Files/ViewTest.php +++ b/tests/lib/Files/ViewTest.php @@ -37,23 +37,23 @@ use Test\TestMoveableMountPoint; use Test\Traits\UserTrait; class TemporaryNoTouch extends Temporary { - public function touch($path, $mtime = null) { + public function touch($path, $mtime = null): bool { return false; } } class TemporaryNoCross extends Temporary { - public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime = null) { + public function copyFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime = null): bool { return Common::copyFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath, $preserveMtime); } - public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath) { + public function moveFromStorage(IStorage $sourceStorage, $sourceInternalPath, $targetInternalPath): bool { return Common::moveFromStorage($sourceStorage, $sourceInternalPath, $targetInternalPath); } } class TemporaryNoLocal extends Temporary { - public function instanceOfStorage($className) { + public function instanceOfStorage($className): bool { if ($className === '\OC\Files\Storage\Local') { return false; } else { @@ -1752,6 +1752,8 @@ class ViewTest extends \Test\TestCase { ILockingProvider::LOCK_SHARED, ILockingProvider::LOCK_EXCLUSIVE, ILockingProvider::LOCK_SHARED, + null, + 0, ], // ---- delete hook ---- @@ -1783,6 +1785,8 @@ class ViewTest extends \Test\TestCase { ILockingProvider::LOCK_SHARED, ILockingProvider::LOCK_SHARED, null, + null, + false, ], [ 'fopen', @@ -1809,8 +1813,28 @@ class ViewTest extends \Test\TestCase { // ---- no hooks, no locks --- ['is_dir', ['dir'], 'dir', null], ['is_file', ['dir'], 'dir', null], - ['stat', ['dir'], 'dir', null], - ['filetype', ['dir'], 'dir', null], + [ + 'stat', + ['dir'], + 'dir', + null, + ILockingProvider::LOCK_SHARED, + ILockingProvider::LOCK_SHARED, + ILockingProvider::LOCK_SHARED, + null, + false, + ], + [ + 'filetype', + ['dir'], + 'dir', + null, + ILockingProvider::LOCK_SHARED, + ILockingProvider::LOCK_SHARED, + ILockingProvider::LOCK_SHARED, + null, + false, + ], [ 'filesize', ['dir'], @@ -1829,7 +1853,17 @@ class ViewTest extends \Test\TestCase { ['isDeletable', ['dir'], 'dir', null], ['isSharable', ['dir'], 'dir', null], ['file_exists', ['dir'], 'dir', null], - ['filemtime', ['dir'], 'dir', null], + [ + 'filemtime', + ['dir'], + 'dir', + null, + ILockingProvider::LOCK_SHARED, + ILockingProvider::LOCK_SHARED, + ILockingProvider::LOCK_SHARED, + null, + false, + ], ]; } diff --git a/tests/lib/Lockdown/Filesystem/NullStorageTest.php b/tests/lib/Lockdown/Filesystem/NullStorageTest.php index a0b9b04ad1a..21cb0f75bb6 100644 --- a/tests/lib/Lockdown/Filesystem/NullStorageTest.php +++ b/tests/lib/Lockdown/Filesystem/NullStorageTest.php @@ -96,7 +96,7 @@ class NullStorageTest extends TestCase { } public function testGetPermissions(): void { - $this->assertNull($this->storage->getPermissions('foo')); + $this->assertEquals(0, $this->storage->getPermissions('foo')); } public function testFile_exists(): void { -- cgit v1.2.3