diff options
author | Joas Schilling <coding@schilljs.com> | 2016-07-13 16:54:19 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-13 16:54:19 +0200 |
commit | c04e7b13c342ee9c1d57cf117f6bb14a157d6b4e (patch) | |
tree | 207e45921ea3b79126e12ac4976c2a654a4e858e /tests | |
parent | e1bad212cf1a9e1edccaf3205f3a83c6c1281ace (diff) | |
parent | 927be847b9a9bcab1f87824e13ac55770564aa42 (diff) | |
download | nextcloud-server-c04e7b13c342ee9c1d57cf117f6bb14a157d6b4e.tar.gz nextcloud-server-c04e7b13c342ee9c1d57cf117f6bb14a157d6b4e.zip |
Merge pull request #392 from nextcloud/roottest_nodb
RootTest does not require DB
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/Files/Node/RootTest.php | 59 |
1 files changed, 39 insertions, 20 deletions
diff --git a/tests/lib/Files/Node/RootTest.php b/tests/lib/Files/Node/RootTest.php index 1b4824cba76..92aebcddab4 100644 --- a/tests/lib/Files/Node/RootTest.php +++ b/tests/lib/Files/Node/RootTest.php @@ -9,18 +9,29 @@ namespace Test\Files\Node; use OC\Files\FileInfo; -use OCP\Files\NotPermittedException; -use OC\Files\Mount\Manager; -/** - * @group DB - */ class RootTest extends \Test\TestCase { + /** @var \OC\User\User */ private $user; + /** @var \OC\Files\Mount\Manager */ + private $manager; + protected function setUp() { parent::setUp(); - $this->user = new \OC\User\User('', new \Test\Util\User\Dummy); + + $config = $this->getMockBuilder('\OCP\IConfig') + ->disableOriginalConstructor() + ->getMock(); + $urlgenerator = $this->getMockBuilder('\OCP\IURLGenerator') + ->disableOriginalConstructor() + ->getMock(); + + $this->user = new \OC\User\User('', new \Test\Util\User\Dummy, null, $config, $urlgenerator); + + $this->manager = $this->getMockBuilder('\OC\Files\Mount\Manager') + ->disableOriginalConstructor() + ->getMock(); } protected function getFileInfo($data) { @@ -28,16 +39,19 @@ class RootTest extends \Test\TestCase { } public function testGet() { - $manager = new Manager(); /** * @var \OC\Files\Storage\Storage $storage */ - $storage = $this->getMock('\OC\Files\Storage\Storage'); + $storage = $this->getMockBuilder('\OC\Files\Storage\Storage') + ->disableOriginalConstructor() + ->getMock(); /** * @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view */ - $view = $this->getMock('\OC\Files\View'); - $root = new \OC\Files\Node\Root($manager, $view, $this->user); + $view = $this->getMockBuilder('\OC\Files\View') + ->disableOriginalConstructor() + ->getMock(); + $root = new \OC\Files\Node\Root($this->manager, $view, $this->user); $view->expects($this->once()) ->method('getFileInfo') @@ -54,16 +68,19 @@ class RootTest extends \Test\TestCase { * @expectedException \OCP\Files\NotFoundException */ public function testGetNotFound() { - $manager = new Manager(); /** * @var \OC\Files\Storage\Storage $storage */ - $storage = $this->getMock('\OC\Files\Storage\Storage'); + $storage = $this->getMockBuilder('\OC\Files\Storage\Storage') + ->disableOriginalConstructor() + ->getMock(); /** * @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view */ - $view = $this->getMock('\OC\Files\View'); - $root = new \OC\Files\Node\Root($manager, $view, $this->user); + $view = $this->getMockBuilder('\OC\Files\View') + ->disableOriginalConstructor() + ->getMock(); + $root = new \OC\Files\Node\Root($this->manager, $view, $this->user); $view->expects($this->once()) ->method('getFileInfo') @@ -78,12 +95,13 @@ class RootTest extends \Test\TestCase { * @expectedException \OCP\Files\NotPermittedException */ public function testGetInvalidPath() { - $manager = new Manager(); /** * @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view */ - $view = $this->getMock('\OC\Files\View'); - $root = new \OC\Files\Node\Root($manager, $view, $this->user); + $view = $this->getMockBuilder('\OC\Files\View') + ->disableOriginalConstructor() + ->getMock(); + $root = new \OC\Files\Node\Root($this->manager, $view, $this->user); $root->get('/../foo'); } @@ -92,12 +110,13 @@ class RootTest extends \Test\TestCase { * @expectedException \OCP\Files\NotFoundException */ public function testGetNoStorages() { - $manager = new Manager(); /** * @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view */ - $view = $this->getMock('\OC\Files\View'); - $root = new \OC\Files\Node\Root($manager, $view, $this->user); + $view = $this->getMockBuilder('\OC\Files\View') + ->disableOriginalConstructor() + ->getMock(); + $root = new \OC\Files\Node\Root($this->manager, $view, $this->user); $root->get('/bar/foo'); } |