aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/Files
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2022-02-23 18:29:08 +0100
committerRobin Appelman <robin@icewind.nl>2022-03-04 16:29:59 +0100
commit1c468129afa2b2ec4a370a879f8eaffd22768baf (patch)
tree1c096e8c0a62371965104684e1f1bf2ef55eb2d4 /tests/lib/Files
parent5c0fe934988960ece3ac71d5a1dfc8df405413aa (diff)
downloadnextcloud-server-1c468129afa2b2ec4a370a879f8eaffd22768baf.tar.gz
nextcloud-server-1c468129afa2b2ec4a370a879f8eaffd22768baf.zip
adjust tests to new fs setup
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'tests/lib/Files')
-rw-r--r--tests/lib/Files/Cache/UpdaterLegacyTest.php6
-rw-r--r--tests/lib/Files/Cache/UpdaterTest.php2
-rw-r--r--tests/lib/Files/Config/UserMountCacheTest.php2
-rw-r--r--tests/lib/Files/Mount/ManagerTest.php13
-rw-r--r--tests/lib/Files/Node/FileTest.php25
-rw-r--r--tests/lib/Files/Node/FolderTest.php44
-rw-r--r--tests/lib/Files/Node/HookConnectorTest.php3
-rw-r--r--tests/lib/Files/Node/IntegrationTest.php15
-rw-r--r--tests/lib/Files/Node/NodeTest.php14
-rw-r--r--tests/lib/Files/Node/RootTest.php22
-rw-r--r--tests/lib/Files/PathVerificationTest.php2
-rw-r--r--tests/lib/Files/ViewTest.php16
12 files changed, 106 insertions, 58 deletions
diff --git a/tests/lib/Files/Cache/UpdaterLegacyTest.php b/tests/lib/Files/Cache/UpdaterLegacyTest.php
index 6d6cc08b3de..be0390db15e 100644
--- a/tests/lib/Files/Cache/UpdaterLegacyTest.php
+++ b/tests/lib/Files/Cache/UpdaterLegacyTest.php
@@ -10,6 +10,7 @@ namespace Test\Files\Cache;
use OC\Files\Filesystem as Filesystem;
use OC\Files\View;
+use OCP\Files\Mount\IMountManager;
/**
* Class UpdaterLegacyTest
@@ -61,7 +62,10 @@ class UpdaterLegacyTest extends \Test\TestCase {
Filesystem::init(self::$user, '/' . self::$user . '/files');
- Filesystem::clearMounts();
+ /** @var IMountManager $manager */
+ $manager = \OC::$server->get(IMountManager::class);
+ $manager->removeMount('/' . self::$user);
+
Filesystem::mount($this->storage, [], '/' . self::$user . '/files');
\OC_Hook::clear('OC_Filesystem');
diff --git a/tests/lib/Files/Cache/UpdaterTest.php b/tests/lib/Files/Cache/UpdaterTest.php
index 4c99b24d9d6..7e0f6866793 100644
--- a/tests/lib/Files/Cache/UpdaterTest.php
+++ b/tests/lib/Files/Cache/UpdaterTest.php
@@ -50,8 +50,6 @@ class UpdaterTest extends \Test\TestCase {
}
protected function tearDown(): void {
- Filesystem::clearMounts();
-
$this->logout();
parent::tearDown();
}
diff --git a/tests/lib/Files/Config/UserMountCacheTest.php b/tests/lib/Files/Config/UserMountCacheTest.php
index 321ed2196fd..0922dab3672 100644
--- a/tests/lib/Files/Config/UserMountCacheTest.php
+++ b/tests/lib/Files/Config/UserMountCacheTest.php
@@ -45,6 +45,8 @@ class UserMountCacheTest extends TestCase {
private $fileIds = [];
protected function setUp(): void {
+ parent::setUp();
+
$this->fileIds = [];
$this->connection = \OC::$server->getDatabaseConnection();
$config = $this->getMockBuilder(IConfig::class)
diff --git a/tests/lib/Files/Mount/ManagerTest.php b/tests/lib/Files/Mount/ManagerTest.php
index 1e80ec17ea1..3fd994edd56 100644
--- a/tests/lib/Files/Mount/ManagerTest.php
+++ b/tests/lib/Files/Mount/ManagerTest.php
@@ -9,6 +9,10 @@
namespace Test\Files\Mount;
use OC\Files\Storage\Temporary;
+use OCP\Diagnostics\IEventLogger;
+use OCP\EventDispatcher\IEventDispatcher;
+use OCP\Files\Config\IMountProviderCollection;
+use OCP\IUserSession;
class LongId extends Temporary {
public function getId() {
@@ -24,12 +28,15 @@ class ManagerTest extends \Test\TestCase {
protected function setUp(): void {
parent::setUp();
- $this->manager = new \OC\Files\Mount\Manager();
+ $this->manager = new \OC\Files\Mount\Manager(
+ $this->createMock(IEventLogger::class),
+ $this->createMock(IMountProviderCollection::class),
+ $this->createMock(IUserSession::class),
+ $this->createMock(IEventDispatcher::class),
+ );
}
public function testFind() {
- $this->assertNull($this->manager->find('/'));
-
$rootMount = new \OC\Files\Mount\MountPoint(new Temporary([]), '/');
$this->manager->addMount($rootMount);
$this->assertEquals($rootMount, $this->manager->find('/'));
diff --git a/tests/lib/Files/Node/FileTest.php b/tests/lib/Files/Node/FileTest.php
index 6b5aaabbc28..c381fd9b2be 100644
--- a/tests/lib/Files/Node/FileTest.php
+++ b/tests/lib/Files/Node/FileTest.php
@@ -35,7 +35,7 @@ class FileTest extends NodeTest {
public function testGetContent() {
/** @var \OC\Files\Node\Root|\PHPUnit\Framework\MockObject\MockObject $root */
$root = $this->getMockBuilder('\OC\Files\Node\Root')
- ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
+ ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
$hook = function ($file) {
@@ -65,7 +65,7 @@ class FileTest extends NodeTest {
/** @var \OC\Files\Node\Root|\PHPUnit\Framework\MockObject\MockObject $root */
$root = $this->getMockBuilder('\OC\Files\Node\Root')
- ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
+ ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
$root->expects($this->any())
@@ -84,7 +84,7 @@ class FileTest extends NodeTest {
public function testPutContent() {
/** @var \OC\Files\Node\Root|\PHPUnit\Framework\MockObject\MockObject $root */
$root = $this->getMockBuilder('\OC\Files\Node\Root')
- ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
+ ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
$root->expects($this->any())
@@ -111,7 +111,7 @@ class FileTest extends NodeTest {
/** @var \OC\Files\Node\Root|\PHPUnit\Framework\MockObject\MockObject $root */
$root = $this->getMockBuilder('\OC\Files\Node\Root')
- ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
+ ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
$this->view->expects($this->once())
@@ -126,7 +126,7 @@ class FileTest extends NodeTest {
public function testGetMimeType() {
/** @var \OC\Files\Node\Root|\PHPUnit\Framework\MockObject\MockObject $root */
$root = $this->getMockBuilder('\OC\Files\Node\Root')
- ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
+ ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
$this->view->expects($this->once())
@@ -149,7 +149,8 @@ class FileTest extends NodeTest {
$this->user,
$this->userMountCache,
$this->logger,
- $this->userManager
+ $this->userManager,
+ $this->eventDispatcher
);
$hook = function ($file) {
@@ -184,7 +185,8 @@ class FileTest extends NodeTest {
$this->user,
$this->userMountCache,
$this->logger,
- $this->userManager
+ $this->userManager,
+ $this->eventDispatcher
);
$hooksCalled = 0;
$hook = function ($file) use (&$hooksCalled) {
@@ -223,7 +225,8 @@ class FileTest extends NodeTest {
$this->user,
$this->userMountCache,
$this->logger,
- $this->userManager
+ $this->userManager,
+ $this->eventDispatcher
);
$hook = function ($file) {
throw new \Exception('Hooks are not supposed to be called');
@@ -248,7 +251,8 @@ class FileTest extends NodeTest {
$this->user,
$this->userMountCache,
$this->logger,
- $this->userManager
+ $this->userManager,
+ $this->eventDispatcher
);
$hook = function () {
throw new \Exception('Hooks are not supposed to be called');
@@ -273,7 +277,8 @@ class FileTest extends NodeTest {
$this->user,
$this->userMountCache,
$this->logger,
- $this->userManager
+ $this->userManager,
+ $this->eventDispatcher
);
$hook = function () {
throw new \Exception('Hooks are not supposed to be called');
diff --git a/tests/lib/Files/Node/FolderTest.php b/tests/lib/Files/Node/FolderTest.php
index 72bd15d3922..d604786905d 100644
--- a/tests/lib/Files/Node/FolderTest.php
+++ b/tests/lib/Files/Node/FolderTest.php
@@ -61,7 +61,7 @@ class FolderTest extends NodeTest {
*/
$view = $this->createMock(View::class);
$root = $this->getMockBuilder(Root::class)
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
$root->expects($this->any())
->method('getUser')
@@ -93,7 +93,7 @@ class FolderTest extends NodeTest {
*/
$view = $this->createMock(View::class);
$root = $this->getMockBuilder(Root::class)
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
$root->expects($this->any())
->method('getUser')
@@ -113,7 +113,7 @@ class FolderTest extends NodeTest {
*/
$view = $this->createMock(View::class);
$root = $this->getMockBuilder(Root::class)
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
$root->expects($this->any())
->method('getUser')
@@ -136,7 +136,7 @@ class FolderTest extends NodeTest {
*/
$view = $this->createMock(View::class);
$root = $this->getMockBuilder(Root::class)
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
$root->expects($this->any())
->method('getUser')
@@ -157,7 +157,7 @@ class FolderTest extends NodeTest {
*/
$view = $this->createMock(View::class);
$root = $this->getMockBuilder(Root::class)
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
$root->expects($this->any())
->method('getUser')
@@ -187,7 +187,7 @@ class FolderTest extends NodeTest {
*/
$view = $this->createMock(View::class);
$root = $this->getMockBuilder(Root::class)
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
$root->method('getUser')
->willReturn($this->user);
@@ -207,7 +207,7 @@ class FolderTest extends NodeTest {
*/
$view = $this->createMock(View::class);
$root = $this->getMockBuilder(Root::class)
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
$root->expects($this->any())
->method('getUser')
@@ -237,7 +237,7 @@ class FolderTest extends NodeTest {
*/
$view = $this->createMock(View::class);
$root = $this->getMockBuilder(Root::class)
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
$root->method('getUser')
->willReturn($this->user);
@@ -257,7 +257,7 @@ class FolderTest extends NodeTest {
*/
$view = $this->createMock(View::class);
$root = $this->getMockBuilder(Root::class)
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
$root->method('getUser')
->willReturn($this->user);
@@ -277,7 +277,7 @@ class FolderTest extends NodeTest {
*/
$view = $this->createMock(View::class);
$root = $this->getMockBuilder(Root::class)
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
$root->method('getUser')
->willReturn($this->user);
@@ -321,7 +321,7 @@ class FolderTest extends NodeTest {
$view = $this->createMock(View::class);
$root = $this->getMockBuilder(Root::class)
->setMethods(['getUser', 'getMountsIn', 'getMount'])
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
$root->expects($this->any())
->method('getUser')
@@ -364,7 +364,7 @@ class FolderTest extends NodeTest {
*/
$view = $this->createMock(View::class);
$root = $this->getMockBuilder(Root::class)
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
$root->method('getUser')
->willReturn($this->user);
@@ -407,7 +407,7 @@ class FolderTest extends NodeTest {
*/
$view = $this->createMock(View::class);
$root = $this->getMockBuilder(Root::class)
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
$root->expects($this->any())
->method('getUser')
@@ -479,7 +479,7 @@ class FolderTest extends NodeTest {
$view = $this->createMock(View::class);
$root = $this->getMockBuilder(Root::class)
->setMethods(['getMountsIn', 'getMount'])
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
$storage = $this->createMock(\OC\Files\Storage\Storage::class);
$mount = new MountPoint($storage, '/bar');
@@ -530,7 +530,7 @@ class FolderTest extends NodeTest {
$view = $this->createMock(View::class);
$root = $this->getMockBuilder(Root::class)
->setMethods(['getMountsIn', 'getMount'])
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
$storage = $this->createMock(\OC\Files\Storage\Storage::class);
$mount = new MountPoint($storage, '/bar');
@@ -577,7 +577,7 @@ class FolderTest extends NodeTest {
$view = $this->createMock(View::class);
$root = $this->getMockBuilder(Root::class)
->setMethods(['getMountsIn', 'getMount'])
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
$storage = $this->createMock(\OC\Files\Storage\Storage::class);
$mount = new MountPoint($storage, '/bar');
@@ -627,7 +627,7 @@ class FolderTest extends NodeTest {
$view = $this->createMock(View::class);
$root = $this->getMockBuilder(Root::class)
->setMethods(['getMountsIn', 'getMount'])
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
$storage = $this->createMock(\OC\Files\Storage\Storage::class);
$mount1 = new MountPoint($storage, '/bar');
@@ -697,7 +697,7 @@ class FolderTest extends NodeTest {
$view = $this->createMock(View::class);
$root = $this->getMockBuilder(Root::class)
->setMethods(['getUser', 'getMountsIn', 'getMount'])
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
$view->expects($this->any())
@@ -725,7 +725,7 @@ class FolderTest extends NodeTest {
/** @var \PHPUnit\Framework\MockObject\MockObject|\OC\Files\Node\Root $root */
$root = $this->getMockBuilder(Root::class)
->setMethods(['getUser', 'getMountsIn', 'getMount'])
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
/** @var \PHPUnit\Framework\MockObject\MockObject|\OC\Files\FileInfo $folderInfo */
$folderInfo = $this->getMockBuilder(FileInfo::class)
@@ -793,7 +793,7 @@ class FolderTest extends NodeTest {
/** @var \PHPUnit\Framework\MockObject\MockObject|\OC\Files\Node\Root $root */
$root = $this->getMockBuilder(Root::class)
->setMethods(['getUser', 'getMountsIn', 'getMount'])
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
/** @var \PHPUnit\Framework\MockObject\MockObject|\OC\Files\FileInfo $folderInfo */
$folderInfo = $this->getMockBuilder(FileInfo::class)
@@ -860,7 +860,7 @@ class FolderTest extends NodeTest {
/** @var \PHPUnit\Framework\MockObject\MockObject|\OC\Files\Node\Root $root */
$root = $this->getMockBuilder(Root::class)
->setMethods(['getUser', 'getMountsIn', 'getMount'])
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
/** @var \PHPUnit\Framework\MockObject\MockObject|\OC\Files\FileInfo $folderInfo */
$folderInfo = $this->getMockBuilder(FileInfo::class)
@@ -947,7 +947,7 @@ class FolderTest extends NodeTest {
*/
$view = $this->createMock(View::class);
$root = $this->getMockBuilder(Root::class)
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
+ ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
$root->expects($this->any())
->method('getUser')
diff --git a/tests/lib/Files/Node/HookConnectorTest.php b/tests/lib/Files/Node/HookConnectorTest.php
index 7990abad231..5e0b4017243 100644
--- a/tests/lib/Files/Node/HookConnectorTest.php
+++ b/tests/lib/Files/Node/HookConnectorTest.php
@@ -78,7 +78,8 @@ class HookConnectorTest extends TestCase {
\OC::$server->getUserManager()->get($this->userId),
\OC::$server->getUserMountCache(),
$this->createMock(ILogger::class),
- $this->createMock(IUserManager::class)
+ $this->createMock(IUserManager::class),
+ $this->createMock(IEventDispatcher::class)
);
$this->legacyDispatcher = \OC::$server->getEventDispatcher();
$this->eventDispatcher = \OC::$server->query(IEventDispatcher::class);
diff --git a/tests/lib/Files/Node/IntegrationTest.php b/tests/lib/Files/Node/IntegrationTest.php
index 26cdf398d94..71e8793ad6f 100644
--- a/tests/lib/Files/Node/IntegrationTest.php
+++ b/tests/lib/Files/Node/IntegrationTest.php
@@ -11,9 +11,11 @@ namespace Test\Files\Node;
use OC\Files\Node\Root;
use OC\Files\Storage\Temporary;
use OC\Files\View;
-use OC\User\User;
+use OCP\EventDispatcher\IEventDispatcher;
+use OCP\Files\Mount\IMountManager;
use OCP\ILogger;
use OCP\IUserManager;
+use Test\Traits\UserTrait;
/**
* Class IntegrationTest
@@ -23,6 +25,8 @@ use OCP\IUserManager;
* @package Test\Files\Node
*/
class IntegrationTest extends \Test\TestCase {
+ use UserTrait;
+
/**
* @var \OC\Files\Node\Root $root
*/
@@ -41,11 +45,12 @@ class IntegrationTest extends \Test\TestCase {
protected function setUp(): void {
parent::setUp();
- $manager = \OC\Files\Filesystem::getMountManager();
+ /** @var IMountManager $manager */
+ $manager = \OC::$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());
$this->view = new View();
@@ -55,7 +60,8 @@ class IntegrationTest extends \Test\TestCase {
$user,
\OC::$server->getUserMountCache(),
$this->createMock(ILogger::class),
- $this->createMock(IUserManager::class)
+ $this->createMock(IUserManager::class),
+ $this->createMock(IEventDispatcher::class)
);
$storage = new Temporary([]);
$subStorage = new Temporary([]);
@@ -63,6 +69,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 {
diff --git a/tests/lib/Files/Node/NodeTest.php b/tests/lib/Files/Node/NodeTest.php
index 6ea5a6d7ffa..a60a20b99f3 100644
--- a/tests/lib/Files/Node/NodeTest.php
+++ b/tests/lib/Files/Node/NodeTest.php
@@ -11,6 +11,7 @@ namespace Test\Files\Node;
use OC\Files\FileInfo;
use OC\Files\Mount\Manager;
use OC\Files\View;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\IRootFolder;
use OCP\Files\Node;
use OCP\Files\NotFoundException;
@@ -39,6 +40,8 @@ abstract class NodeTest extends \Test\TestCase {
protected $logger;
/** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */
protected $userManager;
+ /** @var IEventDispatcher|\PHPUnit\Framework\MockObject\MockObject */
+ protected $eventDispatcher;
protected function setUp(): void {
parent::setUp();
@@ -55,8 +58,9 @@ abstract class NodeTest extends \Test\TestCase {
->getMock();
$this->logger = $this->createMock(ILogger::class);
$this->userManager = $this->createMock(IUserManager::class);
+ $this->eventDispatcher = $this->createMock(IEventDispatcher::class);
$this->root = $this->getMockBuilder('\OC\Files\Node\Root')
- ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
+ ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher, $this->eventDispatcher])
->getMock();
}
@@ -151,7 +155,8 @@ abstract class NodeTest extends \Test\TestCase {
$this->user,
$this->userMountCache,
$this->logger,
- $this->userManager
+ $this->userManager,
+ $this->eventDispatcher
);
$root->listen('\OC\Files', 'preDelete', $preListener);
@@ -409,7 +414,8 @@ abstract class NodeTest extends \Test\TestCase {
$this->user,
$this->userMountCache,
$this->logger,
- $this->userManager
+ $this->userManager,
+ $this->eventDispatcher
);
$root->listen('\OC\Files', 'preTouch', $preListener);
$root->listen('\OC\Files', 'postTouch', $postListener);
@@ -592,7 +598,7 @@ abstract class NodeTest extends \Test\TestCase {
public function testMoveCopyHooks($operationMethod, $viewMethod, $preHookName, $postHookName) {
/** @var IRootFolder|\PHPUnit\Framework\MockObject\MockObject $root */
$root = $this->getMockBuilder('\OC\Files\Node\Root')
- ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager])
+ ->setConstructorArgs([$this->manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->setMethods(['get'])
->getMock();
diff --git a/tests/lib/Files/Node/RootTest.php b/tests/lib/Files/Node/RootTest.php
index 13fdcb65902..a7f7dc02e01 100644
--- a/tests/lib/Files/Node/RootTest.php
+++ b/tests/lib/Files/Node/RootTest.php
@@ -13,6 +13,7 @@ use OC\Files\FileInfo;
use OC\Files\Mount\Manager;
use OC\Files\Node\Folder;
use OC\Files\View;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\ILogger;
use OCP\IUser;
use OCP\IUserManager;
@@ -33,6 +34,8 @@ class RootTest extends \Test\TestCase {
private $logger;
/** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */
private $userManager;
+ /** @var IEventDispatcher|\PHPUnit\Framework\MockObject\MockObject */
+ private $eventDispatcher;
protected function setUp(): void {
parent::setUp();
@@ -46,6 +49,7 @@ class RootTest extends \Test\TestCase {
->getMock();
$this->logger = $this->createMock(ILogger::class);
$this->userManager = $this->createMock(IUserManager::class);
+ $this->eventDispatcher = $this->createMock(IEventDispatcher::class);
}
protected function getFileInfo($data) {
@@ -71,7 +75,8 @@ class RootTest extends \Test\TestCase {
$this->user,
$this->userMountCache,
$this->logger,
- $this->userManager
+ $this->userManager,
+ $this->eventDispatcher
);
$view->expects($this->once())
@@ -107,7 +112,8 @@ class RootTest extends \Test\TestCase {
$this->user,
$this->userMountCache,
$this->logger,
- $this->userManager
+ $this->userManager,
+ $this->eventDispatcher
);
$view->expects($this->once())
@@ -135,7 +141,8 @@ class RootTest extends \Test\TestCase {
$this->user,
$this->userMountCache,
$this->logger,
- $this->userManager
+ $this->userManager,
+ $this->eventDispatcher
);
$root->get('/../foo');
@@ -157,7 +164,8 @@ class RootTest extends \Test\TestCase {
$this->user,
$this->userMountCache,
$this->logger,
- $this->userManager
+ $this->userManager,
+ $this->eventDispatcher
);
$root->get('/bar/foo');
@@ -170,7 +178,8 @@ class RootTest extends \Test\TestCase {
$this->user,
$this->userMountCache,
$this->logger,
- $this->userManager
+ $this->userManager,
+ $this->eventDispatcher
);
$user = $this->createMock(IUser::class);
$user
@@ -210,7 +219,8 @@ class RootTest extends \Test\TestCase {
null,
$this->userMountCache,
$this->logger,
- $this->userManager
+ $this->userManager,
+ $this->eventDispatcher
);
$this->userManager
->expects($this->once())
diff --git a/tests/lib/Files/PathVerificationTest.php b/tests/lib/Files/PathVerificationTest.php
index 18637daf9d7..3570acfaab4 100644
--- a/tests/lib/Files/PathVerificationTest.php
+++ b/tests/lib/Files/PathVerificationTest.php
@@ -30,7 +30,7 @@ class PathVerificationTest extends \Test\TestCase {
$this->view = new View();
}
-
+
public function testPathVerificationFileNameTooLong() {
$this->expectException(\OCP\Files\InvalidPathException::class);
$this->expectExceptionMessage('File name is too long');
diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php
index 15c9400864b..7b735720ff1 100644
--- a/tests/lib/Files/ViewTest.php
+++ b/tests/lib/Files/ViewTest.php
@@ -11,6 +11,7 @@ use OC\Cache\CappedMemoryCache;
use OC\Files\Cache\Watcher;
use OC\Files\Filesystem;
use OC\Files\Mount\MountPoint;
+use OC\Files\SetupManager;
use OC\Files\Storage\Common;
use OC\Files\Storage\Storage;
use OC\Files\Storage\Temporary;
@@ -19,6 +20,7 @@ use OCP\Constants;
use OCP\Files\Config\IMountProvider;
use OCP\Files\FileInfo;
use OCP\Files\GenericFileException;
+use OCP\Files\Mount\IMountManager;
use OCP\Files\Storage\IStorage;
use OCP\Lock\ILockingProvider;
use OCP\Lock\LockedException;
@@ -104,9 +106,10 @@ class ViewTest extends \Test\TestCase {
$this->groupObject->addUser($this->userObject);
self::loginAsUser($this->user);
- // clear mounts but somehow keep the root storage
- // that was initialized above...
- Filesystem::clearMounts();
+
+ /** @var IMountManager $manager */
+ $manager = \OC::$server->get(IMountManager::class);
+ $manager->removeMount('/test');
$this->tempStorage = null;
}
@@ -125,6 +128,10 @@ class ViewTest extends \Test\TestCase {
self::logout();
+ /** @var SetupManager $setupManager */
+ $setupManager = \OC::$server->get(SetupManager::class);
+ $setupManager->setupRoot();
+
$this->userObject->delete();
$this->groupObject->delete();
@@ -224,12 +231,14 @@ class ViewTest extends \Test\TestCase {
$storage1 = $this->getTestStorage();
$storage2 = $this->getTestStorage();
$storage3 = $this->getTestStorage();
+
Filesystem::mount($storage1, [], '/');
Filesystem::mount($storage2, [], '/substorage');
Filesystem::mount($storage3, [], '/folder/anotherstorage');
$rootView = new View('');
+
$cachedData = $rootView->getFileInfo('/foo.txt');
/** @var int $id1 */
$id1 = $cachedData['fileid'];
@@ -316,7 +325,6 @@ class ViewTest extends \Test\TestCase {
public function testCacheIncompleteFolder() {
$storage1 = $this->getTestStorage(false);
- Filesystem::clearMounts();
Filesystem::mount($storage1, [], '/incomplete');
$rootView = new View('/incomplete');