diff options
author | Robin McCorkell <rmccorkell@owncloud.com> | 2015-09-01 10:25:33 +0100 |
---|---|---|
committer | Robin McCorkell <rmccorkell@owncloud.com> | 2015-09-01 10:25:33 +0100 |
commit | cd506f210de329853e6df625fd8c36d13f333dce (patch) | |
tree | 5a3fbbf5a9dd2baed9c0a231856c1fd0cb2f391e /apps/files_external/tests | |
parent | 85b62c7d82695dd4cd1c73e7c1d81269ec17170b (diff) | |
download | nextcloud-server-cd506f210de329853e6df625fd8c36d13f333dce.tar.gz nextcloud-server-cd506f210de329853e6df625fd8c36d13f333dce.zip |
Make checkDependencies a real method
Replace ->setDependencyCheck(callable) with a real method
checkDependencies(). A polyfill is available for legacy storages.
Diffstat (limited to 'apps/files_external/tests')
-rw-r--r-- | apps/files_external/tests/backend/legacybackendtest.php | 20 | ||||
-rw-r--r-- | apps/files_external/tests/legacydependencycheckpolyfilltest.php (renamed from apps/files_external/tests/dependencytraittest.php) | 23 |
2 files changed, 32 insertions, 11 deletions
diff --git a/apps/files_external/tests/backend/legacybackendtest.php b/apps/files_external/tests/backend/legacybackendtest.php index 44cb16a4986..4db8ac5d8df 100644 --- a/apps/files_external/tests/backend/legacybackendtest.php +++ b/apps/files_external/tests/backend/legacybackendtest.php @@ -23,15 +23,25 @@ namespace OCA\Files_External\Tests\Backend; use \OCA\Files_External\Lib\Backend\LegacyBackend; use \OCA\Files_External\Lib\DefinitionParameter; +use \OCA\Files_External\Lib\MissingDependency; class LegacyBackendTest extends \Test\TestCase { + /** + * @return MissingDependency[] + */ + public static function checkDependencies() { + return [ + (new MissingDependency('abc'))->setMessage('foobar') + ]; + } + public function testConstructor() { $auth = $this->getMockBuilder('\OCA\Files_External\Lib\Auth\Builtin') ->disableOriginalConstructor() ->getMock(); - $class = '\OC\Files\Storage\SMB'; + $class = '\OCA\Files_External\Tests\Backend\LegacyBackendTest'; $definition = [ 'configuration' => [ 'textfield' => 'Text field', @@ -49,14 +59,18 @@ class LegacyBackendTest extends \Test\TestCase { $backend = new LegacyBackend($class, $definition, $auth); - $this->assertEquals('\OC\Files\Storage\SMB', $backend->getStorageClass()); + $this->assertEquals('\OCA\Files_External\Tests\Backend\LegacyBackendTest', $backend->getStorageClass()); $this->assertEquals('Backend text', $backend->getText()); $this->assertEquals(123, $backend->getPriority()); $this->assertEquals('foo/bar.js', $backend->getCustomJs()); - $this->assertEquals(true, $backend->hasDependencies()); $this->assertArrayHasKey('builtin', $backend->getAuthSchemes()); $this->assertEquals($auth, $backend->getLegacyAuthMechanism()); + $dependencies = $backend->checkDependencies(); + $this->assertCount(1, $dependencies); + $this->assertEquals('abc', $dependencies[0]->getDependency()); + $this->assertEquals('foobar', $dependencies[0]->getMessage()); + $parameters = $backend->getParameters(); $this->assertEquals('Text field', $parameters['textfield']->getText()); $this->assertEquals(DefinitionParameter::VALUE_TEXT, $parameters['textfield']->getType()); diff --git a/apps/files_external/tests/dependencytraittest.php b/apps/files_external/tests/legacydependencycheckpolyfilltest.php index 5706d97053d..49d825d77aa 100644 --- a/apps/files_external/tests/dependencytraittest.php +++ b/apps/files_external/tests/legacydependencycheckpolyfilltest.php @@ -23,16 +23,23 @@ namespace OCA\Files_External\Tests; use \OCA\Files_External\Lib\MissingDependency; -class DependencyTraitTest extends \Test\TestCase { +class LegacyDependencyCheckPolyfillTest extends \Test\TestCase { + + /** + * @return MissingDependency[] + */ + public static function checkDependencies() { + return [ + (new MissingDependency('dependency'))->setMessage('missing dependency'), + (new MissingDependency('program'))->setMessage('cannot find program'), + ]; + } public function testCheckDependencies() { - $trait = $this->getMockForTrait('\OCA\Files_External\Lib\DependencyTrait'); - $trait->setDependencyCheck(function() { - return [ - (new MissingDependency('dependency'))->setMessage('missing dependency'), - (new MissingDependency('program'))->setMessage('cannot find program'), - ]; - }); + $trait = $this->getMockForTrait('\OCA\Files_External\Lib\LegacyDependencyCheckPolyfill'); + $trait->expects($this->once()) + ->method('getStorageClass') + ->willReturn('\OCA\Files_External\Tests\LegacyDependencyCheckPolyfillTest'); $dependencies = $trait->checkDependencies(); $this->assertCount(2, $dependencies); |