diff options
author | Roeland Jago Douma <roeland@famdouma.nl> | 2019-11-27 15:27:18 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2019-11-27 15:27:18 +0100 |
commit | 3a7cf40aaa678bea1df143d2982d603b7a334eec (patch) | |
tree | 63c1e3ad7f7f401d14411a4d44c523632906afc9 /tests/lib/Files/ViewTest.php | |
parent | 0568b012672d650c6b5a49e72c4028dde5463c60 (diff) | |
download | nextcloud-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/ViewTest.php')
-rw-r--r-- | tests/lib/Files/ViewTest.php | 32 |
1 files changed, 19 insertions, 13 deletions
diff --git a/tests/lib/Files/ViewTest.php b/tests/lib/Files/ViewTest.php index 1e564c69092..57050059375 100644 --- a/tests/lib/Files/ViewTest.php +++ b/tests/lib/Files/ViewTest.php @@ -242,10 +242,10 @@ class ViewTest extends \Test\TestCase { $this->assertEquals('/foo.txt', $folderView->getPath($id2)); } - /** - * @expectedException \OCP\Files\NotFoundException - */ + public function testGetPathNotExisting() { + $this->expectException(\OCP\Files\NotFoundException::class); + $storage1 = $this->getTestStorage(); Filesystem::mount($storage1, [], '/'); @@ -1049,9 +1049,10 @@ class ViewTest extends \Test\TestCase { /** * @dataProvider tooLongPathDataProvider - * @expectedException \OCP\Files\InvalidPathException */ public function testTooLongPath($operation, $param0 = null) { + $this->expectException(\OCP\Files\InvalidPathException::class); + $longPath = ''; // 4000 is the maximum path length in file_cache.path @@ -1242,10 +1243,11 @@ class ViewTest extends \Test\TestCase { /** * @dataProvider directoryTraversalProvider - * @expectedException \Exception * @param string $root */ public function testConstructDirectoryTraversalException($root) { + $this->expectException(\Exception::class); + new View($root); } @@ -1289,17 +1291,16 @@ class ViewTest extends \Test\TestCase { $this->assertNull($view->getRelativePath(null)); } - /** - * @expectedException \InvalidArgumentException - */ + public function testNullAsRoot() { + $this->expectException(\InvalidArgumentException::class); + new View(null); } /** * e.g. reading from a folder that's being renamed * - * @expectedException \OCP\Lock\LockedException * * @dataProvider dataLockPaths * @@ -1307,6 +1308,8 @@ class ViewTest extends \Test\TestCase { * @param string $pathPrefix */ public function testReadFromWriteLockedPath($rootPath, $pathPrefix) { + $this->expectException(\OCP\Lock\LockedException::class); + $rootPath = str_replace('{folder}', 'files', $rootPath); $pathPrefix = str_replace('{folder}', 'files', $pathPrefix); @@ -1339,7 +1342,6 @@ class ViewTest extends \Test\TestCase { /** * e.g. writing a file that's being downloaded * - * @expectedException \OCP\Lock\LockedException * * @dataProvider dataLockPaths * @@ -1347,6 +1349,8 @@ class ViewTest extends \Test\TestCase { * @param string $pathPrefix */ public function testWriteToReadLockedFile($rootPath, $pathPrefix) { + $this->expectException(\OCP\Lock\LockedException::class); + $rootPath = str_replace('{folder}', 'files', $rootPath); $pathPrefix = str_replace('{folder}', 'files', $pathPrefix); @@ -1507,11 +1511,12 @@ class ViewTest extends \Test\TestCase { /** * @dataProvider pathRelativeToFilesProviderExceptionCases - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage $absolutePath must be relative to "files" * @param string $path */ public function testGetPathRelativeToFilesWithInvalidArgument($path) { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('$absolutePath must be relative to "files"'); + $view = new View(); $view->getPathRelativeToFiles($path); } @@ -2141,9 +2146,10 @@ class ViewTest extends \Test\TestCase { * simulate a failed copy operation. * We expect that we catch the exception, free the lock and re-throw it. * - * @expectedException \Exception */ public function testLockFileCopyException() { + $this->expectException(\Exception::class); + $view = new View('/' . $this->user . '/files/'); /** @var Temporary|\PHPUnit_Framework_MockObject_MockObject $storage */ |