diff options
author | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2017-11-01 15:37:29 +0100 |
---|---|---|
committer | Arthur Schiwon <blizzz@arthur-schiwon.de> | 2017-11-01 15:37:29 +0100 |
commit | e2805f02aa51c602c581bd4f09b99dd791a42df4 (patch) | |
tree | 4ea194f47aa315874c2aac31c30dbdb14110539b /apps/files_sharing/tests | |
parent | 2b4b3b1986e58305c08941f77a693a80cc3d5b85 (diff) | |
parent | 52b679a2d6f6b273f46334b15534ab312f974a1a (diff) | |
download | nextcloud-server-e2805f02aa51c602c581bd4f09b99dd791a42df4.tar.gz nextcloud-server-e2805f02aa51c602c581bd4f09b99dd791a42df4.zip |
Merge branch 'master' into autocomplete-gui
Diffstat (limited to 'apps/files_sharing/tests')
8 files changed, 109 insertions, 96 deletions
diff --git a/apps/files_sharing/tests/ApiTest.php b/apps/files_sharing/tests/ApiTest.php index 1b629f66a81..8a976108b3f 100644 --- a/apps/files_sharing/tests/ApiTest.php +++ b/apps/files_sharing/tests/ApiTest.php @@ -35,6 +35,8 @@ use OCP\AppFramework\OCS\OCSBadRequestException; use OCP\AppFramework\OCS\OCSException; use OCP\AppFramework\OCS\OCSForbiddenException; use OCP\AppFramework\OCS\OCSNotFoundException; +use OCP\IL10N; +use OCP\IRequest; /** * Class ApiTest @@ -96,7 +98,7 @@ class ApiTest extends TestCase { * @return \OCA\Files_Sharing\Controller\ShareAPIController */ private function createOCS($userId) { - $l = $this->getMockBuilder('\OCP\IL10N')->getMock(); + $l = $this->getMockBuilder(IL10N::class)->getMock(); $l->method('t') ->will($this->returnCallback(function($text, $parameters = []) { return vsprintf($text, $parameters); @@ -104,7 +106,7 @@ class ApiTest extends TestCase { return new ShareAPIController( self::APP_NAME, - $this->getMockBuilder('OCP\IRequest')->getMock(), + $this->getMockBuilder(IRequest::class)->getMock(), $this->shareManager, \OC::$server->getGroupManager(), \OC::$server->getUserManager(), diff --git a/apps/files_sharing/tests/CapabilitiesTest.php b/apps/files_sharing/tests/CapabilitiesTest.php index 1747bbc4ed2..e65131bf45f 100644 --- a/apps/files_sharing/tests/CapabilitiesTest.php +++ b/apps/files_sharing/tests/CapabilitiesTest.php @@ -24,6 +24,7 @@ namespace OCA\Files_Sharing\Tests; use OCA\Files_Sharing\Capabilities; +use OCP\IConfig; /** @@ -54,7 +55,7 @@ class CapabilitiesTest extends \Test\TestCase { * @return string[] */ private function getResults(array $map) { - $config = $this->getMockBuilder('\OCP\IConfig')->disableOriginalConstructor()->getMock(); + $config = $this->getMockBuilder(IConfig::class)->disableOriginalConstructor()->getMock(); $config->method('getAppValue')->will($this->returnValueMap($map)); $cap = new Capabilities($config); $result = $this->getFilesSharingPart($cap->getCapabilities()); diff --git a/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php b/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php index 827fcc15797..5480874615e 100644 --- a/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php +++ b/apps/files_sharing/tests/Command/CleanupRemoteStoragesTest.php @@ -22,6 +22,8 @@ namespace OCA\Files_Sharing\Tests\Command; use OCA\Files_Sharing\Command\CleanupRemoteStorages; +use Symfony\Component\Console\Input\InputInterface; +use Symfony\Component\Console\Output\OutputInterface; use Test\TestCase; /** @@ -158,10 +160,10 @@ class CleanupRemoteStoragesTest extends TestCase { * Test cleanup of orphaned storages */ public function testCleanup() { - $input = $this->getMockBuilder('Symfony\Component\Console\Input\InputInterface') + $input = $this->getMockBuilder(InputInterface::class) ->disableOriginalConstructor() ->getMock(); - $output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface') + $output = $this->getMockBuilder(OutputInterface::class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php index 45134df36b7..3bebb9e1195 100644 --- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php @@ -25,7 +25,9 @@ namespace OCA\Files_Sharing\Tests\Controller; use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\OCS\OCSNotFoundException; +use OCP\Files\File; use OCP\Files\Folder; +use OCP\Files\Storage; use OCP\IL10N; use OCA\Files_Sharing\Controller\ShareAPIController; use OCP\Files\NotFoundException; @@ -156,7 +158,7 @@ class ShareAPIControllerTest extends TestCase { } public function testDeleteShare() { - $node = $this->getMockBuilder('\OCP\Files\File')->getMock(); + $node = $this->getMockBuilder(File::class)->getMock(); $share = $this->newShare(); $share->setSharedBy($this->currentUser) @@ -187,7 +189,7 @@ class ShareAPIControllerTest extends TestCase { * @expectedExceptionMessage could not delete share */ public function testDeleteShareLocked() { - $node = $this->getMockBuilder('\OCP\Files\File')->getMock(); + $node = $this->getMockBuilder(File::class)->getMock(); $share = $this->newShare(); $share->setSharedBy($this->currentUser) @@ -228,7 +230,7 @@ class ShareAPIControllerTest extends TestCase { public function createShare($id, $shareType, $sharedWith, $sharedBy, $shareOwner, $path, $permissions, $shareTime, $expiration, $parent, $target, $mail_send, $token=null, $password=null) { - $share = $this->getMockBuilder('\OCP\Share\IShare')->getMock(); + $share = $this->getMockBuilder(IShare::class)->getMock(); $share->method('getId')->willReturn($id); $share->method('getShareType')->willReturn($shareType); $share->method('getSharedWith')->willReturn($sharedWith); @@ -262,7 +264,7 @@ class ShareAPIControllerTest extends TestCase { ->getMock(); $cache->method('getNumericStorageId')->willReturn(101); - $storage = $this->getMockBuilder('OC\Files\Storage\Storage') + $storage = $this->getMockBuilder(Storage::class) ->disableOriginalConstructor() ->getMock(); $storage->method('getId')->willReturn('STORAGE'); @@ -464,15 +466,15 @@ class ShareAPIControllerTest extends TestCase { ->method('linkToRouteAbsolute') ->willReturn('url'); - $initiator = $this->getMockBuilder('OCP\IUser')->getMock(); + $initiator = $this->getMockBuilder(IUser::class)->getMock(); $initiator->method('getUID')->willReturn('initiatorId'); $initiator->method('getDisplayName')->willReturn('initiatorDisplay'); - $owner = $this->getMockBuilder('OCP\IUser')->getMock(); + $owner = $this->getMockBuilder(IUser::class)->getMock(); $owner->method('getUID')->willReturn('ownerId'); $owner->method('getDisplayName')->willReturn('ownerDisplay'); - $user = $this->getMockBuilder('OCP\IUser')->getMock(); + $user = $this->getMockBuilder(IUser::class)->getMock(); $user->method('getUID')->willReturn('userId'); $user->method('getDisplayName')->willReturn('userDisplay'); @@ -511,25 +513,25 @@ class ShareAPIControllerTest extends TestCase { } public function testCanAccessShare() { - $share = $this->getMockBuilder('OCP\Share\IShare')->getMock(); + $share = $this->getMockBuilder(IShare::class)->getMock(); $share->method('getShareOwner')->willReturn($this->currentUser); $this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); - $share = $this->getMockBuilder('OCP\Share\IShare')->getMock(); + $share = $this->getMockBuilder(IShare::class)->getMock(); $share->method('getSharedBy')->willReturn($this->currentUser); $this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); - $share = $this->getMockBuilder('OCP\Share\IShare')->getMock(); + $share = $this->getMockBuilder(IShare::class)->getMock(); $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER); $share->method('getSharedWith')->willReturn($this->currentUser); $this->assertTrue($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); - $share = $this->getMockBuilder('OCP\Share\IShare')->getMock(); + $share = $this->getMockBuilder(IShare::class)->getMock(); $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_USER); - $share->method('getSharedWith')->willReturn($this->getMockBuilder('OCP\IUser')->getMock()); + $share->method('getSharedWith')->willReturn($this->getMockBuilder(IUser::class)->getMock()); $this->assertFalse($this->invokePrivate($this->ocs, 'canAccessShare', [$share])); - $share = $this->getMockBuilder('OCP\Share\IShare')->getMock(); + $share = $this->getMockBuilder(IShare::class)->getMock(); $share->method('getShareType')->willReturn(\OCP\Share::SHARE_TYPE_GROUP); $share->method('getSharedWith')->willReturn('group'); @@ -579,7 +581,7 @@ class ShareAPIControllerTest extends TestCase { * @expectedExceptionMessage Wrong path, file/folder doesn't exist */ public function testCreateShareInvalidPath() { - $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $userFolder = $this->getMockBuilder(Folder::class)->getMock(); $this->rootFolder->expects($this->once()) ->method('getUserFolder') ->with('currentUser') @@ -601,13 +603,13 @@ class ShareAPIControllerTest extends TestCase { $share = $this->newShare(); $this->shareManager->method('newShare')->willReturn($share); - $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $userFolder = $this->getMockBuilder(Folder::class)->getMock(); $this->rootFolder->expects($this->once()) ->method('getUserFolder') ->with('currentUser') ->willReturn($userFolder); - $path = $this->getMockBuilder('\OCP\Files\File')->getMock(); + $path = $this->getMockBuilder(File::class)->getMock(); $userFolder->expects($this->once()) ->method('get') ->with('valid-path') @@ -628,14 +630,14 @@ class ShareAPIControllerTest extends TestCase { $share = $this->newShare(); $this->shareManager->method('newShare')->willReturn($share); - $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $userFolder = $this->getMockBuilder(Folder::class)->getMock(); $this->rootFolder->expects($this->once()) ->method('getUserFolder') ->with('currentUser') ->willReturn($userFolder); - $path = $this->getMockBuilder('\OCP\Files\File')->getMock(); - $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); + $path = $this->getMockBuilder(File::class)->getMock(); + $storage = $this->getMockBuilder(Storage::class)->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -660,14 +662,14 @@ class ShareAPIControllerTest extends TestCase { $share = $this->newShare(); $this->shareManager->method('newShare')->willReturn($share); - $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $userFolder = $this->getMockBuilder(Folder::class)->getMock(); $this->rootFolder->expects($this->once()) ->method('getUserFolder') ->with('currentUser') ->willReturn($userFolder); - $path = $this->getMockBuilder('\OCP\Files\File')->getMock(); - $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); + $path = $this->getMockBuilder(File::class)->getMock(); + $storage = $this->getMockBuilder(Storage::class)->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -705,14 +707,14 @@ class ShareAPIControllerTest extends TestCase { ])->setMethods(['formatShare']) ->getMock(); - $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $userFolder = $this->getMockBuilder(Folder::class)->getMock(); $this->rootFolder->expects($this->once()) ->method('getUserFolder') ->with('currentUser') ->willReturn($userFolder); - $path = $this->getMockBuilder('\OCP\Files\File')->getMock(); - $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); + $path = $this->getMockBuilder(File::class)->getMock(); + $storage = $this->getMockBuilder(Storage::class)->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -759,14 +761,14 @@ class ShareAPIControllerTest extends TestCase { $this->shareManager->method('createShare')->will($this->returnArgument(0)); $this->shareManager->method('allowGroupSharing')->willReturn(true); - $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $userFolder = $this->getMockBuilder(Folder::class)->getMock(); $this->rootFolder->expects($this->once()) ->method('getUserFolder') ->with('currentUser') ->willReturn($userFolder); - $path = $this->getMockBuilder('\OCP\Files\File')->getMock(); - $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); + $path = $this->getMockBuilder(File::class)->getMock(); + $storage = $this->getMockBuilder(Storage::class)->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -811,14 +813,14 @@ class ShareAPIControllerTest extends TestCase { ['shareWith', null, 'validGroup'], ])); - $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $userFolder = $this->getMockBuilder(Folder::class)->getMock(); $this->rootFolder->expects($this->once()) ->method('getUserFolder') ->with('currentUser') ->willReturn($userFolder); - $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); - $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); + $path = $this->getMockBuilder(Folder::class)->getMock(); + $storage = $this->getMockBuilder(Storage::class)->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -863,14 +865,14 @@ class ShareAPIControllerTest extends TestCase { $share = $this->newShare(); $this->shareManager->method('newShare')->willReturn($share); - $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $userFolder = $this->getMockBuilder(Folder::class)->getMock(); $this->rootFolder->expects($this->once()) ->method('getUserFolder') ->with('currentUser') ->willReturn($userFolder); - $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); - $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); + $path = $this->getMockBuilder(Folder::class)->getMock(); + $storage = $this->getMockBuilder(Storage::class)->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -901,8 +903,8 @@ class ShareAPIControllerTest extends TestCase { ['shareType', '-1', \OCP\Share::SHARE_TYPE_LINK], ])); - $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); - $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); + $path = $this->getMockBuilder(Folder::class)->getMock(); + $storage = $this->getMockBuilder(Storage::class)->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -920,8 +922,8 @@ class ShareAPIControllerTest extends TestCase { * @expectedExceptionMessage Public upload disabled by the administrator */ public function testCreateShareLinkNoPublicUpload() { - $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); - $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); + $path = $this->getMockBuilder(Folder::class)->getMock(); + $storage = $this->getMockBuilder(Storage::class)->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -940,8 +942,8 @@ class ShareAPIControllerTest extends TestCase { * @expectedExceptionMessage Public upload is only possible for publicly shared folders */ public function testCreateShareLinkPublicUploadFile() { - $path = $this->getMockBuilder('\OCP\Files\File')->getMock(); - $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); + $path = $this->getMockBuilder(File::class)->getMock(); + $storage = $this->getMockBuilder(Storage::class)->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -959,8 +961,8 @@ class ShareAPIControllerTest extends TestCase { public function testCreateShareLinkPublicUploadFolder() { $ocs = $this->mockFormatShare(); - $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); - $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); + $path = $this->getMockBuilder(Folder::class)->getMock(); + $storage = $this->getMockBuilder(Storage::class)->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -993,8 +995,8 @@ class ShareAPIControllerTest extends TestCase { public function testCreateShareLinkPassword() { $ocs = $this->mockFormatShare(); - $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); - $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); + $path = $this->getMockBuilder(Folder::class)->getMock(); + $storage = $this->getMockBuilder(Storage::class)->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -1037,8 +1039,8 @@ class ShareAPIControllerTest extends TestCase { ['password', '', ''], ])); - $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); - $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); + $path = $this->getMockBuilder(Folder::class)->getMock(); + $storage = $this->getMockBuilder(Storage::class)->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -1078,8 +1080,8 @@ class ShareAPIControllerTest extends TestCase { public function testCreateShareInvalidExpireDate() { $ocs = $this->mockFormatShare(); - $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); - $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); + $path = $this->getMockBuilder(Folder::class)->getMock(); + $storage = $this->getMockBuilder(Storage::class)->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(false); @@ -1117,14 +1119,14 @@ class ShareAPIControllerTest extends TestCase { ])->setMethods(['formatShare']) ->getMock(); - $userFolder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $userFolder = $this->getMockBuilder(Folder::class)->getMock(); $this->rootFolder->expects($this->once()) ->method('getUserFolder') ->with('currentUser') ->willReturn($userFolder); - $path = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); - $storage = $this->getMockBuilder('OCP\Files\Storage')->getMock(); + $path = $this->getMockBuilder(Folder::class)->getMock(); + $storage = $this->getMockBuilder(Storage::class)->getMock(); $storage->method('instanceOfStorage') ->with('OCA\Files_Sharing\External\Storage') ->willReturn(true); @@ -1153,7 +1155,7 @@ class ShareAPIControllerTest extends TestCase { * @expectedExceptionMessage Wrong share ID, share doesn't exist */ public function testUpdateShareCantAccess() { - $node = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $node = $this->getMockBuilder(Folder::class)->getMock(); $share = $this->newShare(); $share->setNode($node); @@ -1171,7 +1173,7 @@ class ShareAPIControllerTest extends TestCase { * @expectedExceptionMessage Wrong or no update parameter given */ public function testUpdateNoParametersLink() { - $node = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $node = $this->getMockBuilder(Folder::class)->getMock(); $share = $this->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) @@ -1192,7 +1194,7 @@ class ShareAPIControllerTest extends TestCase { * @expectedExceptionMessage Wrong or no update parameter given */ public function testUpdateNoParametersOther() { - $node = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $node = $this->getMockBuilder(Folder::class)->getMock(); $share = $this->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) @@ -1248,7 +1250,7 @@ class ShareAPIControllerTest extends TestCase { public function testUpdateLinkShareSet() { $ocs = $this->mockFormatShare(); - $folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $folder = $this->getMockBuilder(Folder::class)->getMock(); $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) @@ -1286,7 +1288,7 @@ class ShareAPIControllerTest extends TestCase { public function testUpdateLinkShareEnablePublicUpload($permissions, $publicUpload, $expireDate, $password) { $ocs = $this->mockFormatShare(); - $folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $folder = $this->getMockBuilder(Folder::class)->getMock(); $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) @@ -1321,7 +1323,7 @@ class ShareAPIControllerTest extends TestCase { public function testUpdateLinkShareInvalidDate() { $ocs = $this->mockFormatShare(); - $folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $folder = $this->getMockBuilder(Folder::class)->getMock(); $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) @@ -1359,7 +1361,7 @@ class ShareAPIControllerTest extends TestCase { public function testUpdateLinkSharePublicUploadNotAllowed($permissions, $publicUpload, $expireDate, $password) { $ocs = $this->mockFormatShare(); - $folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $folder = $this->getMockBuilder(Folder::class)->getMock(); $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) @@ -1380,7 +1382,7 @@ class ShareAPIControllerTest extends TestCase { public function testUpdateLinkSharePublicUploadOnFile() { $ocs = $this->mockFormatShare(); - $file = $this->getMockBuilder('\OCP\Files\File')->getMock(); + $file = $this->getMockBuilder(File::class)->getMock(); $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) @@ -1400,7 +1402,7 @@ class ShareAPIControllerTest extends TestCase { $date = new \DateTime('2000-01-01'); $date->setTime(0,0,0); - $node = $this->getMockBuilder('\OCP\Files\File')->getMock(); + $node = $this->getMockBuilder(File::class)->getMock(); $share = $this->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) @@ -1434,7 +1436,7 @@ class ShareAPIControllerTest extends TestCase { public function testUpdateLinkShareExpireDateDoesNotChangeOther() { $ocs = $this->mockFormatShare(); - $node = $this->getMockBuilder('\OCP\Files\File')->getMock(); + $node = $this->getMockBuilder(File::class)->getMock(); $share = $this->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) ->setSharedBy($this->currentUser) @@ -1473,7 +1475,7 @@ class ShareAPIControllerTest extends TestCase { $date = new \DateTime('2000-01-01'); - $folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $folder = $this->getMockBuilder(Folder::class)->getMock(); $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) @@ -1510,7 +1512,7 @@ class ShareAPIControllerTest extends TestCase { $date = new \DateTime('2000-01-01'); - $folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $folder = $this->getMockBuilder(Folder::class)->getMock(); $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) @@ -1546,7 +1548,7 @@ class ShareAPIControllerTest extends TestCase { $date = new \DateTime('2000-01-01'); - $folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $folder = $this->getMockBuilder(Folder::class)->getMock(); $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) @@ -1580,7 +1582,7 @@ class ShareAPIControllerTest extends TestCase { public function testUpdateOtherPermissions() { $ocs = $this->mockFormatShare(); - $file = $this->getMockBuilder('\OCP\Files\File')->getMock(); + $file = $this->getMockBuilder(File::class)->getMock(); $share = \OC::$server->getShareManager()->newShare(); $share->setPermissions(\OCP\Constants::PERMISSION_ALL) @@ -1750,9 +1752,9 @@ class ShareAPIControllerTest extends TestCase { } public function dataFormatShare() { - $file = $this->getMockBuilder('\OCP\Files\File')->getMock(); - $folder = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); - $parent = $this->getMockBuilder('\OCP\Files\Folder')->getMock(); + $file = $this->getMockBuilder(File::class)->getMock(); + $folder = $this->getMockBuilder(Folder::class)->getMock(); + $parent = $this->getMockBuilder(Folder::class)->getMock(); $file->method('getMimeType')->willReturn('myMimeType'); $folder->method('getMimeType')->willReturn('myFolderMimeType'); @@ -1769,18 +1771,18 @@ class ShareAPIControllerTest extends TestCase { $cache = $this->getMockBuilder('OCP\Files\Cache\ICache')->getMock(); $cache->method('getNumericStorageId')->willReturn(100); - $storage = $this->getMockBuilder('\OCP\Files\Storage')->getMock(); + $storage = $this->getMockBuilder(Storage::class)->getMock(); $storage->method('getId')->willReturn('storageId'); $storage->method('getCache')->willReturn($cache); $file->method('getStorage')->willReturn($storage); $folder->method('getStorage')->willReturn($storage); - $owner = $this->getMockBuilder('\OCP\IUser')->getMock(); + $owner = $this->getMockBuilder(IUser::class)->getMock(); $owner->method('getDisplayName')->willReturn('ownerDN'); - $initiator = $this->getMockBuilder('\OCP\IUser')->getMock(); + $initiator = $this->getMockBuilder(IUser::class)->getMock(); $initiator->method('getDisplayName')->willReturn('initiatorDN'); - $recipient = $this->getMockBuilder('\OCP\IUser')->getMock(); + $recipient = $this->getMockBuilder(IUser::class)->getMock(); $recipient->method('getDisplayName')->willReturn('recipientDN'); $result = []; diff --git a/apps/files_sharing/tests/Controller/ShareControllerTest.php b/apps/files_sharing/tests/Controller/ShareControllerTest.php index 7a017b5e3b7..6f0b3f9c2da 100644 --- a/apps/files_sharing/tests/Controller/ShareControllerTest.php +++ b/apps/files_sharing/tests/Controller/ShareControllerTest.php @@ -35,6 +35,12 @@ use OC\Files\Filesystem; use OCA\FederatedFileSharing\FederatedShareProvider; use OCA\Files_Sharing\Controller\ShareController; use OCP\AppFramework\Http\DataResponse; +use OCP\IConfig; +use OCP\IL10N; +use OCP\ILogger; +use OCP\IPreview; +use OCP\IRequest; +use OCP\IUser; use OCP\Share\Exceptions\ShareNotFound; use OCP\AppFramework\Http\NotFoundResponse; use OCP\AppFramework\Http\RedirectResponse; @@ -43,6 +49,7 @@ use OCP\ISession; use OCP\IUserManager; use OCP\Security\ISecureRandom; use OCP\IURLGenerator; +use OCP\Share\IShare; use Symfony\Component\EventDispatcher\EventDispatcherInterface; /** @@ -83,11 +90,11 @@ class ShareControllerTest extends \Test\TestCase { $this->appName = 'files_sharing'; $this->shareManager = $this->getMockBuilder('\OC\Share20\Manager')->disableOriginalConstructor()->getMock(); - $this->urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')->getMock(); - $this->session = $this->getMockBuilder('\OCP\ISession')->getMock(); - $this->previewManager = $this->getMockBuilder('\OCP\IPreview')->getMock(); - $this->config = $this->getMockBuilder('\OCP\IConfig')->getMock(); - $this->userManager = $this->getMockBuilder('\OCP\IUserManager')->getMock(); + $this->urlGenerator = $this->getMockBuilder(IURLGenerator::class)->getMock(); + $this->session = $this->getMockBuilder(ISession::class)->getMock(); + $this->previewManager = $this->getMockBuilder(IPreview::class)->getMock(); + $this->config = $this->getMockBuilder(IConfig::class)->getMock(); + $this->userManager = $this->getMockBuilder(IUserManager::class)->getMock(); $this->federatedShareProvider = $this->getMockBuilder('OCA\FederatedFileSharing\FederatedShareProvider') ->disableOriginalConstructor()->getMock(); $this->federatedShareProvider->expects($this->any()) @@ -98,11 +105,11 @@ class ShareControllerTest extends \Test\TestCase { $this->shareController = new \OCA\Files_Sharing\Controller\ShareController( $this->appName, - $this->getMockBuilder('\OCP\IRequest')->getMock(), + $this->getMockBuilder(IRequest::class)->getMock(), $this->config, $this->urlGenerator, $this->userManager, - $this->getMockBuilder('\OCP\ILogger')->getMock(), + $this->getMockBuilder(ILogger::class)->getMock(), $this->getMockBuilder('\OCP\Activity\IManager')->getMock(), $this->shareManager, $this->session, @@ -110,7 +117,7 @@ class ShareControllerTest extends \Test\TestCase { $this->getMockBuilder('\OCP\Files\IRootFolder')->getMock(), $this->federatedShareProvider, $this->eventDispatcher, - $this->getMockBuilder('\OCP\IL10N')->getMock(), + $this->getMockBuilder(IL10N::class)->getMock(), $this->getMockBuilder('\OCP\Defaults')->getMock() ); @@ -320,7 +327,7 @@ class ShareControllerTest extends \Test\TestCase { public function testShowShare() { - $owner = $this->getMockBuilder('OCP\IUser')->getMock(); + $owner = $this->getMockBuilder(IUser::class)->getMock(); $owner->method('getDisplayName')->willReturn('ownerDisplay'); $owner->method('getUID')->willReturn('ownerUID'); @@ -412,7 +419,7 @@ class ShareControllerTest extends \Test\TestCase { * @expectedException \OCP\Files\NotFoundException */ public function testShowShareInvalid() { - $owner = $this->getMockBuilder('OCP\IUser')->getMock(); + $owner = $this->getMockBuilder(IUser::class)->getMock(); $owner->method('getDisplayName')->willReturn('ownerDisplay'); $owner->method('getUID')->willReturn('ownerUID'); @@ -457,7 +464,7 @@ class ShareControllerTest extends \Test\TestCase { } public function testDownloadShare() { - $share = $this->getMockBuilder('\OCP\Share\IShare')->getMock(); + $share = $this->getMockBuilder(IShare::class)->getMock(); $share->method('getPassword')->willReturn('password'); $share ->expects($this->once()) @@ -482,7 +489,7 @@ class ShareControllerTest extends \Test\TestCase { } public function testDownloadShareWithCreateOnlyShare() { - $share = $this->getMockBuilder('\OCP\Share\IShare')->getMock(); + $share = $this->getMockBuilder(IShare::class)->getMock(); $share->method('getPassword')->willReturn('password'); $share ->expects($this->once()) diff --git a/apps/files_sharing/tests/External/ManagerTest.php b/apps/files_sharing/tests/External/ManagerTest.php index 9f60261c203..37319dd17b2 100644 --- a/apps/files_sharing/tests/External/ManagerTest.php +++ b/apps/files_sharing/tests/External/ManagerTest.php @@ -27,7 +27,6 @@ namespace OCA\Files_Sharing\Tests\External; use OC\Federation\CloudIdManager; use OC\Files\Storage\StorageFactory; -use OCA\FederatedFileSharing\DiscoveryManager; use OCA\Files_Sharing\External\Manager; use OCA\Files_Sharing\External\MountProvider; use OCA\Files_Sharing\Tests\TestCase; @@ -68,7 +67,7 @@ class ManagerTest extends TestCase { $this->createUser($this->uid, ''); $this->user = \OC::$server->getUserManager()->get($this->uid); $this->mountManager = new \OC\Files\Mount\Manager(); - $this->clientService = $this->getMockBuilder('\OCP\Http\Client\IClientService') + $this->clientService = $this->getMockBuilder(IClientService::class) ->disableOriginalConstructor()->getMock(); $this->manager = new Manager( diff --git a/apps/files_sharing/tests/MountProviderTest.php b/apps/files_sharing/tests/MountProviderTest.php index 04476987a32..68c62427e34 100644 --- a/apps/files_sharing/tests/MountProviderTest.php +++ b/apps/files_sharing/tests/MountProviderTest.php @@ -60,11 +60,11 @@ class MountProviderTest extends \Test\TestCase { public function setUp() { parent::setUp(); - $this->config = $this->getMockBuilder('OCP\IConfig')->getMock(); - $this->user = $this->getMockBuilder('OCP\IUser')->getMock(); + $this->config = $this->getMockBuilder(IConfig::class)->getMock(); + $this->user = $this->getMockBuilder(IUser::class)->getMock(); $this->loader = $this->getMockBuilder('OCP\Files\Storage\IStorageFactory')->getMock(); - $this->shareManager = $this->getMockBuilder('\OCP\Share\IManager')->getMock(); - $this->logger = $this->getMockBuilder('\OCP\ILogger')->getMock(); + $this->shareManager = $this->getMockBuilder(IManager::class)->getMock(); + $this->logger = $this->getMockBuilder(ILogger::class)->getMock(); $this->provider = new MountProvider($this->config, $this->shareManager, $this->logger); } diff --git a/apps/files_sharing/tests/UpdaterTest.php b/apps/files_sharing/tests/UpdaterTest.php index 63000152b5a..c01365a500a 100644 --- a/apps/files_sharing/tests/UpdaterTest.php +++ b/apps/files_sharing/tests/UpdaterTest.php @@ -70,7 +70,7 @@ class UpdaterTest extends TestCase { * that the mount point doesn't end up at the trash bin */ public function testDeleteParentFolder() { - $status = \OC_App::isEnabled('files_trashbin'); + $status = \OC::$server->getAppManager()->isEnabledForUser('files_trashbin'); (new \OC_App())->enable('files_trashbin'); |