diff options
author | Morris Jobke <hey@morrisjobke.de> | 2017-10-24 15:26:53 +0200 |
---|---|---|
committer | Morris Jobke <hey@morrisjobke.de> | 2017-10-24 17:45:32 +0200 |
commit | 43e498844e8c1aa519a19238d2cf3d6b95e1aab0 (patch) | |
tree | 59510ef2ffc6c1fd1fd92475013b108f1da2bfeb /apps/files_external | |
parent | b1f77aca4effec99387481a831910d4870ae2ffc (diff) | |
download | nextcloud-server-43e498844e8c1aa519a19238d2cf3d6b95e1aab0.tar.gz nextcloud-server-43e498844e8c1aa519a19238d2cf3d6b95e1aab0.zip |
Use ::class in test mocks
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'apps/files_external')
8 files changed, 43 insertions, 26 deletions
diff --git a/apps/files_external/tests/Auth/AuthMechanismTest.php b/apps/files_external/tests/Auth/AuthMechanismTest.php index 5d635a5036a..11eee7b8824 100644 --- a/apps/files_external/tests/Auth/AuthMechanismTest.php +++ b/apps/files_external/tests/Auth/AuthMechanismTest.php @@ -22,10 +22,14 @@ namespace OCA\Files_External\Tests\Auth; +use OCA\Files_External\Lib\Auth\AuthMechanism; +use OCA\Files_External\Lib\Backend\Backend; +use OCA\Files_External\Lib\StorageConfig; + class AuthMechanismTest extends \Test\TestCase { public function testJsonSerialization() { - $mechanism = $this->getMockBuilder('\OCA\Files_External\Lib\Auth\AuthMechanism') + $mechanism = $this->getMockBuilder(AuthMechanism::class) ->setMethods(['jsonSerializeDefinition']) ->getMock(); $mechanism->expects($this->once()) @@ -52,7 +56,7 @@ class AuthMechanismTest extends \Test\TestCase { * @dataProvider validateStorageProvider */ public function testValidateStorage($expectedSuccess, $scheme, $definitionSuccess) { - $mechanism = $this->getMockBuilder('\OCA\Files_External\Lib\Auth\AuthMechanism') + $mechanism = $this->getMockBuilder(AuthMechanism::class) ->setMethods(['validateStorageDefinition']) ->getMock(); $mechanism->expects($this->atMost(1)) @@ -61,14 +65,14 @@ class AuthMechanismTest extends \Test\TestCase { $mechanism->setScheme($scheme); - $backend = $this->getMockBuilder('\OCA\Files_External\Lib\Backend\Backend') + $backend = $this->getMockBuilder(Backend::class) ->disableOriginalConstructor() ->getMock(); $backend->expects($this->once()) ->method('getAuthSchemes') ->willReturn(['scheme' => true, 'foobar' => true]); - $storageConfig = $this->getMockBuilder('\OCA\Files_External\Lib\StorageConfig') + $storageConfig = $this->getMockBuilder(StorageConfig::class) ->disableOriginalConstructor() ->getMock(); $storageConfig->expects($this->once()) diff --git a/apps/files_external/tests/Backend/BackendTest.php b/apps/files_external/tests/Backend/BackendTest.php index 762b9f4c0e8..1a1c386240a 100644 --- a/apps/files_external/tests/Backend/BackendTest.php +++ b/apps/files_external/tests/Backend/BackendTest.php @@ -23,11 +23,12 @@ namespace OCA\Files_External\Tests\Backend; use \OCA\Files_External\Lib\Backend\Backend; +use OCA\Files_External\Lib\StorageConfig; class BackendTest extends \Test\TestCase { public function testJsonSerialization() { - $backend = $this->getMockBuilder('\OCA\Files_External\Lib\Backend\Backend') + $backend = $this->getMockBuilder(Backend::class) ->setMethods(['jsonSerializeDefinition']) ->getMock(); $backend->expects($this->once()) @@ -59,14 +60,14 @@ class BackendTest extends \Test\TestCase { * @dataProvider validateStorageProvider */ public function testValidateStorage($expectedSuccess, $definitionSuccess) { - $backend = $this->getMockBuilder('\OCA\Files_External\Lib\Backend\Backend') + $backend = $this->getMockBuilder(Backend::class) ->setMethods(['validateStorageDefinition']) ->getMock(); $backend->expects($this->atMost(1)) ->method('validateStorageDefinition') ->willReturn($definitionSuccess); - $storageConfig = $this->getMockBuilder('\OCA\Files_External\Lib\StorageConfig') + $storageConfig = $this->getMockBuilder(StorageConfig::class) ->disableOriginalConstructor() ->getMock(); diff --git a/apps/files_external/tests/Controller/StoragesControllerTest.php b/apps/files_external/tests/Controller/StoragesControllerTest.php index 35a055e6be5..f854b25676c 100644 --- a/apps/files_external/tests/Controller/StoragesControllerTest.php +++ b/apps/files_external/tests/Controller/StoragesControllerTest.php @@ -23,6 +23,8 @@ */ namespace OCA\Files_External\Tests\Controller; +use OCA\Files_External\Lib\Auth\AuthMechanism; +use OCA\Files_External\Lib\Backend\Backend; use \OCP\AppFramework\Http; use \OCA\Files_External\Controller\GlobalStoragesController; @@ -54,7 +56,7 @@ abstract class StoragesControllerTest extends \Test\TestCase { * @return \OCA\Files_External\Lib\Backend\Backend */ protected function getBackendMock($class = '\OCA\Files_External\Lib\Backend\SMB', $storageClass = '\OCA\Files_External\Lib\Storage\SMB') { - $backend = $this->getMockBuilder('\OCA\Files_External\Lib\Backend\Backend') + $backend = $this->getMockBuilder(Backend::class) ->disableOriginalConstructor() ->getMock(); $backend->method('getStorageClass') @@ -68,7 +70,7 @@ abstract class StoragesControllerTest extends \Test\TestCase { * @return \OCA\Files_External\Lib\Auth\AuthMechanism */ protected function getAuthMechMock($scheme = 'null', $class = '\OCA\Files_External\Lib\Auth\NullMechanism') { - $authMech = $this->getMockBuilder('\OCA\Files_External\Lib\Auth\AuthMechanism') + $authMech = $this->getMockBuilder(AuthMechanism::class) ->disableOriginalConstructor() ->getMock(); $authMech->method('getScheme') diff --git a/apps/files_external/tests/FrontendDefinitionTraitTest.php b/apps/files_external/tests/FrontendDefinitionTraitTest.php index 7efc7c66586..4154ac6092c 100644 --- a/apps/files_external/tests/FrontendDefinitionTraitTest.php +++ b/apps/files_external/tests/FrontendDefinitionTraitTest.php @@ -23,10 +23,13 @@ namespace OCA\Files_External\Tests; +use OCA\Files_External\Lib\DefinitionParameter; +use OCA\Files_External\Lib\StorageConfig; + class FrontendDefinitionTraitTest extends \Test\TestCase { public function testJsonSerialization() { - $param = $this->getMockBuilder('\OCA\Files_External\Lib\DefinitionParameter') + $param = $this->getMockBuilder(DefinitionParameter::class) ->disableOriginalConstructor() ->getMock(); $param->method('getName')->willReturn('foo'); @@ -60,7 +63,7 @@ class FrontendDefinitionTraitTest extends \Test\TestCase { public function testValidateStorage($expectedSuccess, $params) { $backendParams = []; foreach ($params as $name => $valid) { - $param = $this->getMockBuilder('\OCA\Files_External\Lib\DefinitionParameter') + $param = $this->getMockBuilder(DefinitionParameter::class) ->disableOriginalConstructor() ->getMock(); $param->method('getName') @@ -73,7 +76,7 @@ class FrontendDefinitionTraitTest extends \Test\TestCase { $backendParams[] = $param; } - $storageConfig = $this->getMockBuilder('\OCA\Files_External\Lib\StorageConfig') + $storageConfig = $this->getMockBuilder(StorageConfig::class) ->disableOriginalConstructor() ->getMock(); $storageConfig->expects($this->any()) @@ -90,7 +93,7 @@ class FrontendDefinitionTraitTest extends \Test\TestCase { } public function testValidateStorageSet() { - $param = $this->getMockBuilder('\OCA\Files_External\Lib\DefinitionParameter') + $param = $this->getMockBuilder(DefinitionParameter::class) ->disableOriginalConstructor() ->getMock(); $param->method('getName') @@ -102,7 +105,7 @@ class FrontendDefinitionTraitTest extends \Test\TestCase { return true; })); - $storageConfig = $this->getMockBuilder('\OCA\Files_External\Lib\StorageConfig') + $storageConfig = $this->getMockBuilder(StorageConfig::class) ->disableOriginalConstructor() ->getMock(); $storageConfig->expects($this->once()) diff --git a/apps/files_external/tests/Service/BackendServiceTest.php b/apps/files_external/tests/Service/BackendServiceTest.php index cbb25579e11..6916d47a02a 100644 --- a/apps/files_external/tests/Service/BackendServiceTest.php +++ b/apps/files_external/tests/Service/BackendServiceTest.php @@ -21,6 +21,8 @@ */ namespace OCA\Files_External\Tests\Service; +use OCA\Files_External\Lib\Auth\AuthMechanism; +use OCA\Files_External\Lib\Backend\Backend; use OCA\Files_External\Lib\Config\IAuthMechanismProvider; use OCA\Files_External\Lib\Config\IBackendProvider; use \OCA\Files_External\Service\BackendService; @@ -46,7 +48,7 @@ class BackendServiceTest extends \Test\TestCase { * @return \OCA\Files_External\Lib\Backend\Backend */ protected function getBackendMock($class) { - $backend = $this->getMockBuilder('\OCA\Files_External\Lib\Backend\Backend') + $backend = $this->getMockBuilder(Backend::class) ->disableOriginalConstructor() ->getMock(); $backend->method('getIdentifier')->will($this->returnValue('identifier:'.$class)); @@ -60,7 +62,7 @@ class BackendServiceTest extends \Test\TestCase { * @return \OCA\Files_External\Lib\Auth\AuthMechanism */ protected function getAuthMechanismMock($class) { - $backend = $this->getMockBuilder('\OCA\Files_External\Lib\Auth\AuthMechanism') + $backend = $this->getMockBuilder(AuthMechanism::class) ->disableOriginalConstructor() ->getMock(); $backend->method('getIdentifier')->will($this->returnValue('identifier:'.$class)); @@ -73,7 +75,7 @@ class BackendServiceTest extends \Test\TestCase { $backend = $this->getBackendMock('\Foo\Bar'); - $backendAlias = $this->getMockBuilder('\OCA\Files_External\Lib\Backend\Backend') + $backendAlias = $this->getMockBuilder(Backend::class) ->disableOriginalConstructor() ->getMock(); $backendAlias->method('getIdentifierAliases') @@ -175,7 +177,7 @@ class BackendServiceTest extends \Test\TestCase { ->method('removeVisibility') ->with(BackendService::VISIBILITY_PERSONAL); - $backendAlias = $this->getMockBuilder('\OCA\Files_External\Lib\Backend\Backend') + $backendAlias = $this->getMockBuilder(Backend::class) ->disableOriginalConstructor() ->getMock(); $backendAlias->method('getIdentifierAliases') diff --git a/apps/files_external/tests/Service/StoragesServiceTest.php b/apps/files_external/tests/Service/StoragesServiceTest.php index 056a03d24c8..22409ea9dbd 100644 --- a/apps/files_external/tests/Service/StoragesServiceTest.php +++ b/apps/files_external/tests/Service/StoragesServiceTest.php @@ -27,7 +27,9 @@ namespace OCA\Files_External\Tests\Service; use \OC\Files\Filesystem; +use OCA\Files_External\Lib\Auth\AuthMechanism; use OCA\Files_External\Lib\Auth\InvalidAuth; +use OCA\Files_External\Lib\Backend\Backend; use OCA\Files_External\Lib\Backend\InvalidBackend; use OCA\Files_External\NotFoundException; use OCA\Files_External\Lib\StorageConfig; @@ -179,7 +181,7 @@ abstract class StoragesServiceTest extends \Test\TestCase { } protected function getBackendMock($class = '\OCA\Files_External\Lib\Backend\SMB', $storageClass = '\OCA\Files_External\Lib\Storage\SMB') { - $backend = $this->getMockBuilder('\OCA\Files_External\Lib\Backend\Backend') + $backend = $this->getMockBuilder(Backend::class) ->disableOriginalConstructor() ->getMock(); $backend->method('getStorageClass') @@ -190,7 +192,7 @@ abstract class StoragesServiceTest extends \Test\TestCase { } protected function getAuthMechMock($scheme = 'null', $class = '\OCA\Files_External\Lib\Auth\NullMechanism') { - $authMech = $this->getMockBuilder('\OCA\Files_External\Lib\Auth\AuthMechanism') + $authMech = $this->getMockBuilder(AuthMechanism::class) ->disableOriginalConstructor() ->getMock(); $authMech->method('getScheme') @@ -204,7 +206,7 @@ abstract class StoragesServiceTest extends \Test\TestCase { /** * Creates a StorageConfig instance based on array data * - * @param array data + * @param array $data * * @return StorageConfig storage config instance */ diff --git a/apps/files_external/tests/Settings/SectionTest.php b/apps/files_external/tests/Settings/SectionTest.php index ee501b1270b..93aee61b47d 100644 --- a/apps/files_external/tests/Settings/SectionTest.php +++ b/apps/files_external/tests/Settings/SectionTest.php @@ -38,8 +38,8 @@ class SectionTest extends TestCase { public function setUp() { parent::setUp(); - $this->urlGenerator = $this->getMockBuilder('\OCP\IURLGenerator')->disableOriginalConstructor()->getMock(); - $this->l = $this->getMockBuilder('\OCP\IL10N')->disableOriginalConstructor()->getMock(); + $this->urlGenerator = $this->getMockBuilder(IURLGenerator::class)->disableOriginalConstructor()->getMock(); + $this->l = $this->getMockBuilder(IL10N::class)->disableOriginalConstructor()->getMock(); $this->section = new Section( $this->urlGenerator, diff --git a/apps/files_external/tests/StorageConfigTest.php b/apps/files_external/tests/StorageConfigTest.php index 96d4fda5050..f357c0c6990 100644 --- a/apps/files_external/tests/StorageConfigTest.php +++ b/apps/files_external/tests/StorageConfigTest.php @@ -25,15 +25,18 @@ namespace OCA\Files_External\Tests; +use OCA\Files_External\Lib\Auth\AuthMechanism; +use OCA\Files_External\Lib\Backend\Backend; +use OCA\Files_External\Lib\DefinitionParameter; use OCA\Files_External\Lib\StorageConfig; class StorageConfigTest extends \Test\TestCase { public function testJsonSerialization() { - $backend = $this->getMockBuilder('\OCA\Files_External\Lib\Backend\Backend') + $backend = $this->getMockBuilder(Backend::class) ->disableOriginalConstructor() ->getMock(); - $parameter = $this->getMockBuilder('\OCA\Files_External\Lib\DefinitionParameter') + $parameter = $this->getMockBuilder(DefinitionParameter::class) ->disableOriginalConstructor() ->getMock(); $parameter @@ -47,7 +50,7 @@ class StorageConfigTest extends \Test\TestCase { $backend->method('getIdentifier') ->willReturn('storage::identifier'); - $authMech = $this->getMockBuilder('\OCA\Files_External\Lib\Auth\AuthMechanism') + $authMech = $this->getMockBuilder(AuthMechanism::class) ->disableOriginalConstructor() ->getMock(); $authMech->method('getIdentifier') |