aboutsummaryrefslogtreecommitdiffstats
path: root/tests/lib/Files/Node/RootTest.php
diff options
context:
space:
mode:
authorSimon L <szaimen@e.mail.de>2023-04-18 04:11:44 +0200
committerGitHub <noreply@github.com>2023-04-18 04:11:44 +0200
commit855e7a2efb377653d0ce50ff9c0e43ec27612413 (patch)
tree35c17a4cb706b29d03b4a1a866ac0f7d997b5355 /tests/lib/Files/Node/RootTest.php
parente10e509452de7f69c64e394a652b46a6ca2cbd95 (diff)
parentd9c81f56ad25d6665e87468cf18dc2646334fb3b (diff)
downloadnextcloud-server-855e7a2efb377653d0ce50ff9c0e43ec27612413.tar.gz
nextcloud-server-855e7a2efb377653d0ce50ff9c0e43ec27612413.zip
Merge pull request #36774 from nextcloud/bugfix/noid/sabre-nodes
fix: always use proper path on node api when calling the view
Diffstat (limited to 'tests/lib/Files/Node/RootTest.php')
-rw-r--r--tests/lib/Files/Node/RootTest.php43
1 files changed, 17 insertions, 26 deletions
diff --git a/tests/lib/Files/Node/RootTest.php b/tests/lib/Files/Node/RootTest.php
index 5d8e2a4ac62..aab658c3c36 100644
--- a/tests/lib/Files/Node/RootTest.php
+++ b/tests/lib/Files/Node/RootTest.php
@@ -52,6 +52,17 @@ class RootTest extends \Test\TestCase {
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
}
+ /**
+ * @return \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject $view
+ */
+ protected function getRootViewMock() {
+ $view = $this->createMock(View::class);
+ $view->expects($this->any())
+ ->method('getRoot')
+ ->willReturn('');
+ return $view;
+ }
+
protected function getFileInfo($data) {
return new FileInfo('', null, '', $data, null);
}
@@ -63,12 +74,7 @@ class RootTest extends \Test\TestCase {
$storage = $this->getMockBuilder('\OC\Files\Storage\Storage')
->disableOriginalConstructor()
->getMock();
- /**
- * @var \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject $view
- */
- $view = $this->getMockBuilder(View::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $view = $this->getRootViewMock();
$root = new \OC\Files\Node\Root(
$this->manager,
$view,
@@ -100,12 +106,7 @@ class RootTest extends \Test\TestCase {
$storage = $this->getMockBuilder('\OC\Files\Storage\Storage')
->disableOriginalConstructor()
->getMock();
- /**
- * @var \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject $view
- */
- $view = $this->getMockBuilder(View::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $view = $this->getRootViewMock();
$root = new \OC\Files\Node\Root(
$this->manager,
$view,
@@ -129,12 +130,7 @@ class RootTest extends \Test\TestCase {
public function testGetInvalidPath() {
$this->expectException(\OCP\Files\NotPermittedException::class);
- /**
- * @var \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject $view
- */
- $view = $this->getMockBuilder(View::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $view = $this->getRootViewMock();
$root = new \OC\Files\Node\Root(
$this->manager,
$view,
@@ -152,12 +148,7 @@ class RootTest extends \Test\TestCase {
public function testGetNoStorages() {
$this->expectException(\OCP\Files\NotFoundException::class);
- /**
- * @var \OC\Files\View | \PHPUnit\Framework\MockObject\MockObject $view
- */
- $view = $this->getMockBuilder(View::class)
- ->disableOriginalConstructor()
- ->getMock();
+ $view = $this->getRootViewMock();
$root = new \OC\Files\Node\Root(
$this->manager,
$view,
@@ -174,7 +165,7 @@ class RootTest extends \Test\TestCase {
public function testGetUserFolder() {
$root = new \OC\Files\Node\Root(
$this->manager,
- $this->createMock(View::class),
+ $this->getRootViewMock(),
$this->user,
$this->userMountCache,
$this->logger,
@@ -215,7 +206,7 @@ class RootTest extends \Test\TestCase {
$root = new \OC\Files\Node\Root(
$this->createMock(Manager::class),
- $this->createMock(View::class),
+ $this->getRootViewMock(),
null,
$this->userMountCache,
$this->logger,