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 /apps/files_sharing/tests | |
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 'apps/files_sharing/tests')
15 files changed, 133 insertions, 131 deletions
diff --git a/apps/files_sharing/tests/CapabilitiesTest.php b/apps/files_sharing/tests/CapabilitiesTest.php index 493f607dba2..3f8dd85c10b 100644 --- a/apps/files_sharing/tests/CapabilitiesTest.php +++ b/apps/files_sharing/tests/CapabilitiesTest.php @@ -92,7 +92,7 @@ class CapabilitiesTest extends \Test\TestCase { ['core', 'shareapi_allow_links', 'yes', 'no'], ]; $result = $this->getResults($map); - $this->assertInternalType('array', $result['public']); + $this->assertIsArray($result['public']); $this->assertFalse($result['public']['enabled']); } @@ -102,7 +102,7 @@ class CapabilitiesTest extends \Test\TestCase { ['core', 'shareapi_allow_links', 'yes', 'yes'], ]; $result = $this->getResults($map); - $this->assertInternalType('array', $result['public']); + $this->assertIsArray($result['public']); $this->assertTrue($result['public']['enabled']); } @@ -138,7 +138,7 @@ class CapabilitiesTest extends \Test\TestCase { ]; $result = $this->getResults($map); $this->assertArrayHasKey('expire_date', $result['public']); - $this->assertInternalType('array', $result['public']['expire_date']); + $this->assertIsArray($result['public']['expire_date']); $this->assertFalse($result['public']['expire_date']['enabled']); } @@ -152,7 +152,7 @@ class CapabilitiesTest extends \Test\TestCase { ]; $result = $this->getResults($map); $this->assertArrayHasKey('expire_date', $result['public']); - $this->assertInternalType('array', $result['public']['expire_date']); + $this->assertIsArray($result['public']['expire_date']); $this->assertTrue($result['public']['expire_date']['enabled']); $this->assertArrayHasKey('days', $result['public']['expire_date']); $this->assertFalse($result['public']['expire_date']['enforced']); @@ -167,7 +167,7 @@ class CapabilitiesTest extends \Test\TestCase { ]; $result = $this->getResults($map); $this->assertArrayHasKey('expire_date', $result['public']); - $this->assertInternalType('array', $result['public']['expire_date']); + $this->assertIsArray($result['public']['expire_date']); $this->assertTrue($result['public']['expire_date']['enforced']); } diff --git a/apps/files_sharing/tests/Collaboration/ShareRecipientSorterTest.php b/apps/files_sharing/tests/Collaboration/ShareRecipientSorterTest.php index 93bef4afbf6..146bb565a81 100644 --- a/apps/files_sharing/tests/Collaboration/ShareRecipientSorterTest.php +++ b/apps/files_sharing/tests/Collaboration/ShareRecipientSorterTest.php @@ -43,7 +43,7 @@ class ShareRecipientSorterTest extends TestCase { /** @var ShareRecipientSorter */ protected $sorter; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->shareManager = $this->createMock(IManager::class); diff --git a/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php b/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php index 4e100cf2099..102210e3b1e 100644 --- a/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php +++ b/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php @@ -110,7 +110,7 @@ class CleanupRemoteStoragesTest extends TestCase { $this->command = new CleanupRemoteStorages($this->connection); } - public function tearDown(): void { + protected function tearDown(): void { $storageQuery = \OC::$server->getDatabaseConnection()->getQueryBuilder(); $storageQuery->delete('storages') ->where($storageQuery->expr()->eq('id', $storageQuery->createParameter('id'))); diff --git a/apps/files_sharing/tests/Controller/ExternalShareControllerTest.php b/apps/files_sharing/tests/Controller/ExternalShareControllerTest.php index d2237acbd7f..5296a1ad0c3 100644 --- a/apps/files_sharing/tests/Controller/ExternalShareControllerTest.php +++ b/apps/files_sharing/tests/Controller/ExternalShareControllerTest.php @@ -43,7 +43,7 @@ class ExternalShareControllerTest extends \Test\TestCase { /** @var IClientService */ private $clientService; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->request = $this->getMockBuilder('\\OCP\\IRequest') ->disableOriginalConstructor()->getMock(); diff --git a/apps/files_sharing/tests/Controller/PublicPreviewControllerTest.php b/apps/files_sharing/tests/Controller/PublicPreviewControllerTest.php index cbe3872bb67..834796bf431 100644 --- a/apps/files_sharing/tests/Controller/PublicPreviewControllerTest.php +++ b/apps/files_sharing/tests/Controller/PublicPreviewControllerTest.php @@ -54,7 +54,7 @@ class PublicPreviewControllerTest extends TestCase { /** @var PublicPreviewController */ private $controller; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->previewManager = $this->createMock(IPreview::class); diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php index 7a50a752044..ae7fc54599c 100644 --- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php @@ -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,11 +212,11 @@ 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(); @@ -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(); @@ -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); @@ -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); @@ -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)); @@ -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); @@ -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([ @@ -1888,11 +1889,11 @@ 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->createMock(Storage::class); $storage->method('instanceOfStorage') @@ -1908,11 +1909,11 @@ 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->createMock(Storage::class); $storage->method('instanceOfStorage') @@ -2034,11 +2035,11 @@ 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(); @@ -2109,11 +2110,11 @@ 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(); @@ -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(); @@ -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(); @@ -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'); diff --git a/apps/files_sharing/tests/Controller/ShareControllerTest.php b/apps/files_sharing/tests/Controller/ShareControllerTest.php index ec6fc9a598d..55981f00238 100644 --- a/apps/files_sharing/tests/Controller/ShareControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareControllerTest.php @@ -532,10 +532,10 @@ class ShareControllerTest extends \Test\TestCase { self::assertEquals($expectedResponse, $response); } - /** - * @expectedException \OCP\Files\NotFoundException - */ + public function testShowShareInvalid() { + $this->expectException(\OCP\Files\NotFoundException::class); + $this->shareController->setToken('token'); $owner = $this->getMockBuilder(IUser::class)->getMock(); diff --git a/apps/files_sharing/tests/Controller/ShareInfoControllerTest.php b/apps/files_sharing/tests/Controller/ShareInfoControllerTest.php index b8d87d5cd68..f2feb6e7fcc 100644 --- a/apps/files_sharing/tests/Controller/ShareInfoControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareInfoControllerTest.php @@ -45,7 +45,7 @@ class ShareInfoControllerTest extends TestCase { private $shareManager; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->shareManager = $this->createMock(ShareManager::class); diff --git a/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php index 20790fc0bfa..99f86525913 100644 --- a/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareesAPIControllerTest.php @@ -397,11 +397,11 @@ class ShareesAPIControllerTest extends TestCase { $this->assertSame($expected, $this->invokePrivate($this->sharees, 'isRemoteSharingAllowed', [$itemType])); } - /** - * @expectedException \OCP\AppFramework\OCS\OCSBadRequestException - * @expectedExceptionMessage Missing itemType - */ + public function testSearchNoItemType() { + $this->expectException(\OCP\AppFramework\OCS\OCSBadRequestException::class); + $this->expectExceptionMessage('Missing itemType'); + $this->sharees->search('', null, 1, 10, [], false); } diff --git a/apps/files_sharing/tests/LockingTest.php b/apps/files_sharing/tests/LockingTest.php index 47394fc588f..49f49da643f 100644 --- a/apps/files_sharing/tests/LockingTest.php +++ b/apps/files_sharing/tests/LockingTest.php @@ -46,7 +46,7 @@ class LockingTest extends TestCase { private $ownerUid; private $recipientUid; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->userBackend = new \Test\Util\User\Dummy(); @@ -74,15 +74,15 @@ class LockingTest extends TestCase { $this->assertTrue(Filesystem::file_exists('bar.txt')); } - public function tearDown(): void { + protected function tearDown(): void { \OC::$server->getUserManager()->removeBackend($this->userBackend); parent::tearDown(); } - /** - * @expectedException \OCP\Lock\LockedException - */ + public function testLockAsRecipient() { + $this->expectException(\OCP\Lock\LockedException::class); + $this->loginAsUser($this->ownerUid); Filesystem::initMountPoints($this->recipientUid); diff --git a/apps/files_sharing/tests/Middleware/OCSShareAPIMiddlewareTest.php b/apps/files_sharing/tests/Middleware/OCSShareAPIMiddlewareTest.php index 06d33859a28..31ca88cc4fc 100644 --- a/apps/files_sharing/tests/Middleware/OCSShareAPIMiddlewareTest.php +++ b/apps/files_sharing/tests/Middleware/OCSShareAPIMiddlewareTest.php @@ -44,7 +44,7 @@ class OCSShareAPIMiddlewareTest extends \Test\TestCase { /** @var OCSShareAPIMiddleware */ private $middleware; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->shareManager = $this->createMock(IManager::class); diff --git a/apps/files_sharing/tests/Middleware/ShareInfoMiddlewareTest.php b/apps/files_sharing/tests/Middleware/ShareInfoMiddlewareTest.php index e6744d5fd1d..db698d94f11 100644 --- a/apps/files_sharing/tests/Middleware/ShareInfoMiddlewareTest.php +++ b/apps/files_sharing/tests/Middleware/ShareInfoMiddlewareTest.php @@ -41,7 +41,7 @@ class ShareInfoMiddlewareTest extends TestCase { /** @var ShareInfoMiddleware */ private $middleware; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->shareManager = $this->createMock(ShareManager::class); diff --git a/apps/files_sharing/tests/Middleware/SharingCheckMiddlewareTest.php b/apps/files_sharing/tests/Middleware/SharingCheckMiddlewareTest.php index e3fb602acd6..7a2baba16e0 100644 --- a/apps/files_sharing/tests/Middleware/SharingCheckMiddlewareTest.php +++ b/apps/files_sharing/tests/Middleware/SharingCheckMiddlewareTest.php @@ -198,11 +198,11 @@ class SharingCheckMiddlewareTest extends \Test\TestCase { $this->sharingCheckMiddleware->beforeController($controller, 'myMethod'); } - /** - * @expectedException \OCP\Files\NotFoundException - * @expectedExceptionMessage Sharing is disabled. - */ + public function testBeforeControllerWithSharingDisabled() { + $this->expectException(\OCP\Files\NotFoundException::class); + $this->expectExceptionMessage('Sharing is disabled.'); + $this->appManager ->expects($this->once()) ->method('isEnabledForUser') @@ -212,11 +212,11 @@ class SharingCheckMiddlewareTest extends \Test\TestCase { $this->sharingCheckMiddleware->beforeController($this->controllerMock, 'myMethod'); } - /** - * @expectedException \Exception - * @expectedExceptionMessage My Exception message - */ + public function testAfterExceptionWithRegularException() { + $this->expectException(\Exception::class); + $this->expectExceptionMessage('My Exception message'); + $this->sharingCheckMiddleware->afterException($this->controllerMock, 'myMethod', new \Exception('My Exception message')); } diff --git a/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php b/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php index 418ede9179a..b98b0b9fcd8 100644 --- a/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php +++ b/apps/files_sharing/tests/Migration/SetPasswordColumnTest.php @@ -47,7 +47,7 @@ class SetPasswordColumnTest extends TestCase { private $table = 'share'; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->connection = \OC::$server->getDatabaseConnection(); @@ -57,7 +57,7 @@ class SetPasswordColumnTest extends TestCase { $this->cleanDB(); } - public function tearDown(): void { + protected function tearDown(): void { parent::tearDown(); $this->cleanDB(); } diff --git a/apps/files_sharing/tests/MountProviderTest.php b/apps/files_sharing/tests/MountProviderTest.php index 5b20524da47..06ca2060477 100644 --- a/apps/files_sharing/tests/MountProviderTest.php +++ b/apps/files_sharing/tests/MountProviderTest.php @@ -59,7 +59,7 @@ class MountProviderTest extends \Test\TestCase { /** @var ILogger | \PHPUnit_Framework_MockObject_MockObject */ private $logger; - public function setUp(): void { + protected function setUp(): void { parent::setUp(); $this->config = $this->getMockBuilder(IConfig::class)->getMock(); |