diff options
Diffstat (limited to 'apps/files_sharing/tests/Controller/ShareAPIControllerTest.php')
-rw-r--r-- | apps/files_sharing/tests/Controller/ShareAPIControllerTest.php | 260 |
1 files changed, 131 insertions, 129 deletions
diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php index 6452ad50019..ae7fc54599c 100644 --- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php @@ -100,7 +100,7 @@ class ShareAPIControllerTest extends TestCase { /** @var IServerContainer|\PHPUnit_Framework_MockObject_MockObject */ private $serverContainer; - protected function setUp() { + protected function setUp(): void { $this->shareManager = $this->createMock(IManager::class); $this->shareManager ->expects($this->any()) @@ -164,11 +164,11 @@ class ShareAPIControllerTest extends TestCase { return \OC::$server->getShareManager()->newShare(); } - /** - * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException - * @expectedExceptionMessage Wrong share ID, share doesn't exist - */ + public function testDeleteShareShareNotFound() { + $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class); + $this->expectExceptionMessage('Wrong share ID, share doesn\'t exist'); + $this->shareManager ->expects($this->exactly(3)) ->method('getShareById') @@ -212,16 +212,16 @@ class ShareAPIControllerTest extends TestCase { $this->assertEquals($expected->getData(), $result->getData()); } - /** - * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException - * @expectedExceptionMessage Could not delete share - */ + public function testDeleteShareLocked() { + $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class); + $this->expectExceptionMessage('Could not delete share'); + $node = $this->getMockBuilder(File::class)->getMock(); $share = $this->newShare(); $share->setNode($node); - + $this->shareManager ->expects($this->once()) ->method('getShareById') @@ -237,7 +237,7 @@ class ShareAPIControllerTest extends TestCase { ->method('lock') ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED) ->will($this->throwException(new LockedException('mypath'))); - + $this->assertFalse($this->invokePrivate($this->ocs, 'canDeleteFromSelf', [$share])); $this->assertFalse($this->invokePrivate($this->ocs, 'canDeleteShare', [$share])); @@ -245,7 +245,7 @@ class ShareAPIControllerTest extends TestCase { } /** - * You can always remove a share that was shared with you + * You can always remove a share that was shared with you */ public function testDeleteShareWithMe() { $node = $this->getMockBuilder(File::class)->getMock(); @@ -254,7 +254,7 @@ class ShareAPIControllerTest extends TestCase { $share->setSharedWith($this->currentUser) ->setShareType(\OCP\Share::SHARE_TYPE_USER) ->setNode($node); - + $this->shareManager ->expects($this->once()) ->method('getShareById') @@ -269,7 +269,7 @@ class ShareAPIControllerTest extends TestCase { $node->expects($this->once()) ->method('lock') ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED); - + $this->assertFalse($this->invokePrivate($this->ocs, 'canDeleteFromSelf', [$share])); $this->assertTrue($this->invokePrivate($this->ocs, 'canDeleteShare', [$share])); @@ -300,7 +300,7 @@ class ShareAPIControllerTest extends TestCase { $node->expects($this->once()) ->method('lock') ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED); - + $this->assertFalse($this->invokePrivate($this->ocs, 'canDeleteFromSelf', [$share])); $this->assertTrue($this->invokePrivate($this->ocs, 'canDeleteShare', [$share])); @@ -332,7 +332,7 @@ class ShareAPIControllerTest extends TestCase { $node->expects($this->once()) ->method('lock') ->with(\OCP\Lock\ILockingProvider::LOCK_SHARED); - + $this->assertFalse($this->invokePrivate($this->ocs, 'canDeleteFromSelf', [$share])); $this->assertTrue($this->invokePrivate($this->ocs, 'canDeleteShare', [$share])); @@ -388,10 +388,10 @@ class ShareAPIControllerTest extends TestCase { $this->shareManager->expects($this->once()) ->method('deleteFromSelf') ->with($share, $this->currentUser); - + $this->shareManager->expects($this->never()) ->method('deleteShare'); - + $this->assertTrue($this->invokePrivate($this->ocs, 'canDeleteShareFromSelf', [$share])); $this->assertFalse($this->invokePrivate($this->ocs, 'canDeleteShare', [$share])); @@ -401,10 +401,11 @@ class ShareAPIControllerTest extends TestCase { /** * You cannot remove a share if you're not * in the group the share is shared with - * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException - * @expectedExceptionMessage Wrong share ID, share doesn't exist */ public function testDeleteSharedWithGroupIDontBelongTo() { + $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class); + $this->expectExceptionMessage('Wrong share ID, share doesn\'t exist'); + $node = $this->getMockBuilder(File::class)->getMock(); $share = $this->newShare(); @@ -448,10 +449,10 @@ class ShareAPIControllerTest extends TestCase { $this->shareManager->expects($this->never()) ->method('deleteFromSelf'); - + $this->shareManager->expects($this->never()) ->method('deleteShare'); - + $this->assertFalse($this->invokePrivate($this->ocs, 'canDeleteShareFromSelf', [$share])); $this->assertFalse($this->invokePrivate($this->ocs, 'canDeleteShare', [$share])); @@ -767,11 +768,11 @@ class ShareAPIControllerTest extends TestCase { $this->assertEquals($result, $ocs->getShare($share->getId())->getData()[0]); } - /** - * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException - * @expectedExceptionMessage Wrong share ID, share doesn't exist - */ + public function testGetShareInvalidNode() { + $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class); + $this->expectExceptionMessage('Wrong share ID, share doesn\'t exist'); + $share = \OC::$server->getShareManager()->newShare(); $share->setSharedBy('initiator') ->setSharedWith('recipient') @@ -1533,19 +1534,19 @@ class ShareAPIControllerTest extends TestCase { $this->assertEquals($expected, $this->invokePrivate($this->ocs, 'canAccessShare', [$share])); } - /** - * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException - * @expectedExceptionMessage Please specify a file or folder path - */ + public function testCreateShareNoPath() { + $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class); + $this->expectExceptionMessage('Please specify a file or folder path'); + $this->ocs->createShare(); } - /** - * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException - * @expectedExceptionMessage Wrong path, file/folder doesn't exist - */ + public function testCreateShareInvalidPath() { + $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class); + $this->expectExceptionMessage('Wrong path, file/folder doesn\'t exist'); + $userFolder = $this->getMockBuilder(Folder::class)->getMock(); $this->rootFolder->expects($this->once()) ->method('getUserFolder') @@ -1560,11 +1561,11 @@ class ShareAPIControllerTest extends TestCase { $this->ocs->createShare('invalid-path'); } - /** - * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException - * @expectedExceptionMessage invalid permissions - */ + public function testCreateShareInvalidPermissions() { + $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class); + $this->expectExceptionMessage('invalid permissions'); + $share = $this->newShare(); $this->shareManager->method('newShare')->willReturn($share); @@ -1587,11 +1588,11 @@ class ShareAPIControllerTest extends TestCase { $this->ocs->createShare('valid-path', 32); } - /** - * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException - * @expectedExceptionMessage Please specify a valid user - */ + public function testCreateShareUserNoShareWith() { + $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class); + $this->expectExceptionMessage('Please specify a valid user'); + $share = $this->newShare(); $this->shareManager->method('newShare')->willReturn($share); @@ -1602,7 +1603,7 @@ class ShareAPIControllerTest extends TestCase { ->willReturn($userFolder); $path = $this->getMockBuilder(File::class)->getMock(); - $storage = $this->getMockBuilder(Storage::class)->getMock(); + $storage = $this->createMock(Storage::class); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -1619,11 +1620,11 @@ class ShareAPIControllerTest extends TestCase { $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER); } - /** - * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException - * @expectedExceptionMessage Please specify a valid user - */ + public function testCreateShareUserNoValidShareWith() { + $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class); + $this->expectExceptionMessage('Please specify a valid user'); + $share = $this->newShare(); $this->shareManager->method('newShare')->willReturn($share); @@ -1634,7 +1635,7 @@ class ShareAPIControllerTest extends TestCase { ->willReturn($userFolder); $path = $this->getMockBuilder(File::class)->getMock(); - $storage = $this->getMockBuilder(Storage::class)->getMock(); + $storage = $this->createMock(Storage::class); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -1682,7 +1683,7 @@ class ShareAPIControllerTest extends TestCase { ->willReturn($userFolder); $path = $this->getMockBuilder(File::class)->getMock(); - $storage = $this->getMockBuilder(Storage::class)->getMock(); + $storage = $this->createMock(Storage::class); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -1719,11 +1720,11 @@ class ShareAPIControllerTest extends TestCase { $this->assertEquals($expected->getData(), $result->getData()); } - /** - * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException - * @expectedExceptionMessage Please specify a valid group - */ + public function testCreateShareGroupNoValidShareWith() { + $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class); + $this->expectExceptionMessage('Please specify a valid group'); + $share = $this->newShare(); $this->shareManager->method('newShare')->willReturn($share); $this->shareManager->method('createShare')->will($this->returnArgument(0)); @@ -1736,7 +1737,7 @@ class ShareAPIControllerTest extends TestCase { ->willReturn($userFolder); $path = $this->getMockBuilder(File::class)->getMock(); - $storage = $this->getMockBuilder(Storage::class)->getMock(); + $storage = $this->createMock(Storage::class); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -1791,7 +1792,7 @@ class ShareAPIControllerTest extends TestCase { ->willReturn($userFolder); $path = $this->getMockBuilder(Folder::class)->getMock(); - $storage = $this->getMockBuilder(Storage::class)->getMock(); + $storage = $this->createMock(Storage::class); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -1828,11 +1829,11 @@ class ShareAPIControllerTest extends TestCase { $this->assertEquals($expected->getData(), $result->getData()); } - /** - * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException - * @expectedExceptionMessage Group sharing is disabled by the administrator - */ + public function testCreateShareGroupNotAllowed() { + $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class); + $this->expectExceptionMessage('Group sharing is disabled by the administrator'); + $share = $this->newShare(); $this->shareManager->method('newShare')->willReturn($share); @@ -1843,7 +1844,7 @@ class ShareAPIControllerTest extends TestCase { ->willReturn($userFolder); $path = $this->getMockBuilder(Folder::class)->getMock(); - $storage = $this->getMockBuilder(Storage::class)->getMock(); + $storage = $this->createMock(Storage::class); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -1862,11 +1863,11 @@ class ShareAPIControllerTest extends TestCase { $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_GROUP, 'invalidGroup'); } - /** - * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException - * @expectedExceptionMessage Public link sharing is disabled by the administrator - */ + public function testCreateShareLinkNoLinksAllowed() { + $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class); + $this->expectExceptionMessage('Public link sharing is disabled by the administrator'); + $this->request ->method('getParam') ->will($this->returnValueMap([ @@ -1875,7 +1876,7 @@ class ShareAPIControllerTest extends TestCase { ])); $path = $this->getMockBuilder(Folder::class)->getMock(); - $storage = $this->getMockBuilder(Storage::class)->getMock(); + $storage = $this->createMock(Storage::class); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -1888,13 +1889,13 @@ class ShareAPIControllerTest extends TestCase { $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK); } - /** - * @expectedException \OCP\AppFramework\OCS\OCSForbiddenException - * @expectedExceptionMessage Public upload disabled by the administrator - */ + public function testCreateShareLinkNoPublicUpload() { + $this->expectException(\OCP\AppFramework\OCS\OCSForbiddenException::class); + $this->expectExceptionMessage('Public upload disabled by the administrator'); + $path = $this->getMockBuilder(Folder::class)->getMock(); - $storage = $this->getMockBuilder(Storage::class)->getMock(); + $storage = $this->createMock(Storage::class); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -1908,13 +1909,13 @@ class ShareAPIControllerTest extends TestCase { $this->ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_LINK, null, 'true'); } - /** - * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException - * @expectedExceptionMessage Public upload is only possible for publicly shared folders - */ + public function testCreateShareLinkPublicUploadFile() { + $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class); + $this->expectExceptionMessage('Public upload is only possible for publicly shared folders'); + $path = $this->getMockBuilder(File::class)->getMock(); - $storage = $this->getMockBuilder(Storage::class)->getMock(); + $storage = $this->createMock(Storage::class); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -1933,7 +1934,7 @@ class ShareAPIControllerTest extends TestCase { $ocs = $this->mockFormatShare(); $path = $this->getMockBuilder(Folder::class)->getMock(); - $storage = $this->getMockBuilder(Storage::class)->getMock(); + $storage = $this->createMock(Storage::class); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -1967,7 +1968,7 @@ class ShareAPIControllerTest extends TestCase { $ocs = $this->mockFormatShare(); $path = $this->getMockBuilder(Folder::class)->getMock(); - $storage = $this->getMockBuilder(Storage::class)->getMock(); + $storage = $this->createMock(Storage::class); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -2001,7 +2002,7 @@ class ShareAPIControllerTest extends TestCase { $ocs = $this->mockFormatShare(); $path = $this->getMockBuilder(Folder::class)->getMock(); - $storage = $this->getMockBuilder(Storage::class)->getMock(); + $storage = $this->createMock(Storage::class); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -2034,15 +2035,15 @@ class ShareAPIControllerTest extends TestCase { $this->assertEquals($expected->getData(), $result->getData()); } - /** - * @expectedException \OCP\AppFramework\OCS\OCSForbiddenException - * @expectedExceptionMessage Sharing valid-path sending the password by Nextcloud Talk failed because Nextcloud Talk is not enabled - */ + public function testCreateShareLinkSendPasswordByTalkWithTalkDisabled() { + $this->expectException(\OCP\AppFramework\OCS\OCSForbiddenException::class); + $this->expectExceptionMessage('Sharing valid-path sending the password by Nextcloud Talk failed because Nextcloud Talk is not enabled'); + $ocs = $this->mockFormatShare(); $path = $this->getMockBuilder(Folder::class)->getMock(); - $storage = $this->getMockBuilder(Storage::class)->getMock(); + $storage = $this->createMock(Storage::class); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -2076,7 +2077,7 @@ class ShareAPIControllerTest extends TestCase { ])); $path = $this->getMockBuilder(Folder::class)->getMock(); - $storage = $this->getMockBuilder(Storage::class)->getMock(); + $storage = $this->createMock(Storage::class); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -2109,15 +2110,15 @@ class ShareAPIControllerTest extends TestCase { $this->assertEquals($expected->getData(), $result->getData()); } - /** - * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException - * @expectedExceptionMessage Invalid date, date format must be YYYY-MM-DD - */ + public function testCreateShareInvalidExpireDate() { + $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class); + $this->expectExceptionMessage('Invalid date, date format must be YYYY-MM-DD'); + $ocs = $this->mockFormatShare(); $path = $this->getMockBuilder(Folder::class)->getMock(); - $storage = $this->getMockBuilder(Storage::class)->getMock(); + $storage = $this->createMock(Storage::class); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -2145,7 +2146,7 @@ class ShareAPIControllerTest extends TestCase { ->willReturn($userFolder); $path = $this->getMockBuilder(File::class)->getMock(); - $storage = $this->getMockBuilder(Storage::class)->getMock(); + $storage = $this->createMock(Storage::class); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -2210,11 +2211,11 @@ class ShareAPIControllerTest extends TestCase { $this->assertEquals($expected->getData(), $result->getData()); } - /** - * @expectedException \OCP\AppFramework\OCS\OCSForbiddenException - * @expectedExceptionMessage Sharing valid-path failed because the back end does not support room shares - */ + public function testCreateShareRoomHelperNotAvailable() { + $this->expectException(\OCP\AppFramework\OCS\OCSForbiddenException::class); + $this->expectExceptionMessage('Sharing valid-path failed because the back end does not support room shares'); + $ocs = $this->mockFormatShare(); $share = $this->newShare(); @@ -2227,7 +2228,7 @@ class ShareAPIControllerTest extends TestCase { ->willReturn($userFolder); $path = $this->getMockBuilder(File::class)->getMock(); - $storage = $this->getMockBuilder(Storage::class)->getMock(); + $storage = $this->createMock(Storage::class); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -2251,11 +2252,11 @@ class ShareAPIControllerTest extends TestCase { $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_ROOM, 'recipientRoom'); } - /** - * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException - * @expectedExceptionMessage Exception thrown by the helper - */ + public function testCreateShareRoomHelperThrowException() { + $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class); + $this->expectExceptionMessage('Exception thrown by the helper'); + $ocs = $this->mockFormatShare(); $share = $this->newShare(); @@ -2268,7 +2269,7 @@ class ShareAPIControllerTest extends TestCase { ->willReturn($userFolder); $path = $this->getMockBuilder(File::class)->getMock(); - $storage = $this->getMockBuilder(Storage::class)->getMock(); + $storage = $this->createMock(Storage::class); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -2345,7 +2346,7 @@ class ShareAPIControllerTest extends TestCase { ->willReturn($userFolder); $path = $this->getMockBuilder(Folder::class)->getMock(); - $storage = $this->getMockBuilder(Storage::class)->getMock(); + $storage = $this->createMock(Storage::class); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(true); @@ -2369,11 +2370,11 @@ class ShareAPIControllerTest extends TestCase { $ocs->createShare('valid-path', \OCP\Constants::PERMISSION_ALL, \OCP\Share::SHARE_TYPE_USER, 'validUser'); } - /** - * @expectedException \OCP\AppFramework\OCS\OCSNotFoundException - * @expectedExceptionMessage Wrong share ID, share doesn't exist - */ + public function testUpdateShareCantAccess() { + $this->expectException(\OCP\AppFramework\OCS\OCSNotFoundException::class); + $this->expectExceptionMessage('Wrong share ID, share doesn\'t exist'); + $node = $this->getMockBuilder(Folder::class)->getMock(); $share = $this->newShare(); $share->setNode($node); @@ -2396,11 +2397,11 @@ class ShareAPIControllerTest extends TestCase { $this->ocs->updateShare(42); } - /** - * @expectedException \OCP\AppFramework\OCS\OCSBadRequestException - * @expectedExceptionMessage Wrong or no update parameter given - */ + public function testUpdateNoParametersLink() { + $this->expectException(\OCP\AppFramework\OCS\OCSBadRequestException::class); + $this->expectExceptionMessage('Wrong or no update parameter given'); + $node = $this->getMockBuilder(Folder::class)->getMock(); $share = $this->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) @@ -2417,11 +2418,11 @@ class ShareAPIControllerTest extends TestCase { $this->ocs->updateShare(42); } - /** - * @expectedException \OCP\AppFramework\OCS\OCSBadRequestException - * @expectedExceptionMessage Wrong or no update parameter given - */ + public function testUpdateNoParametersOther() { + $this->expectException(\OCP\AppFramework\OCS\OCSBadRequestException::class); + $this->expectExceptionMessage('Wrong or no update parameter given'); + $node = $this->getMockBuilder(Folder::class)->getMock(); $share = $this->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) @@ -2606,11 +2607,11 @@ class ShareAPIControllerTest extends TestCase { $this->assertEquals($expected->getData(), $result->getData()); } - /** - * @expectedException \OCP\AppFramework\OCS\OCSBadRequestException - * @expectedExceptionMessage Invalid date. Format must be YYYY-MM-DD - */ + public function testUpdateLinkShareInvalidDate() { + $this->expectException(\OCP\AppFramework\OCS\OCSBadRequestException::class); + $this->expectExceptionMessage('Invalid date. Format must be YYYY-MM-DD'); + $ocs = $this->mockFormatShare(); $folder = $this->getMockBuilder(Folder::class)->getMock(); @@ -2645,10 +2646,11 @@ class ShareAPIControllerTest extends TestCase { /** * @dataProvider publicUploadParamsProvider - * @expectedException \OCP\AppFramework\OCS\OCSForbiddenException - * @expectedExceptionMessage Public upload disabled by the administrator */ public function testUpdateLinkSharePublicUploadNotAllowed($permissions, $publicUpload, $expireDate, $password) { + $this->expectException(\OCP\AppFramework\OCS\OCSForbiddenException::class); + $this->expectExceptionMessage('Public upload disabled by the administrator'); + $ocs = $this->mockFormatShare(); $folder = $this->getMockBuilder(Folder::class)->getMock(); @@ -2665,11 +2667,11 @@ class ShareAPIControllerTest extends TestCase { $ocs->updateShare(42, $permissions, $password, null, $publicUpload, $expireDate); } - /** - * @expectedException \OCP\AppFramework\OCS\OCSBadRequestException - * @expectedExceptionMessage Public upload is only possible for publicly shared folders - */ + public function testUpdateLinkSharePublicUploadOnFile() { + $this->expectException(\OCP\AppFramework\OCS\OCSBadRequestException::class); + $this->expectExceptionMessage('Public upload is only possible for publicly shared folders'); + $ocs = $this->mockFormatShare(); $file = $this->getMockBuilder(File::class)->getMock(); @@ -2778,11 +2780,11 @@ class ShareAPIControllerTest extends TestCase { $this->assertEquals($expected->getData(), $result->getData()); } - /** - * @expectedException \OCP\AppFramework\OCS\OCSForbiddenException - * @expectedExceptionMessage Sharing sending the password by Nextcloud Talk failed because Nextcloud Talk is not enabled - */ + public function testUpdateLinkShareSendPasswordByTalkWithTalkDisabledDoesNotChangeOther() { + $this->expectException(\OCP\AppFramework\OCS\OCSForbiddenException::class); + $this->expectExceptionMessage('Sharing sending the password by Nextcloud Talk failed because Nextcloud Talk is not enabled'); + $ocs = $this->mockFormatShare(); $date = new \DateTime('2000-01-01'); @@ -3381,7 +3383,7 @@ class ShareAPIControllerTest extends TestCase { $cache = $this->getMockBuilder('OCP\Files\Cache\ICache')->getMock(); $cache->method('getNumericStorageId')->willReturn(100); - $storage = $this->getMockBuilder(Storage::class)->getMock(); + $storage = $this->createMock(Storage::class); $storage->method('getId')->willReturn('storageId'); $storage->method('getCache')->willReturn($cache); @@ -4150,7 +4152,7 @@ class ShareAPIControllerTest extends TestCase { $cache = $this->getMockBuilder('OCP\Files\Cache\ICache')->getMock(); $cache->method('getNumericStorageId')->willReturn(100); - $storage = $this->getMockBuilder(Storage::class)->getMock(); + $storage = $this->createMock(Storage::class); $storage->method('getId')->willReturn('storageId'); $storage->method('getCache')->willReturn($cache); |