diff options
Diffstat (limited to 'apps/files_external/tests/backend/legacybackendtest.php')
-rw-r--r-- | apps/files_external/tests/backend/legacybackendtest.php | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/apps/files_external/tests/backend/legacybackendtest.php b/apps/files_external/tests/backend/legacybackendtest.php index 44cb16a4986..d57810de29b 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()); @@ -78,4 +92,22 @@ class LegacyBackendTest extends \Test\TestCase { $this->assertEquals(DefinitionParameter::FLAG_OPTIONAL, $parameters['optionalpassword']->getFlags()); } + public function testNoDependencies() { + $auth = $this->getMockBuilder('\OCA\Files_External\Lib\Auth\Builtin') + ->disableOriginalConstructor() + ->getMock(); + + $class = '\OCA\Files_External\Tests\Backend\LegacyBackendTest'; + $definition = [ + 'configuration' => [ + ], + 'backend' => 'Backend text', + ]; + + $backend = new LegacyBackend($class, $definition, $auth); + + $dependencies = $backend->checkDependencies(); + $this->assertCount(0, $dependencies); + } + } |