summaryrefslogtreecommitdiffstats
path: root/tests/lib/Files/Node
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2019-11-27 15:27:18 +0100
committerRoeland Jago Douma <roeland@famdouma.nl>2019-11-27 15:27:18 +0100
commit3a7cf40aaa678bea1df143d2982d603b7a334eec (patch)
tree63c1e3ad7f7f401d14411a4d44c523632906afc9 /tests/lib/Files/Node
parent0568b012672d650c6b5a49e72c4028dde5463c60 (diff)
downloadnextcloud-server-3a7cf40aaa678bea1df143d2982d603b7a334eec.tar.gz
nextcloud-server-3a7cf40aaa678bea1df143d2982d603b7a334eec.zip
Mode to modern phpunit
Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'tests/lib/Files/Node')
-rw-r--r--tests/lib/Files/Node/FileTest.php30
-rw-r--r--tests/lib/Files/Node/FolderTest.php12
-rw-r--r--tests/lib/Files/Node/HookConnectorTest.php4
-rw-r--r--tests/lib/Files/Node/NodeTest.php66
-rw-r--r--tests/lib/Files/Node/RootTest.php26
5 files changed, 69 insertions, 69 deletions
diff --git a/tests/lib/Files/Node/FileTest.php b/tests/lib/Files/Node/FileTest.php
index a17cc1d1a3a..2cdf9cbdc5a 100644
--- a/tests/lib/Files/Node/FileTest.php
+++ b/tests/lib/Files/Node/FileTest.php
@@ -59,10 +59,10 @@ class FileTest extends NodeTest {
$this->assertEquals('bar', $node->getContent());
}
- /**
- * @expectedException \OCP\Files\NotPermittedException
- */
+
public function testGetContentNotPermitted() {
+ $this->expectException(\OCP\Files\NotPermittedException::class);
+
/** @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])
@@ -105,10 +105,10 @@ class FileTest extends NodeTest {
$node->putContent('bar');
}
- /**
- * @expectedException \OCP\Files\NotPermittedException
- */
+
public function testPutContentNotPermitted() {
+ $this->expectException(\OCP\Files\NotPermittedException::class);
+
/** @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])
@@ -213,10 +213,10 @@ class FileTest extends NodeTest {
$this->assertEquals(2, $hooksCalled);
}
- /**
- * @expectedException \OCP\Files\NotPermittedException
- */
+
public function testFOpenReadNotPermitted() {
+ $this->expectException(\OCP\Files\NotPermittedException::class);
+
$root = new \OC\Files\Node\Root(
$this->manager,
$this->view,
@@ -238,10 +238,10 @@ class FileTest extends NodeTest {
$node->fopen('r');
}
- /**
- * @expectedException \OCP\Files\NotPermittedException
- */
+
public function testFOpenReadWriteNoReadPermissions() {
+ $this->expectException(\OCP\Files\NotPermittedException::class);
+
$root = new \OC\Files\Node\Root(
$this->manager,
$this->view,
@@ -263,10 +263,10 @@ class FileTest extends NodeTest {
$node->fopen('w');
}
- /**
- * @expectedException \OCP\Files\NotPermittedException
- */
+
public function testFOpenReadWriteNoWritePermissions() {
+ $this->expectException(\OCP\Files\NotPermittedException::class);
+
$root = new \OC\Files\Node\Root(
$this->manager,
new $this->view,
diff --git a/tests/lib/Files/Node/FolderTest.php b/tests/lib/Files/Node/FolderTest.php
index 3390d19feb7..d33fb4f68f8 100644
--- a/tests/lib/Files/Node/FolderTest.php
+++ b/tests/lib/Files/Node/FolderTest.php
@@ -176,10 +176,10 @@ class FolderTest extends NodeTest {
$this->assertEquals($child, $result);
}
- /**
- * @expectedException \OCP\Files\NotPermittedException
- */
+
public function testNewFolderNotPermitted() {
+ $this->expectException(\OCP\Files\NotPermittedException::class);
+
$manager = $this->createMock(Manager::class);
/**
* @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view
@@ -230,10 +230,10 @@ class FolderTest extends NodeTest {
$this->assertEquals($child, $result);
}
- /**
- * @expectedException \OCP\Files\NotPermittedException
- */
+
public function testNewFileNotPermitted() {
+ $this->expectException(\OCP\Files\NotPermittedException::class);
+
$manager = $this->createMock(Manager::class);
/**
* @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view
diff --git a/tests/lib/Files/Node/HookConnectorTest.php b/tests/lib/Files/Node/HookConnectorTest.php
index 9c47df02f3b..4c747a562b8 100644
--- a/tests/lib/Files/Node/HookConnectorTest.php
+++ b/tests/lib/Files/Node/HookConnectorTest.php
@@ -53,7 +53,7 @@ class HookConnectorTest extends TestCase {
*/
private $userId;
- public function setUp(): void {
+ protected function setUp(): void {
parent::setUp();
$this->userId = $this->getUniqueID();
$this->createUser($this->userId, 'pass');
@@ -71,7 +71,7 @@ class HookConnectorTest extends TestCase {
$this->eventDispatcher = \OC::$server->getEventDispatcher();
}
- public function tearDown(): void {
+ protected function tearDown(): void {
parent::tearDown();
\OC_Hook::clear('OC_Filesystem');
\OC_Util::tearDownFS();
diff --git a/tests/lib/Files/Node/NodeTest.php b/tests/lib/Files/Node/NodeTest.php
index 14ae0b0ead3..7c8ddee6b5f 100644
--- a/tests/lib/Files/Node/NodeTest.php
+++ b/tests/lib/Files/Node/NodeTest.php
@@ -180,10 +180,10 @@ abstract class NodeTest extends \Test\TestCase {
$this->assertEquals(2, $hooksRun);
}
- /**
- * @expectedException \OCP\Files\NotPermittedException
- */
+
public function testDeleteNotPermitted() {
+ $this->expectException(\OCP\Files\NotPermittedException::class);
+
$this->root->expects($this->any())
->method('getUser')
->will($this->returnValue($this->user));
@@ -437,10 +437,10 @@ abstract class NodeTest extends \Test\TestCase {
$this->assertEquals(2, $hooksRun);
}
- /**
- * @expectedException \OCP\Files\NotPermittedException
- */
+
public function testTouchNotPermitted() {
+ $this->expectException(\OCP\Files\NotPermittedException::class);
+
$this->root->expects($this->any())
->method('getUser')
->will($this->returnValue($this->user));
@@ -454,10 +454,10 @@ abstract class NodeTest extends \Test\TestCase {
$node->touch(100);
}
- /**
- * @expectedException \OCP\Files\InvalidPathException
- */
+
public function testInvalidPath() {
+ $this->expectException(\OCP\Files\InvalidPathException::class);
+
$node = $this->createTestNode($this->root, $this->view, '/../foo');
$node->getFileInfo();
}
@@ -488,10 +488,10 @@ abstract class NodeTest extends \Test\TestCase {
$this->assertEquals(3, $target->getId());
}
- /**
- * @expectedException \OCP\Files\NotPermittedException
- */
+
public function testCopyNotPermitted() {
+ $this->expectException(\OCP\Files\NotPermittedException::class);
+
/**
* @var \OC\Files\Storage\Storage | \PHPUnit_Framework_MockObject_MockObject $storage
*/
@@ -519,10 +519,10 @@ abstract class NodeTest extends \Test\TestCase {
$node->copy('/bar/asd');
}
- /**
- * @expectedException \OCP\Files\NotFoundException
- */
+
public function testCopyNoParent() {
+ $this->expectException(\OCP\Files\NotFoundException::class);
+
$this->view->expects($this->never())
->method('copy');
@@ -536,10 +536,10 @@ abstract class NodeTest extends \Test\TestCase {
$node->copy('/bar/asd/foo');
}
- /**
- * @expectedException \OCP\Files\NotPermittedException
- */
+
public function testCopyParentIsFile() {
+ $this->expectException(\OCP\Files\NotPermittedException::class);
+
$this->view->expects($this->never())
->method('copy');
@@ -659,10 +659,10 @@ abstract class NodeTest extends \Test\TestCase {
$this->assertEquals(4, $hooksRun);
}
- /**
- * @expectedException \OCP\Files\NotPermittedException
- */
+
public function testMoveNotPermitted() {
+ $this->expectException(\OCP\Files\NotPermittedException::class);
+
$this->view->expects($this->any())
->method('getFileInfo')
->will($this->returnValue($this->getFileInfo(['permissions' => \OCP\Constants::PERMISSION_READ])));
@@ -681,10 +681,10 @@ abstract class NodeTest extends \Test\TestCase {
$node->move('/bar/asd');
}
- /**
- * @expectedException \OCP\Files\NotFoundException
- */
+
public function testMoveNoParent() {
+ $this->expectException(\OCP\Files\NotFoundException::class);
+
/**
* @var \OC\Files\Storage\Storage | \PHPUnit_Framework_MockObject_MockObject $storage
*/
@@ -703,10 +703,10 @@ abstract class NodeTest extends \Test\TestCase {
$node->move('/bar/asd');
}
- /**
- * @expectedException \OCP\Files\NotPermittedException
- */
+
public function testMoveParentIsFile() {
+ $this->expectException(\OCP\Files\NotPermittedException::class);
+
$this->view->expects($this->never())
->method('rename');
@@ -721,10 +721,10 @@ abstract class NodeTest extends \Test\TestCase {
$node->move('/bar/asd');
}
- /**
- * @expectedException \OCP\Files\NotPermittedException
- */
+
public function testMoveFailed() {
+ $this->expectException(\OCP\Files\NotPermittedException::class);
+
$this->view->expects($this->any())
->method('rename')
->with('/bar/foo', '/bar/asd')
@@ -744,10 +744,10 @@ abstract class NodeTest extends \Test\TestCase {
$node->move('/bar/asd');
}
- /**
- * @expectedException \OCP\Files\NotPermittedException
- */
+
public function testCopyFailed() {
+ $this->expectException(\OCP\Files\NotPermittedException::class);
+
$this->view->expects($this->any())
->method('copy')
->with('/bar/foo', '/bar/asd')
diff --git a/tests/lib/Files/Node/RootTest.php b/tests/lib/Files/Node/RootTest.php
index 70ffe1b25c4..5067236ec58 100644
--- a/tests/lib/Files/Node/RootTest.php
+++ b/tests/lib/Files/Node/RootTest.php
@@ -87,10 +87,10 @@ class RootTest extends \Test\TestCase {
$this->assertInstanceOf('\OC\Files\Node\File', $node);
}
- /**
- * @expectedException \OCP\Files\NotFoundException
- */
+
public function testGetNotFound() {
+ $this->expectException(\OCP\Files\NotFoundException::class);
+
/**
* @var \OC\Files\Storage\Storage $storage
*/
@@ -121,10 +121,10 @@ class RootTest extends \Test\TestCase {
$root->get('/bar/foo');
}
- /**
- * @expectedException \OCP\Files\NotPermittedException
- */
+
public function testGetInvalidPath() {
+ $this->expectException(\OCP\Files\NotPermittedException::class);
+
/**
* @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view
*/
@@ -143,10 +143,10 @@ class RootTest extends \Test\TestCase {
$root->get('/../foo');
}
- /**
- * @expectedException \OCP\Files\NotFoundException
- */
+
public function testGetNoStorages() {
+ $this->expectException(\OCP\Files\NotFoundException::class);
+
/**
* @var \OC\Files\View | \PHPUnit_Framework_MockObject_MockObject $view
*/
@@ -201,11 +201,11 @@ class RootTest extends \Test\TestCase {
$this->assertEquals($folder, $root->getUserFolder('MyUserId'));
}
- /**
- * @expectedException \OC\User\NoUserException
- * @expectedExceptionMessage Backends provided no user object
- */
+
public function testGetUserFolderWithNoUserObj() {
+ $this->expectException(\OC\User\NoUserException::class);
+ $this->expectExceptionMessage('Backends provided no user object');
+
$root = new \OC\Files\Node\Root(
$this->createMock(Manager::class),
$this->createMock(View::class),