diff options
Diffstat (limited to 'apps/files_versions/tests/VersioningTest.php')
-rw-r--r-- | apps/files_versions/tests/VersioningTest.php | 39 |
1 files changed, 21 insertions, 18 deletions
diff --git a/apps/files_versions/tests/VersioningTest.php b/apps/files_versions/tests/VersioningTest.php index f294390a593..659b2cff10c 100644 --- a/apps/files_versions/tests/VersioningTest.php +++ b/apps/files_versions/tests/VersioningTest.php @@ -1,4 +1,6 @@ <?php + +declare(strict_types=1); /** * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors * SPDX-FileCopyrightText: 2016 ownCloud, Inc. @@ -83,7 +85,10 @@ class VersioningTest extends \Test\TestCase { parent::setUp(); $config = Server::get(IConfig::class); - $mockConfig = $this->createMock(IConfig::class); + $mockConfig = $this->getMockBuilder(AllConfig::class) + ->onlyMethods(['getSystemValue']) + ->setConstructorArgs([Server::get(SystemConfig::class)]) + ->getMock(); $mockConfig->expects($this->any()) ->method('getSystemValue') ->willReturnCallback(function ($key, $default) use ($config) { @@ -160,7 +165,7 @@ class VersioningTest extends \Test\TestCase { } } - public function versionsProvider() { + public static function versionsProvider(): array { return [ // first set of versions uniformly distributed versions [ @@ -427,8 +432,9 @@ class VersioningTest extends \Test\TestCase { $this->rootView->file_put_contents($v2, 'version2'); // move file into the shared folder as recipient - Filesystem::rename('/test.txt', '/folder1/test.txt'); + $success = Filesystem::rename('/test.txt', '/folder1/test.txt'); + $this->assertTrue($success); $this->assertFalse($this->rootView->file_exists($v1)); $this->assertFalse($this->rootView->file_exists($v2)); @@ -679,7 +685,7 @@ class VersioningTest extends \Test\TestCase { $firstVersion = current($versions); - $this->assertFalse(Storage::rollback('folder/test.txt', $firstVersion['version'], $this->user2), 'Revert did not happen'); + $this->assertFalse(Storage::rollback('folder/test.txt', (int)$firstVersion['version'], $this->user2), 'Revert did not happen'); $this->loginAsUser(self::TEST_VERSIONS_USER); @@ -739,8 +745,8 @@ class VersioningTest extends \Test\TestCase { return; } - $eventHandler = $this->getMockBuilder(\stdclass::class) - ->setMethods(['callback']) + $eventHandler = $this->getMockBuilder(DummyHookListener::class) + ->onlyMethods(['callback']) ->getMock(); $eventHandler->expects($this->any()) @@ -759,7 +765,7 @@ class VersioningTest extends \Test\TestCase { ); } - private function doTestRestore() { + private function doTestRestore(): void { $filePath = self::TEST_VERSIONS_USER . '/files/sub/test.txt'; $this->rootView->file_put_contents($filePath, 'test file'); @@ -808,7 +814,7 @@ class VersioningTest extends \Test\TestCase { $eventDispatcher = Server::get(IEventDispatcher::class); $eventFired = false; - $eventDispatcher->addListener(VersionRestoredEvent::class, function ($event) use (&$eventFired, $t2) { + $eventDispatcher->addListener(VersionRestoredEvent::class, function ($event) use (&$eventFired, $t2): void { $eventFired = true; $this->assertEquals('/sub/test.txt', $event->getVersion()->getVersionPath()); $this->assertTrue($event->getVersion()->getRevisionId() > 0); @@ -937,11 +943,7 @@ class VersioningTest extends \Test\TestCase { ); } - /** - * @param View $view - * @param string $path - */ - private function createAndCheckVersions(View $view, $path) { + private function createAndCheckVersions(View $view, string $path): array { $view->file_put_contents($path, 'test file'); $view->file_put_contents($path, 'version 1'); $view->file_put_contents($path, 'version 2'); @@ -963,11 +965,7 @@ class VersioningTest extends \Test\TestCase { return $versions; } - /** - * @param string $user - * @param bool $create - */ - public static function loginHelper($user, $create = false) { + public static function loginHelper(string $user, bool $create = false) { if ($create) { $backend = new \Test\Util\User\Dummy(); $backend->createUser($user, $user); @@ -983,6 +981,11 @@ class VersioningTest extends \Test\TestCase { } } +class DummyHookListener { + public function callback() { + } +} + // extend the original class to make it possible to test protected methods class VersionStorageToTest extends Storage { |