diff options
Diffstat (limited to 'apps/dav/tests/unit/Connector/Sabre')
18 files changed, 125 insertions, 122 deletions
diff --git a/apps/dav/tests/unit/Connector/Sabre/AuthTest.php b/apps/dav/tests/unit/Connector/Sabre/AuthTest.php index 447a10afc79..60ec3186ed6 100644 --- a/apps/dav/tests/unit/Connector/Sabre/AuthTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/AuthTest.php @@ -60,7 +60,7 @@ class AuthTest extends TestCase { /** @var Throttler */ private $throttler; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->session = $this->getMockBuilder(ISession::class) ->disableOriginalConstructor()->getMock(); @@ -220,10 +220,10 @@ class AuthTest extends TestCase { $this->assertFalse($this->invokePrivate($this->auth, 'validateUserPass', ['MyTestUser', 'MyTestPassword'])); } - /** - * @expectedException \OCA\DAV\Connector\Sabre\Exception\PasswordLoginForbidden - */ + public function testValidateUserPassWithPasswordLoginForbidden() { + $this->expectException(\OCA\DAV\Connector\Sabre\Exception\PasswordLoginForbidden::class); + $this->userSession ->expects($this->once()) ->method('isLoggedIn') @@ -329,11 +329,11 @@ class AuthTest extends TestCase { $this->auth->check($request, $response); } - /** - * @expectedException \Sabre\DAV\Exception\NotAuthenticated - * @expectedExceptionMessage 2FA challenge not passed. - */ + public function testAuthenticateAlreadyLoggedInWithoutTwoFactorChallengePassed() { + $this->expectException(\Sabre\DAV\Exception\NotAuthenticated::class); + $this->expectExceptionMessage('2FA challenge not passed.'); + $request = $this->getMockBuilder(RequestInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -383,11 +383,11 @@ class AuthTest extends TestCase { $this->auth->check($request, $response); } - /** - * @expectedException \Sabre\DAV\Exception\NotAuthenticated - * @expectedExceptionMessage CSRF check not passed. - */ + public function testAuthenticateAlreadyLoggedInWithoutCsrfTokenAndIncorrectlyDavAuthenticated() { + $this->expectException(\Sabre\DAV\Exception\NotAuthenticated::class); + $this->expectExceptionMessage('CSRF check not passed.'); + $request = $this->getMockBuilder(RequestInterface::class) ->disableOriginalConstructor() ->getMock(); @@ -564,11 +564,11 @@ class AuthTest extends TestCase { $this->assertEquals([false, 'No \'Authorization: Basic\' header found. Either the client didn\'t send one, or the server is misconfigured'], $response); } - /** - * @expectedException \Sabre\DAV\Exception\NotAuthenticated - * @expectedExceptionMessage Cannot authenticate over ajax calls - */ + public function testAuthenticateNoBasicAuthenticateHeadersProvidedWithAjax() { + $this->expectException(\Sabre\DAV\Exception\NotAuthenticated::class); + $this->expectExceptionMessage('Cannot authenticate over ajax calls'); + /** @var \Sabre\HTTP\RequestInterface $httpRequest */ $httpRequest = $this->getMockBuilder(RequestInterface::class) ->disableOriginalConstructor() diff --git a/apps/dav/tests/unit/Connector/Sabre/BearerAuthTest.php b/apps/dav/tests/unit/Connector/Sabre/BearerAuthTest.php index 2af8fc4c74d..b69c8af45ae 100644 --- a/apps/dav/tests/unit/Connector/Sabre/BearerAuthTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/BearerAuthTest.php @@ -45,7 +45,7 @@ class BearerAuthTest extends TestCase { /** @var BearerAuth */ private $bearerAuth; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->userSession = $this->createMock(\OC\User\Session::class); diff --git a/apps/dav/tests/unit/Connector/Sabre/BlockLegacyClientPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/BlockLegacyClientPluginTest.php index 03c1ef1ff93..a79186f59a5 100644 --- a/apps/dav/tests/unit/Connector/Sabre/BlockLegacyClientPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/BlockLegacyClientPluginTest.php @@ -42,7 +42,7 @@ class BlockLegacyClientPluginTest extends TestCase { /** @var BlockLegacyClientPlugin */ private $blockLegacyClientVersionPlugin; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->config = $this->getMockBuilder(IConfig::class) @@ -67,10 +67,11 @@ class BlockLegacyClientPluginTest extends TestCase { /** * @dataProvider oldDesktopClientProvider * @param string $userAgent - * @expectedException \Sabre\DAV\Exception\Forbidden - * @expectedExceptionMessage Unsupported client version. */ public function testBeforeHandlerException($userAgent) { + $this->expectException(\Sabre\DAV\Exception\Forbidden::class); + $this->expectExceptionMessage('Unsupported client version.'); + /** @var \Sabre\HTTP\RequestInterface | PHPUnit_Framework_MockObject_MockObject $request */ $request = $this->createMock('\Sabre\HTTP\RequestInterface'); $request diff --git a/apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php index b605aba2bc2..2eda470b255 100644 --- a/apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/CommentsPropertiesPluginTest.php @@ -40,7 +40,7 @@ class CommentsPropertiesPluginTest extends \Test\TestCase { protected $userSession; protected $server; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->commentsManager = $this->getMockBuilder(ICommentsManager::class) diff --git a/apps/dav/tests/unit/Connector/Sabre/CopyEtagHeaderPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/CopyEtagHeaderPluginTest.php index 5685580c03a..69ebc8d2a34 100644 --- a/apps/dav/tests/unit/Connector/Sabre/CopyEtagHeaderPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/CopyEtagHeaderPluginTest.php @@ -45,7 +45,7 @@ class CopyEtagHeaderPluginTest extends TestCase { /** @var Server */ private $server; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->server = new \Sabre\DAV\Server(); $this->plugin = new CopyEtagHeaderPlugin(); diff --git a/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php b/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php index 69f67f607b2..de44606fc19 100644 --- a/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/CustomPropertiesBackendTest.php @@ -67,7 +67,7 @@ class CustomPropertiesBackendTest extends \Test\TestCase { */ private $user; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->server = new \Sabre\DAV\Server(); $this->tree = $this->getMockBuilder(Tree::class) @@ -90,7 +90,7 @@ class CustomPropertiesBackendTest extends \Test\TestCase { ); } - public function tearDown(): void { + protected function tearDown(): void { $connection = \OC::$server->getDatabaseConnection(); $deleteStatement = $connection->prepare( 'DELETE FROM `*PREFIX*properties`' . diff --git a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php index ee64eb5bce6..a93ef7ee962 100644 --- a/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/DirectoryTest.php @@ -97,10 +97,10 @@ class DirectoryTest extends \Test\TestCase { return new Directory($this->view, $this->info); } - /** - * @expectedException \Sabre\DAV\Exception\Forbidden - */ + public function testDeleteRootFolderFails() { + $this->expectException(\Sabre\DAV\Exception\Forbidden::class); + $this->info->expects($this->any()) ->method('isDeletable') ->will($this->returnValue(true)); @@ -110,10 +110,10 @@ class DirectoryTest extends \Test\TestCase { $dir->delete(); } - /** - * @expectedException \OCA\DAV\Connector\Sabre\Exception\Forbidden - */ + public function testDeleteForbidden() { + $this->expectException(\OCA\DAV\Connector\Sabre\Exception\Forbidden::class); + // deletion allowed $this->info->expects($this->once()) ->method('isDeletable') @@ -129,9 +129,7 @@ class DirectoryTest extends \Test\TestCase { $dir->delete(); } - /** - * - */ + public function testDeleteFolderWhenAllowed() { // deletion allowed $this->info->expects($this->once()) @@ -148,10 +146,10 @@ class DirectoryTest extends \Test\TestCase { $dir->delete(); } - /** - * @expectedException \Sabre\DAV\Exception\Forbidden - */ + public function testDeleteFolderFailsWhenNotAllowed() { + $this->expectException(\Sabre\DAV\Exception\Forbidden::class); + $this->info->expects($this->once()) ->method('isDeletable') ->will($this->returnValue(false)); @@ -160,10 +158,10 @@ class DirectoryTest extends \Test\TestCase { $dir->delete(); } - /** - * @expectedException \Sabre\DAV\Exception\Forbidden - */ + public function testDeleteFolderThrowsWhenDeletionFailed() { + $this->expectException(\Sabre\DAV\Exception\Forbidden::class); + // deletion allowed $this->info->expects($this->once()) ->method('isDeletable') @@ -218,10 +216,10 @@ class DirectoryTest extends \Test\TestCase { $dir->getChildren(); } - /** - * @expectedException \Sabre\DAV\Exception\Forbidden - */ + public function testGetChildrenNoPermission() { + $this->expectException(\Sabre\DAV\Exception\Forbidden::class); + $info = $this->createMock(FileInfo::class); $info->expects($this->any()) ->method('isReadable') @@ -231,10 +229,10 @@ class DirectoryTest extends \Test\TestCase { $dir->getChildren(); } - /** - * @expectedException \Sabre\DAV\Exception\NotFound - */ + public function testGetChildNoPermission() { + $this->expectException(\Sabre\DAV\Exception\NotFound::class); + $this->info->expects($this->any()) ->method('isReadable') ->will($this->returnValue(false)); @@ -243,10 +241,10 @@ class DirectoryTest extends \Test\TestCase { $dir->getChild('test'); } - /** - * @expectedException \Sabre\DAV\Exception\ServiceUnavailable - */ + public function testGetChildThrowStorageNotAvailableException() { + $this->expectException(\Sabre\DAV\Exception\ServiceUnavailable::class); + $this->view->expects($this->once()) ->method('getFileInfo') ->willThrowException(new \OCP\Files\StorageNotAvailableException()); @@ -255,10 +253,10 @@ class DirectoryTest extends \Test\TestCase { $dir->getChild('.'); } - /** - * @expectedException \OCA\DAV\Connector\Sabre\Exception\InvalidPath - */ + public function testGetChildThrowInvalidPath() { + $this->expectException(\OCA\DAV\Connector\Sabre\Exception\InvalidPath::class); + $this->view->expects($this->once()) ->method('verifyPath') ->willThrowException(new \OCP\Files\InvalidPathException()); @@ -334,9 +332,10 @@ class DirectoryTest extends \Test\TestCase { /** * @dataProvider moveFailedProvider - * @expectedException \Sabre\DAV\Exception\Forbidden */ public function testMoveFailed($source, $destination, $updatables, $deletables) { + $this->expectException(\Sabre\DAV\Exception\Forbidden::class); + $this->moveTest($source, $destination, $updatables, $deletables); } @@ -350,9 +349,10 @@ class DirectoryTest extends \Test\TestCase { /** * @dataProvider moveFailedInvalidCharsProvider - * @expectedException \OCA\DAV\Connector\Sabre\Exception\InvalidPath */ public function testMoveFailedInvalidChars($source, $destination, $updatables, $deletables) { + $this->expectException(\OCA\DAV\Connector\Sabre\Exception\InvalidPath::class); + $this->moveTest($source, $destination, $updatables, $deletables); } @@ -403,11 +403,11 @@ class DirectoryTest extends \Test\TestCase { $this->assertTrue($targetNode->moveInto(basename($destination), $source, $sourceNode)); } - /** - * @expectedException \Sabre\DAV\Exception\Forbidden - * @expectedExceptionMessage Could not copy directory b, target exists - */ + public function testFailingMove() { + $this->expectException(\Sabre\DAV\Exception\Forbidden::class); + $this->expectExceptionMessage('Could not copy directory b, target exists'); + $source = 'a/b'; $destination = 'c/b'; $updatables = ['a' => true, 'a/b' => true, 'b' => true, 'c/b' => false]; diff --git a/apps/dav/tests/unit/Connector/Sabre/DummyGetResponsePluginTest.php b/apps/dav/tests/unit/Connector/Sabre/DummyGetResponsePluginTest.php index 1d22579bdd1..e6555be814d 100644 --- a/apps/dav/tests/unit/Connector/Sabre/DummyGetResponsePluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/DummyGetResponsePluginTest.php @@ -41,7 +41,7 @@ class DummyGetResponsePluginTest extends TestCase { /** @var DummyGetResponsePlugin */ private $dummyGetResponsePlugin; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->dummyGetResponsePlugin = new DummyGetResponsePlugin(); diff --git a/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php index c2c808a8d95..49b252eb1a1 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FakeLockerPluginTest.php @@ -44,7 +44,7 @@ class FakeLockerPluginTest extends TestCase { /** @var FakeLockerPlugin */ private $fakeLockerPlugin; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->fakeLockerPlugin = new FakeLockerPlugin(); } diff --git a/apps/dav/tests/unit/Connector/Sabre/FileTest.php b/apps/dav/tests/unit/Connector/Sabre/FileTest.php index d0c18f6cd9e..a3cf4560387 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FileTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FileTest.php @@ -62,7 +62,7 @@ class FileTest extends TestCase { /** @var IConfig | \PHPUnit_Framework_MockObject_MockObject */ protected $config; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); unset($_SERVER['HTTP_OC_CHUNKED']); unset($_SERVER['CONTENT_LENGTH']); @@ -78,7 +78,7 @@ class FileTest extends TestCase { $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock(); } - public function tearDown(): void { + protected function tearDown(): void { $userManager = \OC::$server->getUserManager(); $userManager->get($this->user)->delete(); unset($_SERVER['HTTP_OC_CHUNKED']); @@ -815,9 +815,10 @@ class FileTest extends TestCase { /** * Test setting name with setName() with invalid chars * - * @expectedException \OCA\DAV\Connector\Sabre\Exception\InvalidPath */ public function testSetNameInvalidChars() { + $this->expectException(\OCA\DAV\Connector\Sabre\Exception\InvalidPath::class); + // setup $view = $this->getMockBuilder(View::class) ->setMethods(['getRelativePath']) @@ -834,8 +835,7 @@ class FileTest extends TestCase { $file->setName('/super*star.txt'); } - /** - */ + public function testUploadAbort() { // setup $view = $this->getMockBuilder(View::class) @@ -879,9 +879,7 @@ class FileTest extends TestCase { $this->assertEmpty($this->listPartFiles($view, ''), 'No stray part files'); } - /** - * - */ + public function testDeleteWhenAllowed() { // setup $view = $this->getMockBuilder(View::class) @@ -901,10 +899,10 @@ class FileTest extends TestCase { $file->delete(); } - /** - * @expectedException \Sabre\DAV\Exception\Forbidden - */ + public function testDeleteThrowsWhenDeletionNotAllowed() { + $this->expectException(\Sabre\DAV\Exception\Forbidden::class); + // setup $view = $this->getMockBuilder(View::class) ->getMock(); @@ -919,10 +917,10 @@ class FileTest extends TestCase { $file->delete(); } - /** - * @expectedException \Sabre\DAV\Exception\Forbidden - */ + public function testDeleteThrowsWhenDeletionFailed() { + $this->expectException(\Sabre\DAV\Exception\Forbidden::class); + // setup $view = $this->getMockBuilder(View::class) ->getMock(); @@ -942,10 +940,10 @@ class FileTest extends TestCase { $file->delete(); } - /** - * @expectedException \OCA\DAV\Connector\Sabre\Exception\Forbidden - */ + public function testDeleteThrowsWhenDeletionThrows() { + $this->expectException(\OCA\DAV\Connector\Sabre\Exception\Forbidden::class); + // setup $view = $this->getMockBuilder(View::class) ->getMock(); @@ -1112,10 +1110,10 @@ class FileTest extends TestCase { ]; } - /** - * @expectedException \Sabre\DAV\Exception\ServiceUnavailable - */ + public function testGetFopenFails() { + $this->expectException(\Sabre\DAV\Exception\ServiceUnavailable::class); + $view = $this->getMockBuilder(View::class) ->setMethods(['fopen']) ->getMock(); @@ -1132,10 +1130,10 @@ class FileTest extends TestCase { $file->get(); } - /** - * @expectedException \OCA\DAV\Connector\Sabre\Exception\Forbidden - */ + public function testGetFopenThrows() { + $this->expectException(\OCA\DAV\Connector\Sabre\Exception\Forbidden::class); + $view = $this->getMockBuilder(View::class) ->setMethods(['fopen']) ->getMock(); @@ -1152,10 +1150,10 @@ class FileTest extends TestCase { $file->get(); } - /** - * @expectedException \Sabre\DAV\Exception\NotFound - */ + public function testGetThrowsIfNoPermission() { + $this->expectException(\Sabre\DAV\Exception\NotFound::class); + $view = $this->getMockBuilder(View::class) ->setMethods(['fopen']) ->getMock(); diff --git a/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php index 564059cd1dc..45c11d0011a 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FilesPluginTest.php @@ -97,7 +97,7 @@ class FilesPluginTest extends TestCase { */ private $previewManager; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->server = $this->getMockBuilder(Server::class) ->disableOriginalConstructor() @@ -462,10 +462,11 @@ class FilesPluginTest extends TestCase { * FolderA is an incoming shared folder and there are no delete permissions. * Thus moving /FolderA/test.txt to /test.txt should fail already on that check * - * @expectedException \Sabre\DAV\Exception\Forbidden - * @expectedExceptionMessage FolderA/test.txt cannot be deleted */ public function testMoveSrcNotDeletable() { + $this->expectException(\Sabre\DAV\Exception\Forbidden::class); + $this->expectExceptionMessage('FolderA/test.txt cannot be deleted'); + $fileInfoFolderATestTXT = $this->getMockBuilder(FileInfo::class) ->disableOriginalConstructor() ->getMock(); @@ -507,11 +508,11 @@ class FilesPluginTest extends TestCase { $this->plugin->checkMove('FolderA/test.txt', 'test.txt'); } - /** - * @expectedException \Sabre\DAV\Exception\NotFound - * @expectedExceptionMessage FolderA/test.txt does not exist - */ + public function testMoveSrcNotExist() { + $this->expectException(\Sabre\DAV\Exception\NotFound::class); + $this->expectExceptionMessage('FolderA/test.txt does not exist'); + $node = $this->getMockBuilder(Node::class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php index ea58c50480c..14c6af122a2 100644 --- a/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/FilesReportPluginTest.php @@ -85,7 +85,7 @@ class FilesReportPluginTest extends \Test\TestCase { /** @var IAppManager|\PHPUnit_Framework_MockObject_MockObject * */ private $appManager; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->tree = $this->getMockBuilder(Tree::class) ->disableOriginalConstructor() @@ -603,10 +603,10 @@ class FilesReportPluginTest extends \Test\TestCase { $this->assertEquals(['222'], array_values($this->invokePrivate($this->plugin, 'processFilterRules', [$rules]))); } - /** - * @expectedException \OCP\SystemTag\TagNotFoundException - */ + public function testProcessFilterRulesInvisibleTagAsUser() { + $this->expectException(\OCP\SystemTag\TagNotFoundException::class); + $this->groupManager->expects($this->any()) ->method('isAdmin') ->will($this->returnValue(false)); diff --git a/apps/dav/tests/unit/Connector/Sabre/MaintenancePluginTest.php b/apps/dav/tests/unit/Connector/Sabre/MaintenancePluginTest.php index a604757520d..a9c8929dee6 100644 --- a/apps/dav/tests/unit/Connector/Sabre/MaintenancePluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/MaintenancePluginTest.php @@ -39,18 +39,18 @@ class MaintenancePluginTest extends TestCase { /** @var MaintenancePlugin */ private $maintenancePlugin; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->config = $this->getMockBuilder(IConfig::class)->getMock(); $this->maintenancePlugin = new MaintenancePlugin($this->config); } - /** - * @expectedException \Sabre\DAV\Exception\ServiceUnavailable - * @expectedExceptionMessage System in maintenance mode. - */ + public function testMaintenanceMode() { + $this->expectException(\Sabre\DAV\Exception\ServiceUnavailable::class); + $this->expectExceptionMessage('System in maintenance mode.'); + $this->config ->expects($this->exactly(1)) ->method('getSystemValueBool') diff --git a/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php b/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php index cd575e4ff3c..1c71d396de2 100644 --- a/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/ObjectTreeTest.php @@ -103,9 +103,10 @@ class ObjectTreeTest extends \Test\TestCase { /** * @dataProvider copyDataProvider - * @expectedException \Sabre\DAV\Exception\Forbidden */ public function testCopyFailNotCreatable($sourcePath, $targetPath, $targetParent) { + $this->expectException(\Sabre\DAV\Exception\Forbidden::class); + $view = $this->createMock(View::class); $view->expects($this->never()) ->method('verifyPath'); @@ -268,10 +269,10 @@ class ObjectTreeTest extends \Test\TestCase { ); } - /** - * @expectedException \OCA\DAV\Connector\Sabre\Exception\InvalidPath - */ + public function testGetNodeForPathInvalidPath() { + $this->expectException(\OCA\DAV\Connector\Sabre\Exception\InvalidPath::class); + $path = '/foo\bar'; diff --git a/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php b/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php index 5320bd28302..7836191450b 100644 --- a/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/PrincipalTest.php @@ -65,7 +65,7 @@ class PrincipalTest extends TestCase { /** @var ProxyMapper | \PHPUnit_Framework_MockObject_MockObject */ private $proxyMapper; - public function setUp(): void { + protected function setUp(): void { $this->userManager = $this->createMock(IUserManager::class); $this->groupManager = $this->createMock(IGroupManager::class); $this->shareManager = $this->createMock(IManager::class); @@ -209,11 +209,11 @@ class PrincipalTest extends TestCase { $this->assertSame([], $response); } - /** - * @expectedException \Sabre\DAV\Exception - * @expectedExceptionMessage Principal not found - */ + public function testGetGroupMemberSetEmpty() { + $this->expectException(\Sabre\DAV\Exception::class); + $this->expectExceptionMessage('Principal not found'); + $this->userManager ->expects($this->once()) ->method('get') @@ -334,11 +334,11 @@ class PrincipalTest extends TestCase { $this->assertSame($expectedResponse, $response); } - /** - * @expectedException \Sabre\DAV\Exception - * @expectedExceptionMessage Principal not found - */ + public function testGetGroupMembershipEmpty() { + $this->expectException(\Sabre\DAV\Exception::class); + $this->expectExceptionMessage('Principal not found'); + $this->userManager ->expects($this->once()) ->method('get') @@ -348,11 +348,11 @@ class PrincipalTest extends TestCase { $this->connector->getGroupMembership('principals/users/foo'); } - /** - * @expectedException \Sabre\DAV\Exception - * @expectedExceptionMessage Setting members of the group is not supported yet - */ + public function testSetGroupMembership() { + $this->expectException(\Sabre\DAV\Exception::class); + $this->expectExceptionMessage('Setting members of the group is not supported yet'); + $this->connector->setGroupMemberSet('principals/users/foo', ['foo']); } diff --git a/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php index e5d229733c5..d09ed9cf681 100644 --- a/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php @@ -85,10 +85,11 @@ class QuotaPluginTest extends TestCase { } /** - * @expectedException \Sabre\DAV\Exception\InsufficientStorage * @dataProvider quotaExceededProvider */ public function testCheckExceededQuota($quota, $headers) { + $this->expectException(\Sabre\DAV\Exception\InsufficientStorage::class); + $this->init($quota); $this->plugin->expects($this->never()) ->method('getFileChunking'); @@ -209,9 +210,10 @@ class QuotaPluginTest extends TestCase { /** * @dataProvider quotaChunkedFailProvider - * @expectedException \Sabre\DAV\Exception\InsufficientStorage */ public function testCheckQuotaChunkedFail($quota, $chunkTotalSize, $headers) { + $this->expectException(\Sabre\DAV\Exception\InsufficientStorage::class); + $this->init($quota, 'sub/test.txt'); $mockChunking = $this->getMockBuilder(\OC_FileChunking::class) diff --git a/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php index 85d285f2c3b..96c2d3ba092 100644 --- a/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/SharesPluginTest.php @@ -66,7 +66,7 @@ class SharesPluginTest extends \Test\TestCase { */ private $plugin; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->server = new \Sabre\DAV\Server(); $this->tree = $this->createMock(Tree::class); diff --git a/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php b/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php index 384441f4495..a805a776ad8 100644 --- a/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php +++ b/apps/dav/tests/unit/Connector/Sabre/TagsPluginTest.php @@ -70,7 +70,7 @@ class TagsPluginTest extends \Test\TestCase { */ private $plugin; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->server = new \Sabre\DAV\Server(); $this->tree = $this->getMockBuilder(Tree::class) |