diff options
Diffstat (limited to 'tests/lib/Files/Node/IntegrationTest.php')
-rw-r--r-- | tests/lib/Files/Node/IntegrationTest.php | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/tests/lib/Files/Node/IntegrationTest.php b/tests/lib/Files/Node/IntegrationTest.php index 26cdf398d94..f059afa1625 100644 --- a/tests/lib/Files/Node/IntegrationTest.php +++ b/tests/lib/Files/Node/IntegrationTest.php @@ -1,19 +1,26 @@ <?php + /** - * Copyright (c) 2013 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\Node; use OC\Files\Node\Root; +use OC\Files\Storage\Storage; use OC\Files\Storage\Temporary; use OC\Files\View; -use OC\User\User; -use OCP\ILogger; +use OC\Memcache\ArrayCache; +use OCP\EventDispatcher\IEventDispatcher; +use OCP\Files\Config\IUserMountCache; +use OCP\Files\Mount\IMountManager; +use OCP\ICacheFactory; use OCP\IUserManager; +use OCP\Server; +use Psr\Log\LoggerInterface; +use Test\Traits\UserTrait; /** * Class IntegrationTest @@ -23,39 +30,48 @@ use OCP\IUserManager; * @package Test\Files\Node */ class IntegrationTest extends \Test\TestCase { + use UserTrait; + /** * @var \OC\Files\Node\Root $root */ private $root; /** - * @var \OC\Files\Storage\Storage[] + * @var Storage[] */ private $storages; /** - * @var \OC\Files\View $view + * @var View $view */ private $view; protected function setUp(): void { parent::setUp(); - $manager = \OC\Files\Filesystem::getMountManager(); + $manager = Server::get(IMountManager::class); \OC_Hook::clear('OC_Filesystem'); - $user = new User($this->getUniqueID('user'), new \Test\Util\User\Dummy, \OC::$server->getEventDispatcher()); + $user = $this->createUser($this->getUniqueID('user'), ''); $this->loginAsUser($user->getUID()); + $cacheFactory = $this->createMock(ICacheFactory::class); + $cacheFactory->method('createLocal') + ->willReturnCallback(function () { + return new ArrayCache(); + }); $this->view = new View(); $this->root = new Root( $manager, $this->view, $user, - \OC::$server->getUserMountCache(), - $this->createMock(ILogger::class), - $this->createMock(IUserManager::class) + Server::get(IUserMountCache::class), + $this->createMock(LoggerInterface::class), + $this->createMock(IUserManager::class), + $this->createMock(IEventDispatcher::class), + $cacheFactory, ); $storage = new Temporary([]); $subStorage = new Temporary([]); @@ -63,6 +79,7 @@ class IntegrationTest extends \Test\TestCase { $this->storages[] = $subStorage; $this->root->mount($storage, '/'); $this->root->mount($subStorage, '/substorage/'); + $manager->removeMount('/' . $user->getUID()); } protected function tearDown(): void { @@ -74,7 +91,7 @@ class IntegrationTest extends \Test\TestCase { parent::tearDown(); } - public function testBasicFile() { + public function testBasicFile(): void { $file = $this->root->newFile('/foo.txt'); $this->assertCount(2, $this->root->getDirectoryListing()); $this->assertTrue($this->root->nodeExists('/foo.txt')); @@ -97,7 +114,7 @@ class IntegrationTest extends \Test\TestCase { $this->assertEquals('qwerty', $file->getContent()); } - public function testBasicFolder() { + public function testBasicFolder(): void { $folder = $this->root->newFolder('/foo'); $this->assertTrue($this->root->nodeExists('/foo')); $file = $folder->newFile('/bar'); |