aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_external/tests/Command
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files_external/tests/Command')
-rw-r--r--apps/files_external/tests/Command/ApplicableTest.php49
-rw-r--r--apps/files_external/tests/Command/CommandTestCase.php (renamed from apps/files_external/tests/Command/CommandTest.php)43
-rw-r--r--apps/files_external/tests/Command/ListCommandTest.php50
3 files changed, 43 insertions, 99 deletions
diff --git a/apps/files_external/tests/Command/ApplicableTest.php b/apps/files_external/tests/Command/ApplicableTest.php
index fb4326354fa..59db18a42de 100644
--- a/apps/files_external/tests/Command/ApplicableTest.php
+++ b/apps/files_external/tests/Command/ApplicableTest.php
@@ -1,38 +1,23 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @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/>
- *
+ * SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Tests\Command;
use OCA\Files_External\Command\Applicable;
use OCP\IGroupManager;
use OCP\IUserManager;
+use PHPUnit\Framework\MockObject\MockObject;
-class ApplicableTest extends CommandTest {
- private function getInstance($storageService) {
- /** @var \OCP\IUserManager|\PHPUnit\Framework\MockObject\MockObject $userManager */
+class ApplicableTest extends CommandTestCase {
+ private function getInstance($storageService): Applicable {
+ /** @var IUserManager&MockObject $userManager */
$userManager = $this->createMock(IUserManager::class);
- /** @var \OCP\IGroupManager|\PHPUnit\Framework\MockObject\MockObject $groupManager */
+ /** @var IGroupManager&MockObject $groupManager */
$groupManager = $this->createMock(IGroupManager::class);
$userManager->expects($this->any())
@@ -46,7 +31,7 @@ class ApplicableTest extends CommandTest {
return new Applicable($storageService, $userManager, $groupManager);
}
- public function testListEmpty() {
+ public function testListEmpty(): void {
$mount = $this->getMount(1, '', '');
$storageService = $this->getGlobalStorageService([$mount]);
@@ -63,7 +48,7 @@ class ApplicableTest extends CommandTest {
$this->assertEquals(['users' => [], 'groups' => []], $result);
}
- public function testList() {
+ public function testList(): void {
$mount = $this->getMount(1, '', '', '', [], [], ['test', 'asd']);
$storageService = $this->getGlobalStorageService([$mount]);
@@ -80,7 +65,7 @@ class ApplicableTest extends CommandTest {
$this->assertEquals(['users' => ['test', 'asd'], 'groups' => []], $result);
}
- public function testAddSingle() {
+ public function testAddSingle(): void {
$mount = $this->getMount(1, '', '', '', [], [], []);
$storageService = $this->getGlobalStorageService([$mount]);
@@ -98,7 +83,7 @@ class ApplicableTest extends CommandTest {
$this->assertEquals(['foo'], $mount->getApplicableUsers());
}
- public function testAddDuplicate() {
+ public function testAddDuplicate(): void {
$mount = $this->getMount(1, '', '', '', [], [], ['foo']);
$storageService = $this->getGlobalStorageService([$mount]);
@@ -116,7 +101,7 @@ class ApplicableTest extends CommandTest {
$this->assertEquals(['foo', 'bar'], $mount->getApplicableUsers());
}
- public function testRemoveSingle() {
+ public function testRemoveSingle(): void {
$mount = $this->getMount(1, '', '', '', [], [], ['foo', 'bar']);
$storageService = $this->getGlobalStorageService([$mount]);
@@ -134,7 +119,7 @@ class ApplicableTest extends CommandTest {
$this->assertEquals(['foo'], $mount->getApplicableUsers());
}
- public function testRemoveNonExisting() {
+ public function testRemoveNonExisting(): void {
$mount = $this->getMount(1, '', '', '', [], [], ['foo', 'bar']);
$storageService = $this->getGlobalStorageService([$mount]);
@@ -152,7 +137,7 @@ class ApplicableTest extends CommandTest {
$this->assertEquals(['foo'], $mount->getApplicableUsers());
}
- public function testRemoveAddRemove() {
+ public function testRemoveAddRemove(): void {
$mount = $this->getMount(1, '', '', '', [], [], ['foo', 'bar']);
$storageService = $this->getGlobalStorageService([$mount]);
diff --git a/apps/files_external/tests/Command/CommandTest.php b/apps/files_external/tests/Command/CommandTestCase.php
index 952ca2a0307..e42ad9cd68a 100644
--- a/apps/files_external/tests/Command/CommandTest.php
+++ b/apps/files_external/tests/Command/CommandTestCase.php
@@ -1,46 +1,29 @@
<?php
+
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <robin@icewind.nl>
- *
- * @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/>
- *
+ * SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Tests\Command;
use OCA\Files_External\Lib\StorageConfig;
use OCA\Files_External\NotFoundException;
+use OCA\Files_External\Service\GlobalStoragesService;
+use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\Input;
use Symfony\Component\Console\Output\BufferedOutput;
use Test\TestCase;
-abstract class CommandTest extends TestCase {
+abstract class CommandTestCase extends TestCase {
/**
* @param StorageConfig[] $mounts
- * @return \OCA\Files_External\Service\GlobalStoragesService|\PHPUnit\Framework\MockObject\MockObject
+ * @return GlobalStoragesService&MockObject
*/
protected function getGlobalStorageService(array $mounts = []) {
- $mock = $this->getMockBuilder('OCA\Files_External\Service\GlobalStoragesService')
- ->disableOriginalConstructor()
- ->getMock();
+ $mock = $this->createMock(GlobalStoragesService::class);
$this->bindMounts($mock, $mounts);
@@ -48,10 +31,10 @@ abstract class CommandTest extends TestCase {
}
/**
- * @param \PHPUnit\Framework\MockObject\MockObject $mock
+ * @param MockObject $mock
* @param StorageConfig[] $mounts
*/
- protected function bindMounts(\PHPUnit\Framework\MockObject\MockObject $mock, array $mounts) {
+ protected function bindMounts(MockObject $mock, array $mounts) {
$mock->expects($this->any())
->method('getStorage')
->willReturnCallback(function ($id) use ($mounts) {
@@ -87,7 +70,7 @@ abstract class CommandTest extends TestCase {
return $mount;
}
- protected function getInput(Command $command, array $arguments = [], array $options = []) {
+ protected function getInput(Command $command, array $arguments = [], array $options = []): ArrayInput {
$input = new ArrayInput([]);
$input->bind($command->getDefinition());
foreach ($arguments as $key => $value) {
@@ -99,7 +82,7 @@ abstract class CommandTest extends TestCase {
return $input;
}
- protected function executeCommand(Command $command, Input $input) {
+ protected function executeCommand(Command $command, Input $input): string {
$output = new BufferedOutput();
$this->invokePrivate($command, 'execute', [$input, $output]);
return $output->fetch();
diff --git a/apps/files_external/tests/Command/ListCommandTest.php b/apps/files_external/tests/Command/ListCommandTest.php
index e9cd3496d71..5b84e500e3f 100644
--- a/apps/files_external/tests/Command/ListCommandTest.php
+++ b/apps/files_external/tests/Command/ListCommandTest.php
@@ -1,28 +1,10 @@
<?php
+
+declare(strict_types=1);
/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- * @author Joas Schilling <coding@schilljs.com>
- * @author Lukas Reschke <lukas@statuscode.ch>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Robin Appelman <robin@icewind.nl>
- * @author Roeland Jago Douma <roeland@famdouma.nl>
- *
- * @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/>
- *
+ * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
+ * SPDX-License-Identifier: AGPL-3.0-only
*/
namespace OCA\Files_External\Tests\Command;
@@ -36,33 +18,27 @@ use OCA\Files_External\Service\GlobalStoragesService;
use OCA\Files_External\Service\UserStoragesService;
use OCP\Authentication\LoginCredentials\IStore;
use OCP\IL10N;
-use OCP\ISession;
use OCP\IUserManager;
use OCP\IUserSession;
-use OCP\Security\ICrypto;
+use PHPUnit\Framework\MockObject\MockObject;
use Symfony\Component\Console\Output\BufferedOutput;
-class ListCommandTest extends CommandTest {
- /**
- * @return ListCommand|\PHPUnit\Framework\MockObject\MockObject
- */
- private function getInstance() {
- /** @var GlobalStoragesService|\PHPUnit\Framework\MockObject\MockObject $globalService */
+class ListCommandTest extends CommandTestCase {
+ private function getInstance(): ListCommand {
+ /** @var GlobalStoragesService&MockObject $globalService */
$globalService = $this->createMock(GlobalStoragesService::class);
- /** @var UserStoragesService|\PHPUnit\Framework\MockObject\MockObject $userService */
+ /** @var UserStoragesService&MockObject $userService */
$userService = $this->createMock(UserStoragesService::class);
- /** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject $userManager */
+ /** @var IUserManager&MockObject $userManager */
$userManager = $this->createMock(IUserManager::class);
- /** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject $userSession */
+ /** @var IUserSession&MockObject $userSession */
$userSession = $this->createMock(IUserSession::class);
return new ListCommand($globalService, $userService, $userSession, $userManager);
}
- public function testListAuthIdentifier() {
+ public function testListAuthIdentifier(): void {
$l10n = $this->createMock(IL10N::class);
- $session = $this->createMock(ISession::class);
- $crypto = $this->createMock(ICrypto::class);
$instance = $this->getInstance();
$mount1 = new StorageConfig();
$mount1->setAuthMechanism(new Password($l10n));