diff --git a/apps/files_external/tests/Auth/Password/GlobalAuth.php b/apps/files_external/tests/Auth/Password/GlobalAuth.php index 1f0841a349..405fbd2941 100644 --- a/apps/files_external/tests/Auth/Password/GlobalAuth.php +++ b/apps/files_external/tests/Auth/Password/GlobalAuth.php @@ -24,6 +24,8 @@ namespace OCA\Files_External\Tests\Auth\Password; use OCA\Files_External\Lib\Auth\Password\GlobalAuth; use OCA\Files_external\Lib\StorageConfig; +use OCP\IL10N; +use OCP\Security\ICredentialsManager; use Test\TestCase; class GlobalAuthTest extends TestCase { @@ -44,14 +46,14 @@ class GlobalAuthTest extends TestCase { protected function setUp() { parent::setUp(); - $this->l10n = $this->getMock('\OCP\IL10N'); - $this->credentialsManager = $this->getMock('\OCP\Security\ICredentialsManager'); + $this->l10n = $this->createMock(IL10N::class); + $this->credentialsManager = $this->createMock(ICredentialsManager::class); $this->instance = new GlobalAuth($this->l10n, $this->credentialsManager); } private function getStorageConfig($type, $config = []) { /** @var \OCA\Files_External\Lib\StorageConfig|\PHPUnit_Framework_MockObject_MockObject $storageConfig */ - $storageConfig = $this->getMock('\OCA\Files_External\Lib\StorageConfig'); + $storageConfig = $this->createMock(StorageConfig::class); $storageConfig->expects($this->any()) ->method('getType') ->will($this->returnValue($type)); diff --git a/apps/files_external/tests/Command/ApplicableTest.php b/apps/files_external/tests/Command/ApplicableTest.php index 7e2ba9563a..70b18be6b7 100644 --- a/apps/files_external/tests/Command/ApplicableTest.php +++ b/apps/files_external/tests/Command/ApplicableTest.php @@ -23,13 +23,15 @@ namespace OCA\Files_External\Tests\Command; use OCA\Files_External\Command\Applicable; +use OCP\IGroupManager; +use OCP\IUserManager; class ApplicableTest extends CommandTest { private function getInstance($storageService) { /** @var \OCP\IUserManager|\PHPUnit_Framework_MockObject_MockObject $userManager */ - $userManager = $this->getMock('\OCP\IUserManager'); + $userManager = $this->createMock(IUserManager::class); /** @var \OCP\IGroupManager|\PHPUnit_Framework_MockObject_MockObject $groupManager */ - $groupManager = $this->getMock('\OCP\IGroupManager'); + $groupManager = $this->createMock(IGroupManager::class); $userManager->expects($this->any()) ->method('userExists') diff --git a/apps/files_external/tests/Command/ListCommandTest.php b/apps/files_external/tests/Command/ListCommandTest.php index 256b35d888..7caf61cf57 100644 --- a/apps/files_external/tests/Command/ListCommandTest.php +++ b/apps/files_external/tests/Command/ListCommandTest.php @@ -29,6 +29,10 @@ use OCA\Files_External\Lib\Auth\Password\Password; use OCA\Files_External\Lib\Auth\Password\SessionCredentials; use OCA\Files_External\Lib\Backend\Local; use OCA\Files_External\Lib\StorageConfig; +use OCP\ISession; +use OCP\IUserManager; +use OCP\IUserSession; +use OCP\Security\ICrypto; use Symfony\Component\Console\Output\BufferedOutput; class ListCommandTest extends CommandTest { @@ -41,17 +45,17 @@ class ListCommandTest extends CommandTest { /** @var \OCA\Files_External\Service\UserStoragesService|\PHPUnit_Framework_MockObject_MockObject $userService */ $userService = $this->getMock('\OCA\Files_External\Service\UserStoragesService', null, [], '', false); /** @var \OCP\IUserManager|\PHPUnit_Framework_MockObject_MockObject $userManager */ - $userManager = $this->getMock('\OCP\IUserManager'); + $userManager = $this->createMock(IUserManager::class); /** @var \OCP\IUserSession|\PHPUnit_Framework_MockObject_MockObject $userSession */ - $userSession = $this->getMock('\OCP\IUserSession'); + $userSession = $this->createMock(IUserSession::class); return new ListCommand($globalService, $userService, $userSession, $userManager); } public function testListAuthIdentifier() { $l10n = $this->getMock('\OC_L10N', null, [], '', false); - $session = $this->getMock('\OCP\ISession'); - $crypto = $this->getMock('\OCP\Security\ICrypto'); + $session = $this->createMock(ISession::class); + $crypto = $this->createMock(ICrypto::class); $instance = $this->getInstance(); $mount1 = new StorageConfig(); $mount1->setAuthMechanism(new Password($l10n)); diff --git a/apps/files_external/tests/Controller/AjaxControllerTest.php b/apps/files_external/tests/Controller/AjaxControllerTest.php index 0fcd89611c..8aba70e0d6 100644 --- a/apps/files_external/tests/Controller/AjaxControllerTest.php +++ b/apps/files_external/tests/Controller/AjaxControllerTest.php @@ -28,6 +28,7 @@ use OCA\Files_External\Lib\Auth\PublicKey\RSA; use OCP\AppFramework\Http\JSONResponse; use OCP\IGroupManager; use OCP\IRequest; +use OCP\IUser; use OCP\IUserSession; use Test\TestCase; @@ -46,15 +47,15 @@ class AjaxControllerTest extends TestCase { private $ajaxController; public function setUp() { - $this->request = $this->getMock('\\OCP\\IRequest'); + $this->request = $this->createMock(IRequest::class); $this->rsa = $this->getMockBuilder('\\OCA\\Files_External\\Lib\\Auth\\PublicKey\\RSA') ->disableOriginalConstructor() ->getMock(); $this->globalAuth = $this->getMockBuilder('\\OCA\\Files_External\\Lib\\Auth\\Password\GlobalAuth') ->disableOriginalConstructor() ->getMock(); - $this->userSession = $this->getMock('\\OCP\\IUserSession'); - $this->groupManager = $this->getMock('\\OCP\\IGroupManager'); + $this->userSession = $this->createMock(IUserSession::class); + $this->groupManager = $this->createMock(IGroupManager::class); $this->ajaxController = new AjaxController( 'files_external', @@ -90,7 +91,7 @@ class AjaxControllerTest extends TestCase { } public function testSaveGlobalCredentialsAsAdminForAnotherUser() { - $user = $this->getMock('\\OCP\\IUser'); + $user = $this->createMock(IUser::class); $user ->expects($this->once()) ->method('getUID') @@ -113,7 +114,7 @@ class AjaxControllerTest extends TestCase { } public function testSaveGlobalCredentialsAsAdminForSelf() { - $user = $this->getMock('\\OCP\\IUser'); + $user = $this->createMock(IUser::class); $user ->expects($this->once()) ->method('getUID') @@ -136,7 +137,7 @@ class AjaxControllerTest extends TestCase { } public function testSaveGlobalCredentialsAsNormalUserForSelf() { - $user = $this->getMock('\\OCP\\IUser'); + $user = $this->createMock(IUser::class); $user ->expects($this->exactly(2)) ->method('getUID') @@ -159,7 +160,7 @@ class AjaxControllerTest extends TestCase { } public function testSaveGlobalCredentialsAsNormalUserForAnotherUser() { - $user = $this->getMock('\\OCP\\IUser'); + $user = $this->createMock(IUser::class); $user ->expects($this->exactly(2)) ->method('getUID') diff --git a/apps/files_external/tests/Controller/GlobalStoragesControllerTest.php b/apps/files_external/tests/Controller/GlobalStoragesControllerTest.php index 627892613e..5c334efdf4 100644 --- a/apps/files_external/tests/Controller/GlobalStoragesControllerTest.php +++ b/apps/files_external/tests/Controller/GlobalStoragesControllerTest.php @@ -27,6 +27,9 @@ namespace OCA\Files_External\Tests\Controller; use OCA\Files_External\Controller\GlobalStoragesController; use \OCP\AppFramework\Http; use \OCA\Files_External\Service\BackendService; +use OCP\IL10N; +use OCP\ILogger; +use OCP\IRequest; class GlobalStoragesControllerTest extends StoragesControllerTest { public function setUp() { @@ -40,10 +43,10 @@ class GlobalStoragesControllerTest extends StoragesControllerTest { $this->controller = new GlobalStoragesController( 'files_external', - $this->getMock('\OCP\IRequest'), - $this->getMock('\OCP\IL10N'), + $this->createMock(IRequest::class), + $this->createMock(IL10N::class), $this->service, - $this->getMock('\OCP\ILogger') + $this->createMock(ILogger::class) ); } } diff --git a/apps/files_external/tests/Controller/UserStoragesControllerTest.php b/apps/files_external/tests/Controller/UserStoragesControllerTest.php index 36182505bf..cdfcbcd140 100644 --- a/apps/files_external/tests/Controller/UserStoragesControllerTest.php +++ b/apps/files_external/tests/Controller/UserStoragesControllerTest.php @@ -28,6 +28,10 @@ use \OCA\Files_External\Controller\UserStoragesController; use OCA\Files_External\Lib\StorageConfig; use \OCP\AppFramework\Http; use \OCA\Files_External\Service\BackendService; +use OCP\IL10N; +use OCP\ILogger; +use OCP\IRequest; +use OCP\IUserSession; class UserStoragesControllerTest extends StoragesControllerTest { @@ -47,11 +51,11 @@ class UserStoragesControllerTest extends StoragesControllerTest { $this->controller = new UserStoragesController( 'files_external', - $this->getMock('\OCP\IRequest'), - $this->getMock('\OCP\IL10N'), + $this->createMock(IRequest::class), + $this->createMock(IL10N::class), $this->service, - $this->getMock('\OCP\IUserSession'), - $this->getMock('\OCP\ILogger') + $this->createMock(IUserSession::class), + $this->createMock(ILogger::class) ); } diff --git a/apps/files_external/tests/Service/BackendServiceTest.php b/apps/files_external/tests/Service/BackendServiceTest.php index efc0a32af5..cbb25579e1 100644 --- a/apps/files_external/tests/Service/BackendServiceTest.php +++ b/apps/files_external/tests/Service/BackendServiceTest.php @@ -21,7 +21,11 @@ */ namespace OCA\Files_External\Tests\Service; +use OCA\Files_External\Lib\Config\IAuthMechanismProvider; +use OCA\Files_External\Lib\Config\IBackendProvider; use \OCA\Files_External\Service\BackendService; +use OCP\IConfig; +use OCP\IL10N; class BackendServiceTest extends \Test\TestCase { @@ -32,8 +36,8 @@ class BackendServiceTest extends \Test\TestCase { protected $l10n; protected function setUp() { - $this->config = $this->getMock('\OCP\IConfig'); - $this->l10n = $this->getMock('\OCP\IL10N'); + $this->config = $this->createMock(IConfig::class); + $this->l10n = $this->createMock(IL10N::class); } /** @@ -97,7 +101,7 @@ class BackendServiceTest extends \Test\TestCase { $backend1 = $this->getBackendMock('\Foo\Bar'); $backend2 = $this->getBackendMock('\Bar\Foo'); - $providerMock = $this->getMock('\OCA\Files_External\Lib\Config\IBackendProvider'); + $providerMock = $this->createMock(IBackendProvider::class); $providerMock->expects($this->once()) ->method('getBackends') ->willReturn([$backend1, $backend2]); @@ -115,7 +119,7 @@ class BackendServiceTest extends \Test\TestCase { $backend1 = $this->getAuthMechanismMock('\Foo\Bar'); $backend2 = $this->getAuthMechanismMock('\Bar\Foo'); - $providerMock = $this->getMock('\OCA\Files_External\Lib\Config\IAuthMechanismProvider'); + $providerMock = $this->createMock(IAuthMechanismProvider::class); $providerMock->expects($this->once()) ->method('getAuthMechanisms') ->willReturn([$backend1, $backend2]); @@ -135,12 +139,12 @@ class BackendServiceTest extends \Test\TestCase { $backend2 = $this->getBackendMock('\Dead\Beef'); - $provider1Mock = $this->getMock('\OCA\Files_External\Lib\Config\IBackendProvider'); + $provider1Mock = $this->createMock(IBackendProvider::class); $provider1Mock->expects($this->once()) ->method('getBackends') ->willReturn([$backend1a, $backend1b]); $service->registerBackendProvider($provider1Mock); - $provider2Mock = $this->getMock('\OCA\Files_External\Lib\Config\IBackendProvider'); + $provider2Mock = $this->createMock(IBackendProvider::class); $provider2Mock->expects($this->once()) ->method('getBackends') ->willReturn([$backend2]); diff --git a/apps/files_external/tests/Service/StoragesServiceTest.php b/apps/files_external/tests/Service/StoragesServiceTest.php index 5dcd93c8ae..2776f24d5a 100644 --- a/apps/files_external/tests/Service/StoragesServiceTest.php +++ b/apps/files_external/tests/Service/StoragesServiceTest.php @@ -31,6 +31,8 @@ use OCA\Files_External\Lib\StorageConfig; use OCA\Files_External\Service\BackendService; use OCA\Files_External\Service\DBConfigService; use OCA\Files_External\Service\StoragesService; +use OCP\AppFramework\IAppContainer; +use OCP\Files\Config\IUserMountCache; class CleaningDBConfig extends DBConfigService { private $mountIds = []; @@ -94,7 +96,7 @@ abstract class StoragesServiceTest extends \Test\TestCase { ); \OC_Mount_Config::$skipTest = true; - $this->mountCache = $this->getMock('OCP\Files\Config\IUserMountCache'); + $this->mountCache = $this->createMock(IUserMountCache::class); // prepare BackendService mock $this->backendService = @@ -150,7 +152,7 @@ abstract class StoragesServiceTest extends \Test\TestCase { Filesystem::signal_delete_mount, get_class($this), 'deleteHookCallback'); - $containerMock = $this->getMock('\OCP\AppFramework\IAppContainer'); + $containerMock = $this->createMock(IAppContainer::class); $containerMock->method('query') ->will($this->returnCallback(function ($name) { if ($name === 'OCA\Files_External\Service\BackendService') { diff --git a/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php b/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php index 6d4aa922c7..72e5dc1514 100644 --- a/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php +++ b/apps/files_external/tests/Service/UserGlobalStoragesServiceTest.php @@ -28,7 +28,9 @@ use OCA\Files_External\Lib\StorageConfig; use OCA\Files_External\NotFoundException; use OCA\Files_External\Service\StoragesService; use OCA\Files_External\Service\UserGlobalStoragesService; +use OCP\IGroupManager; use OCP\IUser; +use OCP\IUserSession; use Test\Traits\UserTrait; /** @@ -63,13 +65,13 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest { $this->user = new \OC\User\User(self::USER_ID, null); /** @var \OCP\IUserSession|\PHPUnit_Framework_MockObject_MockObject $userSession */ - $userSession = $this->getMock('\OCP\IUserSession'); + $userSession = $this->createMock(IUserSession::class); $userSession ->expects($this->any()) ->method('getUser') ->will($this->returnValue($this->user)); - $this->groupManager = $this->getMock('\OCP\IGroupManager'); + $this->groupManager = $this->createMock(IGroupManager::class); $this->groupManager->method('isInGroup') ->will($this->returnCallback(function ($userId, $groupId) { if ($userId === self::USER_ID) { diff --git a/apps/files_external/tests/Service/UserStoragesServiceTest.php b/apps/files_external/tests/Service/UserStoragesServiceTest.php index 85338065c7..3a820f644b 100644 --- a/apps/files_external/tests/Service/UserStoragesServiceTest.php +++ b/apps/files_external/tests/Service/UserStoragesServiceTest.php @@ -30,6 +30,7 @@ use OCA\Files_External\Service\GlobalStoragesService; use OCA\Files_External\Service\StoragesService; use OCA\Files_External\Service\UserStoragesService; use OCA\Files_External\Lib\StorageConfig; +use OCP\IUserSession; use Test\Traits\UserTrait; /** @@ -57,7 +58,7 @@ class UserStoragesServiceTest extends StoragesServiceTest { $this->user = \OC::$server->getUserManager()->get($this->userId); /** @var \OCP\IUserSession|\PHPUnit_Framework_MockObject_MockObject $userSession */ - $userSession = $this->getMock('\OCP\IUserSession'); + $userSession = $this->createMock(IUserSession::class); $userSession ->expects($this->any()) ->method('getUser')