use OC\Files\Search\SearchQuery;
use OC\Files\Storage\Temporary;
use OC\Files\Storage\Wrapper\Jail;
-use OC\Files\View;
use OCP\Files\Cache\ICacheEntry;
use OCP\Files\Mount\IMountPoint;
use OCP\Files\NotFoundException;
*/
class FolderTest extends NodeTest {
protected function createTestNode($root, $view, $path, array $data = [], $internalPath = '', $storage = null) {
+ $view->expects($this->any())
+ ->method('getRoot')
+ ->willReturn('');
if ($data || $internalPath || $storage) {
return new Folder($root, $view, $path, $this->getFileInfo($data, $internalPath, $storage));
} else {
/**
* @var \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject $view
*/
- $view = $this->createMock(View::class);
$root = $this->getMockBuilder(Root::class)
- ->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
+ ->setConstructorArgs([$manager, $this->view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
$root->expects($this->any())
->method('getUser')
->willReturn($this->user);
- $view->expects($this->any())
+ $this->view->expects($this->any())
->method('getDirectoryContent')
->with('/bar/foo')
->willReturn([
new FileInfo('/bar/foo/asd', null, 'foo/asd', ['fileid' => 2, 'path' => '/bar/foo/asd', 'name' => 'asd', 'size' => 100, 'mtime' => 50, 'mimetype' => 'text/plain'], null),
new FileInfo('/bar/foo/qwerty', null, 'foo/qwerty', ['fileid' => 3, 'path' => '/bar/foo/qwerty', 'name' => 'qwerty', 'size' => 200, 'mtime' => 55, 'mimetype' => 'httpd/unix-directory'], null),
]);
- $view->method('getFileInfo')
+ $this->view->method('getFileInfo')
->willReturn($this->createMock(FileInfo::class));
- $view->method('getRelativePath')
+ $this->view->method('getRelativePath')
->willReturn('/bar/foo');
- $node = new Folder($root, $view, '/bar/foo');
+ $node = new Folder($root, $this->view, '/bar/foo');
$children = $node->getDirectoryListing();
$this->assertEquals(2, count($children));
$this->assertInstanceOf('\OC\Files\Node\File', $children[0]);
public function testGet() {
$manager = $this->createMock(Manager::class);
- /**
- * @var \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject $view
- */
- $view = $this->createMock(View::class);
+ $view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
public function testNodeExists() {
$manager = $this->createMock(Manager::class);
- /**
- * @var \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject $view
- */
- $view = $this->createMock(View::class);
+ $view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
public function testNodeExistsNotExists() {
$manager = $this->createMock(Manager::class);
- /**
- * @var \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject $view
- */
- $view = $this->createMock(View::class);
+ $view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
public function testNewFolder() {
$manager = $this->createMock(Manager::class);
- /**
- * @var \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject $view
- */
- $view = $this->createMock(View::class);
+ $view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
public function testNewFolderDeepParent() {
$manager = $this->createMock(Manager::class);
- /**
- * @var \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject $view
- */
- $view = $this->createMock(View::class);
+ $view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
$this->expectException(\OCP\Files\NotPermittedException::class);
$manager = $this->createMock(Manager::class);
- /**
- * @var \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject $view
- */
- $view = $this->createMock(View::class);
+ $view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
public function testNewFile() {
$manager = $this->createMock(Manager::class);
- /**
- * @var \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject $view
- */
- $view = $this->createMock(View::class);
+ $view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
$this->expectException(\OCP\Files\NotPermittedException::class);
$manager = $this->createMock(Manager::class);
- /**
- * @var \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject $view
- */
- $view = $this->createMock(View::class);
+ $view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
public function testGetFreeSpace() {
$manager = $this->createMock(Manager::class);
- /**
- * @var \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject $view
- */
- $view = $this->createMock(View::class);
+ $view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
public function testSearch() {
$manager = $this->createMock(Manager::class);
- /**
- * @var \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject $view
- */
- $view = $this->createMock(View::class);
+ $view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
public function testSearchInRoot() {
$manager = $this->createMock(Manager::class);
- /**
- * @var \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject $view
- */
- $view = $this->createMock(View::class);
+ $view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
->setMethods(['getUser', 'getMountsIn', 'getMount'])
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
public function testSearchInStorageRoot() {
$manager = $this->createMock(Manager::class);
- /**
- * @var \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject $view
- */
- $view = $this->createMock(View::class);
+ $view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
public function testSearchSubStorages() {
$manager = $this->createMock(Manager::class);
- /**
- * @var \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject $view
- */
- $view = $this->createMock(View::class);
+ $view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();
}
public function testIsSubNode() {
- $file = new Node(null, null, '/foo/bar');
- $folder = new Folder(null, null, '/foo');
+ $file = new Node(null, $this->view, '/foo/bar');
+ $folder = new Folder(null, $this->view, '/foo');
$this->assertTrue($folder->isSubNode($file));
$this->assertFalse($folder->isSubNode($folder));
- $file = new Node(null, null, '/foobar');
+ $file = new Node(null, $this->view, '/foobar');
$this->assertFalse($folder->isSubNode($file));
}
public function testGetById() {
$manager = $this->createMock(Manager::class);
- /**
- * @var \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject $view
- */
- $view = $this->createMock(View::class);
+ $view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
->setMethods(['getMountsIn', 'getMount'])
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
public function testGetByIdMountRoot() {
$manager = $this->createMock(Manager::class);
- /**
- * @var \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject $view
- */
- $view = $this->createMock(View::class);
+ $view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
->setMethods(['getMountsIn', 'getMount'])
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
public function testGetByIdOutsideFolder() {
$manager = $this->createMock(Manager::class);
- /**
- * @var \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject $view
- */
- $view = $this->createMock(View::class);
+ $view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
->setMethods(['getMountsIn', 'getMount'])
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
public function testGetByIdMultipleStorages() {
$manager = $this->createMock(Manager::class);
- /**
- * @var \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject $view
- */
- $view = $this->createMock(View::class);
+ $view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
->setMethods(['getMountsIn', 'getMount'])
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
public function testGetUniqueName($name, $existingFiles, $expected) {
$manager = $this->createMock(Manager::class);
$folderPath = '/bar/foo';
- /**
- * @var \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject $view
- */
- $view = $this->createMock(View::class);
+ $view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
->setMethods(['getUser', 'getMountsIn', 'getMount'])
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
public function testRecent(): void {
$manager = $this->createMock(Manager::class);
$folderPath = '/bar/foo';
- /**
- * @var \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject $view
- */
- $view = $this->createMock(View::class);
+ $view = $this->getRootViewMock();
/** @var \PHPUnit\Framework\MockObject\MockObject|\OC\Files\Node\Root $root */
$root = $this->getMockBuilder(Root::class)
->setMethods(['getUser', 'getMountsIn', 'getMount'])
public function testRecentFolder() {
$manager = $this->createMock(Manager::class);
$folderPath = '/bar/foo';
- /**
- * @var \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject $view
- */
- $view = $this->createMock(View::class);
+ $view = $this->getRootViewMock();
/** @var \PHPUnit\Framework\MockObject\MockObject|\OC\Files\Node\Root $root */
$root = $this->getMockBuilder(Root::class)
->setMethods(['getUser', 'getMountsIn', 'getMount'])
public function testRecentJail() {
$manager = $this->createMock(Manager::class);
$folderPath = '/bar/foo';
- /**
- * @var \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject $view
- */
- $view = $this->createMock(View::class);
+ $view = $this->getRootViewMock();
/** @var \PHPUnit\Framework\MockObject\MockObject|\OC\Files\Node\Root $root */
$root = $this->getMockBuilder(Root::class)
->setMethods(['getUser', 'getMountsIn', 'getMount'])
}
$manager = $this->createMock(Manager::class);
- /**
- * @var \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject $view
- */
- $view = $this->createMock(View::class);
+ $view = $this->getRootViewMock();
$root = $this->getMockBuilder(Root::class)
->setConstructorArgs([$manager, $view, $this->user, $this->userMountCache, $this->logger, $this->userManager, $this->eventDispatcher])
->getMock();