summaryrefslogtreecommitdiffstats
path: root/apps/files_external/tests
diff options
context:
space:
mode:
authorRobin Appelman <icewind@owncloud.com>2016-02-04 16:14:17 +0100
committerRobin Appelman <icewind@owncloud.com>2016-02-04 16:14:17 +0100
commit76d9586339d59f7e2aaa2aecce45df7e324e8532 (patch)
tree1378b487fccb8e871f6688ca564b4ea616ff10d4 /apps/files_external/tests
parent71992f9d29c61c867b79d51b74e24113a8a72750 (diff)
downloadnextcloud-server-76d9586339d59f7e2aaa2aecce45df7e324e8532.tar.gz
nextcloud-server-76d9586339d59f7e2aaa2aecce45df7e324e8532.zip
add tests
Diffstat (limited to 'apps/files_external/tests')
-rw-r--r--apps/files_external/tests/command/listcommandtest.php69
1 files changed, 69 insertions, 0 deletions
diff --git a/apps/files_external/tests/command/listcommandtest.php b/apps/files_external/tests/command/listcommandtest.php
new file mode 100644
index 00000000000..338ddb7593e
--- /dev/null
+++ b/apps/files_external/tests/command/listcommandtest.php
@@ -0,0 +1,69 @@
+<?php
+/**
+ * @author Robin Appelman <icewind@owncloud.com>
+ *
+ * @copyright Copyright (c) 2016, ownCloud, Inc.
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see <http://www.gnu.org/licenses/>
+ *
+ */
+
+namespace OCA\Files_External\Tests\Command;
+
+use OCA\Files_External\Command\ListCommand;
+use OCA\Files_External\Lib\Auth\NullMechanism;
+use OCA\Files_External\Lib\Auth\Password\Password;
+use OCA\Files_External\Lib\Auth\Password\UserProvided;
+use OCA\Files_External\Lib\Backend\Local;
+use OCA\Files_external\Lib\StorageConfig;
+use Symfony\Component\Console\Output\BufferedOutput;
+
+class ListCommandTest extends CommandTest {
+ /**
+ * @return \OCA\Files_External\Command\ListCommand|\PHPUnit_Framework_MockObject_MockObject
+ */
+ private function getInstance() {
+ /** @var \OCA\Files_external\Service\GlobalStoragesService|\PHPUnit_Framework_MockObject_MockObject $globalService */
+ $globalService = $this->getMock('\OCA\Files_external\Service\GlobalStoragesService', null, [], '', false);
+ /** @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');
+ /** @var \OCP\IUserSession|\PHPUnit_Framework_MockObject_MockObject $userSession */
+ $userSession = $this->getMock('\OCP\IUserSession');
+
+ return new ListCommand($globalService, $userService, $userSession, $userManager);
+ }
+
+ public function testListAuthIdentifier() {
+ $l10n = $this->getMock('\OC_L10N', null, [], '', false);
+ $credentialsManager = $this->getMock('\OCP\Security\ICredentialsManager');
+ $instance = $this->getInstance();
+ $mount1 = new StorageConfig();
+ $mount1->setAuthMechanism(new Password($l10n));
+ $mount1->setBackend(new Local($l10n, new NullMechanism($l10n)));
+ $mount2 = new StorageConfig();
+ $mount2->setAuthMechanism(new UserProvided($l10n, $credentialsManager));
+ $mount2->setBackend(new Local($l10n, new NullMechanism($l10n)));
+ $input = $this->getInput($instance, [], [
+ 'output' => 'json'
+ ]);
+ $output = new BufferedOutput();
+
+ $instance->listMounts('', [$mount1, $mount2], $input, $output);
+ $output = json_decode($output->fetch(), true);
+
+ $this->assertNotEquals($output[0]['authentication_type'], $output[1]['authentication_type']);
+ }
+}