mirror of
https://github.com/nextcloud/server.git
synced 2026-06-08 16:26:59 -04:00
test: Prepare files_external for PHPUnit10
Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
parent
68b2a6261d
commit
2e0eef00ab
36 changed files with 270 additions and 345 deletions
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
|
|
@ -13,7 +15,7 @@ use OCA\Files_External\Lib\StorageConfig;
|
|||
class AuthMechanismTest extends \Test\TestCase {
|
||||
public function testJsonSerialization(): void {
|
||||
$mechanism = $this->getMockBuilder(AuthMechanism::class)
|
||||
->setMethods(['jsonSerializeDefinition'])
|
||||
->onlyMethods(['jsonSerializeDefinition'])
|
||||
->getMock();
|
||||
$mechanism->expects($this->once())
|
||||
->method('jsonSerializeDefinition')
|
||||
|
|
@ -26,7 +28,7 @@ class AuthMechanismTest extends \Test\TestCase {
|
|||
$this->assertEquals('scheme', $json['scheme']);
|
||||
}
|
||||
|
||||
public function validateStorageProvider() {
|
||||
public static function validateStorageProvider(): array {
|
||||
return [
|
||||
[true, 'scheme', true],
|
||||
[false, 'scheme', false],
|
||||
|
|
@ -38,9 +40,9 @@ class AuthMechanismTest extends \Test\TestCase {
|
|||
/**
|
||||
* @dataProvider validateStorageProvider
|
||||
*/
|
||||
public function testValidateStorage($expectedSuccess, $scheme, $definitionSuccess): void {
|
||||
public function testValidateStorage(bool $expectedSuccess, string $scheme, bool $definitionSuccess): void {
|
||||
$mechanism = $this->getMockBuilder(AuthMechanism::class)
|
||||
->setMethods(['validateStorageDefinition'])
|
||||
->onlyMethods(['validateStorageDefinition'])
|
||||
->getMock();
|
||||
$mechanism->expects($this->atMost(1))
|
||||
->method('validateStorageDefinition')
|
||||
|
|
@ -48,16 +50,12 @@ class AuthMechanismTest extends \Test\TestCase {
|
|||
|
||||
$mechanism->setScheme($scheme);
|
||||
|
||||
$backend = $this->getMockBuilder(Backend::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$backend = $this->createMock(Backend::class);
|
||||
$backend->expects($this->once())
|
||||
->method('getAuthSchemes')
|
||||
->willReturn(['scheme' => true, 'foobar' => true]);
|
||||
|
||||
$storageConfig = $this->getMockBuilder(StorageConfig::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$storageConfig = $this->createMock(StorageConfig::class);
|
||||
$storageConfig->expects($this->once())
|
||||
->method('getBackend')
|
||||
->willReturn($backend);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
|
|
@ -8,26 +10,16 @@ namespace OCA\Files_External\Tests\Auth\Password;
|
|||
|
||||
use OCA\Files_External\Lib\Auth\Password\GlobalAuth;
|
||||
use OCA\Files_External\Lib\InsufficientDataForMeaningfulAnswerException;
|
||||
use OCA\Files_external\Lib\StorageConfig;
|
||||
use OCA\Files_External\Lib\StorageConfig;
|
||||
use OCP\IL10N;
|
||||
use OCP\Security\ICredentialsManager;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Test\TestCase;
|
||||
|
||||
class GlobalAuthTest extends TestCase {
|
||||
/**
|
||||
* @var IL10N|\PHPUnit\Framework\MockObject\MockObject
|
||||
*/
|
||||
private $l10n;
|
||||
|
||||
/**
|
||||
* @var ICredentialsManager|\PHPUnit\Framework\MockObject\MockObject
|
||||
*/
|
||||
private $credentialsManager;
|
||||
|
||||
/**
|
||||
* @var GlobalAuth
|
||||
*/
|
||||
private $instance;
|
||||
private IL10N&MockObject $l10n;
|
||||
private ICredentialsManager&MockObject $credentialsManager;
|
||||
private GlobalAuth $instance;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
@ -37,7 +29,7 @@ class GlobalAuthTest extends TestCase {
|
|||
}
|
||||
|
||||
private function getStorageConfig($type, $config = []) {
|
||||
/** @var \OCA\Files_External\Lib\StorageConfig|\PHPUnit\Framework\MockObject\MockObject $storageConfig */
|
||||
/** @var \OCA\Files_External\Lib\StorageConfig&MockObject $storageConfig */
|
||||
$storageConfig = $this->createMock(StorageConfig::class);
|
||||
$storageConfig->expects($this->any())
|
||||
->method('getType')
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
|
|
@ -12,7 +14,7 @@ use OCA\Files_External\Lib\StorageConfig;
|
|||
class BackendTest extends \Test\TestCase {
|
||||
public function testJsonSerialization(): void {
|
||||
$backend = $this->getMockBuilder(Backend::class)
|
||||
->setMethods(['jsonSerializeDefinition'])
|
||||
->onlyMethods(['jsonSerializeDefinition'])
|
||||
->getMock();
|
||||
$backend->expects($this->once())
|
||||
->method('jsonSerializeDefinition')
|
||||
|
|
@ -32,7 +34,7 @@ class BackendTest extends \Test\TestCase {
|
|||
$this->assertContains('barauth', array_keys($json['authSchemes']));
|
||||
}
|
||||
|
||||
public function validateStorageProvider() {
|
||||
public static function validateStorageProvider(): array {
|
||||
return [
|
||||
[true, true],
|
||||
[false, false],
|
||||
|
|
@ -42,9 +44,9 @@ class BackendTest extends \Test\TestCase {
|
|||
/**
|
||||
* @dataProvider validateStorageProvider
|
||||
*/
|
||||
public function testValidateStorage($expectedSuccess, $definitionSuccess): void {
|
||||
public function testValidateStorage(bool $expectedSuccess, bool $definitionSuccess): void {
|
||||
$backend = $this->getMockBuilder(Backend::class)
|
||||
->setMethods(['validateStorageDefinition'])
|
||||
->onlyMethods(['validateStorageDefinition'])
|
||||
->getMock();
|
||||
$backend->expects($this->atMost(1))
|
||||
->method('validateStorageDefinition')
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
namespace OCA\Files_External\Tests\Backend;
|
||||
|
||||
use OCA\Files_External\Lib\Auth\Builtin;
|
||||
use OCA\Files_External\Lib\Backend\LegacyBackend;
|
||||
use OCA\Files_External\Lib\DefinitionParameter;
|
||||
use OCA\Files_External\Lib\MissingDependency;
|
||||
|
|
@ -15,18 +16,16 @@ class LegacyBackendTest extends \Test\TestCase {
|
|||
/**
|
||||
* @return MissingDependency[]
|
||||
*/
|
||||
public static function checkDependencies() {
|
||||
public static function checkDependencies(): array {
|
||||
return [
|
||||
(new MissingDependency('abc'))->setMessage('foobar')
|
||||
];
|
||||
}
|
||||
|
||||
public function testConstructor(): void {
|
||||
$auth = $this->getMockBuilder('\OCA\Files_External\Lib\Auth\Builtin')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$auth = $this->createMock(Builtin::class);
|
||||
|
||||
$class = '\OCA\Files_External\Tests\Backend\LegacyBackendTest';
|
||||
$class = self::class;
|
||||
$definition = [
|
||||
'configuration' => [
|
||||
'textfield' => 'Text field',
|
||||
|
|
@ -43,7 +42,7 @@ class LegacyBackendTest extends \Test\TestCase {
|
|||
|
||||
$backend = new LegacyBackend($class, $definition, $auth);
|
||||
|
||||
$this->assertEquals('\OCA\Files_External\Tests\Backend\LegacyBackendTest', $backend->getStorageClass());
|
||||
$this->assertEquals(self::class, $backend->getStorageClass());
|
||||
$this->assertEquals('Backend text', $backend->getText());
|
||||
$this->assertEquals(123, $backend->getPriority());
|
||||
$this->assertContains('foo/bar.js', $backend->getCustomJs());
|
||||
|
|
@ -74,11 +73,9 @@ class LegacyBackendTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testNoDependencies(): void {
|
||||
$auth = $this->getMockBuilder('\OCA\Files_External\Lib\Auth\Builtin')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$auth = $this->createMock(Builtin::class);
|
||||
|
||||
$class = '\OCA\Files_External\Tests\Backend\LegacyBackendTest';
|
||||
$class = self::class;
|
||||
$definition = [
|
||||
'configuration' => [
|
||||
],
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
|
|
@ -9,12 +11,13 @@ 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 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 IGroupManager|\PHPUnit\Framework\MockObject\MockObject $groupManager */
|
||||
/** @var IGroupManager&MockObject $groupManager */
|
||||
$groupManager = $this->createMock(IGroupManager::class);
|
||||
|
||||
$userManager->expects($this->any())
|
||||
|
|
|
|||
|
|
@ -9,21 +9,20 @@ 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 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);
|
||||
|
||||
|
|
@ -31,10 +30,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) {
|
||||
|
|
@ -70,7 +69,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) {
|
||||
|
|
@ -82,7 +81,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();
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
|
|
@ -16,24 +18,20 @@ 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);
|
||||
|
|
@ -41,8 +39,6 @@ class ListCommandTest extends CommandTest {
|
|||
|
||||
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));
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
|
@ -12,25 +14,15 @@ use OCP\IUserManager;
|
|||
use OCP\IUserSession;
|
||||
use OCP\Share\Exceptions\ShareNotFound;
|
||||
use OCP\Share\IManager;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
||||
class UserPlaceholderHandlerTest extends \Test\TestCase {
|
||||
/** @var IUser|\PHPUnit\Framework\MockObject\MockObject */
|
||||
protected $user;
|
||||
|
||||
/** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject */
|
||||
protected $session;
|
||||
|
||||
/** @var IManager|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $shareManager;
|
||||
|
||||
/** @var IRequest|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $request;
|
||||
|
||||
/** @var IUserManager|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $userManager;
|
||||
|
||||
/** @var UserPlaceholderHandler */
|
||||
protected $handler;
|
||||
protected IUser&MockObject $user;
|
||||
protected IUserSession&MockObject $session;
|
||||
protected IManager&MockObject $shareManager;
|
||||
protected IRequest&MockObject $request;
|
||||
protected IUserManager&MockObject $userManager;
|
||||
protected UserPlaceholderHandler $handler;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
@ -47,13 +39,13 @@ class UserPlaceholderHandlerTest extends \Test\TestCase {
|
|||
$this->handler = new UserPlaceholderHandler($this->session, $this->shareManager, $this->request, $this->userManager);
|
||||
}
|
||||
|
||||
protected function setUser() {
|
||||
protected function setUser(): void {
|
||||
$this->session->expects($this->any())
|
||||
->method('getUser')
|
||||
->willReturn($this->user);
|
||||
}
|
||||
|
||||
public function optionProvider() {
|
||||
public static function optionProvider(): array {
|
||||
return [
|
||||
['/foo/bar/$user/foobar', '/foo/bar/alice/foobar'],
|
||||
[['/foo/bar/$user/foobar'], ['/foo/bar/alice/foobar']],
|
||||
|
|
@ -64,7 +56,7 @@ class UserPlaceholderHandlerTest extends \Test\TestCase {
|
|||
/**
|
||||
* @dataProvider optionProvider
|
||||
*/
|
||||
public function testHandle($option, $expected): void {
|
||||
public function testHandle(string|array $option, string|array $expected): void {
|
||||
$this->setUser();
|
||||
$this->assertSame($expected, $this->handler->handle($option));
|
||||
}
|
||||
|
|
@ -72,7 +64,7 @@ class UserPlaceholderHandlerTest extends \Test\TestCase {
|
|||
/**
|
||||
* @dataProvider optionProvider
|
||||
*/
|
||||
public function testHandleNoUser($option): void {
|
||||
public function testHandleNoUser(string|array $option): void {
|
||||
$this->shareManager->expects($this->once())
|
||||
->method('getShareByToken')
|
||||
->willThrowException(new ShareNotFound());
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
|
@ -14,32 +16,22 @@ use OCP\IL10N;
|
|||
use OCP\IRequest;
|
||||
use OCP\IUser;
|
||||
use OCP\IUserSession;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Test\TestCase;
|
||||
|
||||
class AjaxControllerTest extends TestCase {
|
||||
/** @var IRequest */
|
||||
private $request;
|
||||
/** @var RSA */
|
||||
private $rsa;
|
||||
/** @var GlobalAuth */
|
||||
private $globalAuth;
|
||||
/** @var IUserSession */
|
||||
private $userSession;
|
||||
/** @var IGroupManager */
|
||||
private $groupManager;
|
||||
/** @var AjaxController */
|
||||
private $ajaxController;
|
||||
/** @var IL10N */
|
||||
private $l10n;
|
||||
private IRequest&MockObject $request;
|
||||
private RSA&MockObject $rsa;
|
||||
private GlobalAuth&MockObject $globalAuth;
|
||||
private IUserSession&MockObject $userSession;
|
||||
private IGroupManager&MockObject $groupManager;
|
||||
private IL10N&MockObject $l10n;
|
||||
private AjaxController $ajaxController;
|
||||
|
||||
protected function setUp(): void {
|
||||
$this->request = $this->createMock(IRequest::class);
|
||||
$this->rsa = $this->getMockBuilder('\\OCA\\Files_External\\Lib\\Auth\\PublicKey\\RSA')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->globalAuth = $this->getMockBuilder('\\OCA\\Files_External\\Lib\\Auth\\Password\GlobalAuth')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->rsa = $this->createMock(RSA::class);
|
||||
$this->globalAuth = $this->createMock(GlobalAuth::class);
|
||||
$this->userSession = $this->createMock(IUserSession::class);
|
||||
$this->groupManager = $this->createMock(IGroupManager::class);
|
||||
$this->l10n = $this->createMock(IL10N::class);
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ namespace OCA\Files_External\Tests\Controller;
|
|||
use OC\User\User;
|
||||
use OCA\Files_External\Controller\GlobalStoragesController;
|
||||
use OCA\Files_External\Service\BackendService;
|
||||
use OCA\Files_External\Service\GlobalStoragesService;
|
||||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
use OCP\IConfig;
|
||||
use OCP\IGroupManager;
|
||||
|
|
@ -17,13 +18,11 @@ use OCP\IRequest;
|
|||
use OCP\IUserSession;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class GlobalStoragesControllerTest extends StoragesControllerTest {
|
||||
class GlobalStoragesControllerTest extends StoragesControllerTestCase {
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
||||
$this->service = $this->getMockBuilder('\OCA\Files_External\Service\GlobalStoragesService')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->service = $this->createMock(GlobalStoragesService::class);
|
||||
|
||||
$this->service->method('getVisibilityType')
|
||||
->willReturn(BackendService::VISIBILITY_ADMIN);
|
||||
|
|
@ -31,7 +30,7 @@ class GlobalStoragesControllerTest extends StoragesControllerTest {
|
|||
$this->controller = $this->createController(true);
|
||||
}
|
||||
|
||||
private function createController($allowCreateLocal = true) {
|
||||
private function createController(bool $allowCreateLocal = true): GlobalStoragesController {
|
||||
$session = $this->createMock(IUserSession::class);
|
||||
$session->method('getUser')
|
||||
->willReturn(new User('test', null, $this->createMock(IEventDispatcher::class)));
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
|
|
@ -7,10 +9,12 @@
|
|||
namespace OCA\Files_External\Tests\Controller;
|
||||
|
||||
use OCA\Files_External\Controller\GlobalStoragesController;
|
||||
use OCA\Files_External\Controller\UserStoragesController;
|
||||
use OCA\Files_External\Lib\Auth\AuthMechanism;
|
||||
use OCA\Files_External\Lib\Auth\NullMechanism;
|
||||
use OCA\Files_External\Lib\Backend\Backend;
|
||||
use OCA\Files_External\Lib\Backend\SMB;
|
||||
use OCA\Files_External\Lib\StorageConfig;
|
||||
|
||||
use OCA\Files_External\MountConfig;
|
||||
use OCA\Files_External\NotFoundException;
|
||||
use OCA\Files_External\Service\GlobalStoragesService;
|
||||
|
|
@ -18,33 +22,25 @@ use OCA\Files_External\Service\UserStoragesService;
|
|||
use OCP\AppFramework\Http;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
||||
abstract class StoragesControllerTest extends \Test\TestCase {
|
||||
|
||||
/**
|
||||
* @var GlobalStoragesController
|
||||
*/
|
||||
protected $controller;
|
||||
|
||||
/**
|
||||
* @var GlobalStoragesService|UserStoragesService|MockObject
|
||||
*/
|
||||
protected $service;
|
||||
abstract class StoragesControllerTestCase extends \Test\TestCase {
|
||||
protected GlobalStoragesController|UserStoragesController $controller;
|
||||
protected GlobalStoragesService|UserStoragesService|MockObject $service;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
MountConfig::$skipTest = true;
|
||||
}
|
||||
|
||||
protected function tearDown(): void {
|
||||
MountConfig::$skipTest = false;
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \OCA\Files_External\Lib\Backend\Backend|MockObject
|
||||
* @return \OCA\Files_External\Lib\Backend\Backend&MockObject
|
||||
*/
|
||||
protected function getBackendMock($class = '\OCA\Files_External\Lib\Backend\SMB', $storageClass = '\OCA\Files_External\Lib\Storage\SMB') {
|
||||
$backend = $this->getMockBuilder(Backend::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
protected function getBackendMock($class = SMB::class, $storageClass = \OCA\Files_External\Lib\Storage\SMB::class) {
|
||||
$backend = $this->createMock(Backend::class);
|
||||
$backend->method('getStorageClass')
|
||||
->willReturn($storageClass);
|
||||
$backend->method('getIdentifier')
|
||||
|
|
@ -57,10 +53,8 @@ abstract class StoragesControllerTest extends \Test\TestCase {
|
|||
/**
|
||||
* @return AuthMechanism|MockObject
|
||||
*/
|
||||
protected function getAuthMechMock($scheme = 'null', $class = '\OCA\Files_External\Lib\Auth\NullMechanism') {
|
||||
$authMech = $this->getMockBuilder(AuthMechanism::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
protected function getAuthMechMock($scheme = 'null', $class = NullMechanism::class) {
|
||||
$authMech = $this->createMock(AuthMechanism::class);
|
||||
$authMech->method('getScheme')
|
||||
->willReturn($scheme);
|
||||
$authMech->method('getIdentifier')
|
||||
|
|
@ -98,8 +92,8 @@ abstract class StoragesControllerTest extends \Test\TestCase {
|
|||
|
||||
$response = $this->controller->create(
|
||||
'mount',
|
||||
'\OCA\Files_External\Lib\Storage\SMB',
|
||||
'\OCA\Files_External\Lib\Auth\NullMechanism',
|
||||
\OCA\Files_External\Lib\Storage\SMB::class,
|
||||
NullMechanism::class,
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
|
|
@ -130,7 +124,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
|
|||
$response = $this->controller->create(
|
||||
'mount',
|
||||
'local',
|
||||
'\OCA\Files_External\Lib\Auth\NullMechanism',
|
||||
NullMechanism::class,
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
|
|
@ -170,8 +164,8 @@ abstract class StoragesControllerTest extends \Test\TestCase {
|
|||
$response = $this->controller->update(
|
||||
1,
|
||||
'mount',
|
||||
'\OCA\Files_External\Lib\Storage\SMB',
|
||||
'\OCA\Files_External\Lib\Auth\NullMechanism',
|
||||
\OCA\Files_External\Lib\Storage\SMB::class,
|
||||
NullMechanism::class,
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
|
|
@ -184,7 +178,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
|
|||
$this->assertEquals($storageConfig->jsonSerialize(), $data);
|
||||
}
|
||||
|
||||
public function mountPointNamesProvider() {
|
||||
public static function mountPointNamesProvider(): array {
|
||||
return [
|
||||
[''],
|
||||
['/'],
|
||||
|
|
@ -212,8 +206,8 @@ abstract class StoragesControllerTest extends \Test\TestCase {
|
|||
|
||||
$response = $this->controller->create(
|
||||
$mountPoint,
|
||||
'\OCA\Files_External\Lib\Storage\SMB',
|
||||
'\OCA\Files_External\Lib\Auth\NullMechanism',
|
||||
\OCA\Files_External\Lib\Storage\SMB::class,
|
||||
NullMechanism::class,
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
|
|
@ -226,8 +220,8 @@ abstract class StoragesControllerTest extends \Test\TestCase {
|
|||
$response = $this->controller->update(
|
||||
1,
|
||||
$mountPoint,
|
||||
'\OCA\Files_External\Lib\Storage\SMB',
|
||||
'\OCA\Files_External\Lib\Auth\NullMechanism',
|
||||
\OCA\Files_External\Lib\Storage\SMB::class,
|
||||
NullMechanism::class,
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
|
|
@ -250,7 +244,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
|
|||
$response = $this->controller->create(
|
||||
'mount',
|
||||
'\OC\Files\Storage\InvalidStorage',
|
||||
'\OCA\Files_External\Lib\Auth\NullMechanism',
|
||||
NullMechanism::class,
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
|
|
@ -264,7 +258,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
|
|||
1,
|
||||
'mount',
|
||||
'\OC\Files\Storage\InvalidStorage',
|
||||
'\OCA\Files_External\Lib\Auth\NullMechanism',
|
||||
NullMechanism::class,
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
|
|
@ -303,8 +297,8 @@ abstract class StoragesControllerTest extends \Test\TestCase {
|
|||
$response = $this->controller->update(
|
||||
255,
|
||||
'mount',
|
||||
'\OCA\Files_External\Lib\Storage\SMB',
|
||||
'\OCA\Files_External\Lib\Auth\NullMechanism',
|
||||
\OCA\Files_External\Lib\Storage\SMB::class,
|
||||
NullMechanism::class,
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
|
|
@ -354,7 +348,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
|
|||
$this->assertEquals($expected, $response->getData());
|
||||
}
|
||||
|
||||
public function validateStorageProvider() {
|
||||
public static function validateStorageProvider(): array {
|
||||
return [
|
||||
[true, true, true],
|
||||
[false, true, false],
|
||||
|
|
@ -366,7 +360,7 @@ abstract class StoragesControllerTest extends \Test\TestCase {
|
|||
/**
|
||||
* @dataProvider validateStorageProvider
|
||||
*/
|
||||
public function testValidateStorage($backendValidate, $authMechValidate, $expectSuccess): void {
|
||||
public function testValidateStorage(bool $backendValidate, bool $authMechValidate, bool $expectSuccess): void {
|
||||
$backend = $this->getBackendMock();
|
||||
$backend->method('validateStorage')
|
||||
->willReturn($backendValidate);
|
||||
|
|
@ -401,8 +395,8 @@ abstract class StoragesControllerTest extends \Test\TestCase {
|
|||
|
||||
$response = $this->controller->create(
|
||||
'mount',
|
||||
'\OCA\Files_External\Lib\Storage\SMB',
|
||||
'\OCA\Files_External\Lib\Auth\NullMechanism',
|
||||
\OCA\Files_External\Lib\Storage\SMB::class,
|
||||
NullMechanism::class,
|
||||
[],
|
||||
[],
|
||||
[],
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
|
|
@ -8,8 +10,10 @@ namespace OCA\Files_External\Tests\Controller;
|
|||
|
||||
use OC\User\User;
|
||||
use OCA\Files_External\Controller\UserStoragesController;
|
||||
use OCA\Files_External\Lib\Storage\SMB;
|
||||
use OCA\Files_External\Lib\StorageConfig;
|
||||
use OCA\Files_External\Service\BackendService;
|
||||
use OCA\Files_External\Service\UserStoragesService;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\EventDispatcher\IEventDispatcher;
|
||||
use OCP\IConfig;
|
||||
|
|
@ -19,18 +23,16 @@ use OCP\IRequest;
|
|||
use OCP\IUserSession;
|
||||
use Psr\Log\LoggerInterface;
|
||||
|
||||
class UserStoragesControllerTest extends StoragesControllerTest {
|
||||
class UserStoragesControllerTest extends StoragesControllerTestCase {
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $oldAllowedBackends;
|
||||
private array $oldAllowedBackends;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->service = $this->getMockBuilder('\OCA\Files_External\Service\UserStoragesService')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->service = $this->createMock(UserStoragesService::class);
|
||||
|
||||
$this->service->method('getVisibilityType')
|
||||
->willReturn(BackendService::VISIBILITY_PERSONAL);
|
||||
|
|
@ -38,7 +40,7 @@ class UserStoragesControllerTest extends StoragesControllerTest {
|
|||
$this->controller = $this->createController(true);
|
||||
}
|
||||
|
||||
private function createController($allowCreateLocal = true) {
|
||||
private function createController(bool $allowCreateLocal = true) {
|
||||
$session = $this->createMock(IUserSession::class);
|
||||
$session->method('getUser')
|
||||
->willReturn(new User('test', null, $this->createMock(IEventDispatcher::class)));
|
||||
|
|
@ -88,7 +90,7 @@ class UserStoragesControllerTest extends StoragesControllerTest {
|
|||
|
||||
$response = $this->controller->create(
|
||||
'mount',
|
||||
'\OCA\Files_External\Lib\Storage\SMB',
|
||||
SMB::class,
|
||||
'\Auth\Mechanism',
|
||||
[],
|
||||
[],
|
||||
|
|
@ -102,7 +104,7 @@ class UserStoragesControllerTest extends StoragesControllerTest {
|
|||
$response = $this->controller->update(
|
||||
1,
|
||||
'mount',
|
||||
'\OCA\Files_External\Lib\Storage\SMB',
|
||||
SMB::class,
|
||||
'\Auth\Mechanism',
|
||||
[],
|
||||
[],
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
|
|
@ -48,7 +50,7 @@ class DefinitionParameterTest extends \Test\TestCase {
|
|||
], $param->jsonSerialize());
|
||||
}
|
||||
|
||||
public function validateValueProvider() {
|
||||
public static function validateValueProvider(): array {
|
||||
return [
|
||||
[Param::VALUE_TEXT, Param::FLAG_NONE, 'abc', true],
|
||||
[Param::VALUE_TEXT, Param::FLAG_NONE, '', false],
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ class FrontendDefinitionTraitTest extends \Test\TestCase {
|
|||
->getMock();
|
||||
$param->method('getName')->willReturn('foo');
|
||||
|
||||
$trait = $this->getMockForTrait('\OCA\Files_External\Lib\FrontendDefinitionTrait');
|
||||
$trait = $this->getMockForTrait(\OCA\Files_External\Lib\FrontendDefinitionTrait::class);
|
||||
$trait->setText('test');
|
||||
$trait->addParameters([$param]);
|
||||
$trait->addCustomJs('foo/bar.js');
|
||||
|
|
@ -32,7 +32,7 @@ class FrontendDefinitionTraitTest extends \Test\TestCase {
|
|||
$this->assertArrayHasKey('foo', $configuration);
|
||||
}
|
||||
|
||||
public function validateStorageProvider() {
|
||||
public static function validateStorageProvider(): array {
|
||||
return [
|
||||
[true, ['foo' => true, 'bar' => true, 'baz' => true]],
|
||||
[false, ['foo' => true, 'bar' => false]]
|
||||
|
|
@ -42,7 +42,7 @@ class FrontendDefinitionTraitTest extends \Test\TestCase {
|
|||
/**
|
||||
* @dataProvider validateStorageProvider
|
||||
*/
|
||||
public function testValidateStorage($expectedSuccess, $params): void {
|
||||
public function testValidateStorage(bool $expectedSuccess, array $params): void {
|
||||
$backendParams = [];
|
||||
foreach ($params as $name => $valid) {
|
||||
$param = $this->getMockBuilder(DefinitionParameter::class)
|
||||
|
|
@ -67,7 +67,7 @@ class FrontendDefinitionTraitTest extends \Test\TestCase {
|
|||
$storageConfig->expects($this->any())
|
||||
->method('setBackendOption');
|
||||
|
||||
$trait = $this->getMockForTrait('\OCA\Files_External\Lib\FrontendDefinitionTrait');
|
||||
$trait = $this->getMockForTrait(\OCA\Files_External\Lib\FrontendDefinitionTrait::class);
|
||||
$trait->setText('test');
|
||||
$trait->addParameters($backendParams);
|
||||
|
||||
|
|
@ -98,7 +98,7 @@ class FrontendDefinitionTraitTest extends \Test\TestCase {
|
|||
->method('setBackendOption')
|
||||
->with('param', 'foobar');
|
||||
|
||||
$trait = $this->getMockForTrait('\OCA\Files_External\Lib\FrontendDefinitionTrait');
|
||||
$trait = $this->getMockForTrait(\OCA\Files_External\Lib\FrontendDefinitionTrait::class);
|
||||
$trait->setText('test');
|
||||
$trait->addParameter($param);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
|
|
@ -13,7 +15,7 @@ class LegacyDependencyCheckPolyfillTest extends \Test\TestCase {
|
|||
/**
|
||||
* @return MissingDependency[]
|
||||
*/
|
||||
public static function checkDependencies() {
|
||||
public static function checkDependencies(): array {
|
||||
return [
|
||||
(new MissingDependency('dependency'))->setMessage('missing dependency'),
|
||||
(new MissingDependency('program'))->setMessage('cannot find program'),
|
||||
|
|
@ -21,10 +23,10 @@ class LegacyDependencyCheckPolyfillTest extends \Test\TestCase {
|
|||
}
|
||||
|
||||
public function testCheckDependencies(): void {
|
||||
$trait = $this->getMockForTrait('\OCA\Files_External\Lib\LegacyDependencyCheckPolyfill');
|
||||
$trait = $this->getMockForTrait(\OCA\Files_External\Lib\LegacyDependencyCheckPolyfill::class);
|
||||
$trait->expects($this->once())
|
||||
->method('getStorageClass')
|
||||
->willReturn('\OCA\Files_External\Tests\LegacyDependencyCheckPolyfillTest');
|
||||
->willReturn(self::class);
|
||||
|
||||
$dependencies = $trait->checkDependencies();
|
||||
$this->assertCount(2, $dependencies);
|
||||
|
|
|
|||
|
|
@ -22,15 +22,12 @@ use Test\TestCase;
|
|||
* @group DB
|
||||
*/
|
||||
class StorePasswordListenerTest extends TestCase {
|
||||
/** @var MockObject|IUser */
|
||||
protected $mockedUser;
|
||||
protected IUser&MockObject $mockedUser;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->mockedUser = $this->createMock(IUser::class);
|
||||
$this->mockedUser
|
||||
->expects($this->any())
|
||||
->method('getUID')
|
||||
$this->mockedUser->method('getUID')
|
||||
->willReturn('test');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
|
|
@ -16,7 +18,7 @@ use OCA\Files_External\Lib\Storage\OwnCloud;
|
|||
* @package OCA\Files_External\Tests
|
||||
*/
|
||||
class OwnCloudFunctionsTest extends \Test\TestCase {
|
||||
public function configUrlProvider() {
|
||||
public static function configUrlProvider(): array {
|
||||
return [
|
||||
[
|
||||
[
|
||||
|
|
@ -88,7 +90,7 @@ class OwnCloudFunctionsTest extends \Test\TestCase {
|
|||
/**
|
||||
* @dataProvider configUrlProvider
|
||||
*/
|
||||
public function testConfig($config, $expectedUri): void {
|
||||
public function testConfig(array $config, string $expectedUri): void {
|
||||
$config['user'] = 'someuser';
|
||||
$config['password'] = 'somepassword';
|
||||
$instance = new OwnCloud($config);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
|
|
@ -8,6 +10,7 @@ namespace OCA\Files_External\Tests;
|
|||
|
||||
use OC\Files\Mount\Manager;
|
||||
use OC\Files\SetupManagerFactory;
|
||||
use OC\Files\Storage\Storage;
|
||||
use OCA\Files_External\Lib\PersonalMount;
|
||||
use OCA\Files_External\Lib\StorageConfig;
|
||||
use OCA\Files_External\Service\UserStoragesService;
|
||||
|
|
@ -17,13 +20,9 @@ class PersonalMountTest extends TestCase {
|
|||
public function testFindByStorageId(): void {
|
||||
$storageConfig = $this->createMock(StorageConfig::class);
|
||||
/** @var UserStoragesService $storageService */
|
||||
$storageService = $this->getMockBuilder('\OCA\Files_External\Service\UserStoragesService')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$storageService = $this->createMock(UserStoragesService::class);
|
||||
|
||||
$storage = $this->getMockBuilder('\OC\Files\Storage\Storage')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$storage = $this->createMock(Storage::class);
|
||||
|
||||
$storage->expects($this->any())
|
||||
->method('getId')
|
||||
|
|
|
|||
|
|
@ -13,25 +13,20 @@ use OCA\Files_External\Lib\Config\IAuthMechanismProvider;
|
|||
use OCA\Files_External\Lib\Config\IBackendProvider;
|
||||
use OCA\Files_External\Service\BackendService;
|
||||
use OCP\IAppConfig;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
||||
class BackendServiceTest extends \Test\TestCase {
|
||||
|
||||
/** @var IAppConfig|\PHPUnit\Framework\MockObject\MockObject */
|
||||
protected $appConfig;
|
||||
protected IAppConfig&MockObject $appConfig;
|
||||
|
||||
protected function setUp(): void {
|
||||
$this->appConfig = $this->createMock(IAppConfig::class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
*
|
||||
* @return \OCA\Files_External\Lib\Backend\Backend|\PHPUnit\Framework\MockObject\MockObject
|
||||
* @return \OCA\Files_External\Lib\Backend\Backend&MockObject
|
||||
*/
|
||||
protected function getBackendMock($class) {
|
||||
$backend = $this->getMockBuilder(Backend::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
protected function getBackendMock(string $class) {
|
||||
$backend = $this->createMock(Backend::class);
|
||||
$backend->method('getIdentifier')->willReturn('identifier:' . $class);
|
||||
$backend->method('getIdentifierAliases')->willReturn(['identifier:' . $class]);
|
||||
return $backend;
|
||||
|
|
@ -40,12 +35,10 @@ class BackendServiceTest extends \Test\TestCase {
|
|||
/**
|
||||
* @param string $class
|
||||
*
|
||||
* @return AuthMechanism|\PHPUnit\Framework\MockObject\MockObject
|
||||
* @return AuthMechanism&MockObject
|
||||
*/
|
||||
protected function getAuthMechanismMock($class) {
|
||||
$backend = $this->getMockBuilder(AuthMechanism::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$backend = $this->createMock(AuthMechanism::class);
|
||||
$backend->method('getIdentifier')->willReturn('identifier:' . $class);
|
||||
$backend->method('getIdentifierAliases')->willReturn(['identifier:' . $class]);
|
||||
return $backend;
|
||||
|
|
@ -56,10 +49,8 @@ class BackendServiceTest extends \Test\TestCase {
|
|||
|
||||
$backend = $this->getBackendMock('\Foo\Bar');
|
||||
|
||||
/** @var \OCA\Files_External\Lib\Backend\Backend|\PHPUnit\Framework\MockObject\MockObject $backendAlias */
|
||||
$backendAlias = $this->getMockBuilder(Backend::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
/** @var \OCA\Files_External\Lib\Backend\Backend&MockObject $backendAlias */
|
||||
$backendAlias = $this->createMock(Backend::class);
|
||||
$backendAlias->method('getIdentifierAliases')
|
||||
->willReturn(['identifier_real', 'identifier_alias']);
|
||||
$backendAlias->method('getIdentifier')
|
||||
|
|
@ -85,7 +76,7 @@ class BackendServiceTest extends \Test\TestCase {
|
|||
$backend1 = $this->getBackendMock('\Foo\Bar');
|
||||
$backend2 = $this->getBackendMock('\Bar\Foo');
|
||||
|
||||
/** @var IBackendProvider|\PHPUnit\Framework\MockObject\MockObject $providerMock */
|
||||
/** @var IBackendProvider&MockObject $providerMock */
|
||||
$providerMock = $this->createMock(IBackendProvider::class);
|
||||
$providerMock->expects($this->once())
|
||||
->method('getBackends')
|
||||
|
|
@ -104,7 +95,7 @@ class BackendServiceTest extends \Test\TestCase {
|
|||
$backend1 = $this->getAuthMechanismMock('\Foo\Bar');
|
||||
$backend2 = $this->getAuthMechanismMock('\Bar\Foo');
|
||||
|
||||
/** @var IAuthMechanismProvider|\PHPUnit\Framework\MockObject\MockObject $providerMock */
|
||||
/** @var IAuthMechanismProvider&MockObject $providerMock */
|
||||
$providerMock = $this->createMock(IAuthMechanismProvider::class);
|
||||
$providerMock->expects($this->once())
|
||||
->method('getAuthMechanisms')
|
||||
|
|
@ -125,13 +116,13 @@ class BackendServiceTest extends \Test\TestCase {
|
|||
|
||||
$backend2 = $this->getBackendMock('\Dead\Beef');
|
||||
|
||||
/** @var IBackendProvider|\PHPUnit\Framework\MockObject\MockObject $provider1Mock */
|
||||
/** @var IBackendProvider&MockObject $provider1Mock */
|
||||
$provider1Mock = $this->createMock(IBackendProvider::class);
|
||||
$provider1Mock->expects($this->once())
|
||||
->method('getBackends')
|
||||
->willReturn([$backend1a, $backend1b]);
|
||||
$service->registerBackendProvider($provider1Mock);
|
||||
/** @var IBackendProvider|\PHPUnit\Framework\MockObject\MockObject $provider2Mock */
|
||||
/** @var IBackendProvider&MockObject $provider2Mock */
|
||||
$provider2Mock = $this->createMock(IBackendProvider::class);
|
||||
$provider2Mock->expects($this->once())
|
||||
->method('getBackends')
|
||||
|
|
@ -202,7 +193,7 @@ class BackendServiceTest extends \Test\TestCase {
|
|||
$this->assertArrayNotHasKey('identifier:\Backend\NotAvailable', $availableBackends);
|
||||
}
|
||||
|
||||
public function invalidConfigPlaceholderProvider() {
|
||||
public static function invalidConfigPlaceholderProvider(): array {
|
||||
return [
|
||||
[['@user']],
|
||||
[['$user']],
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
|
|
@ -16,17 +18,10 @@ use Test\TestCase;
|
|||
* @group DB
|
||||
*/
|
||||
class DBConfigServiceTest extends TestCase {
|
||||
/**
|
||||
* @var DBConfigService
|
||||
*/
|
||||
private $dbConfig;
|
||||
private IDBConnection $connection;
|
||||
private DBConfigService $dbConfig;
|
||||
|
||||
/**
|
||||
* @var IDBConnection
|
||||
*/
|
||||
private $connection;
|
||||
|
||||
private $mounts = [];
|
||||
private array $mounts = [];
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
@ -39,9 +34,10 @@ class DBConfigServiceTest extends TestCase {
|
|||
$this->dbConfig->removeMount($mount);
|
||||
}
|
||||
$this->mounts = [];
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
private function addMount($mountPoint, $storageBackend, $authBackend, $priority, $type) {
|
||||
private function addMount(string $mountPoint, string $storageBackend, string $authBackend, int $priority, int $type) {
|
||||
$id = $this->dbConfig->addMount($mountPoint, $storageBackend, $authBackend, $priority, $type);
|
||||
$this->mounts[] = $id;
|
||||
return $id;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
|
|
@ -14,7 +16,7 @@ use OCA\Files_External\Service\GlobalStoragesService;
|
|||
/**
|
||||
* @group DB
|
||||
*/
|
||||
class GlobalStoragesServiceTest extends StoragesServiceTest {
|
||||
class GlobalStoragesServiceTest extends StoragesServiceTestCase {
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->service = new GlobalStoragesService($this->backendService, $this->dbConfig, $this->mountCache, $this->eventDispatcher);
|
||||
|
|
@ -44,7 +46,7 @@ class GlobalStoragesServiceTest extends StoragesServiceTest {
|
|||
]);
|
||||
}
|
||||
|
||||
public function storageDataProvider() {
|
||||
public static function storageDataProvider(): array {
|
||||
return [
|
||||
// all users
|
||||
[
|
||||
|
|
@ -172,7 +174,7 @@ class GlobalStoragesServiceTest extends StoragesServiceTest {
|
|||
$this->assertEquals(0, $newStorage->getStatus());
|
||||
}
|
||||
|
||||
public function hooksAddStorageDataProvider() {
|
||||
public static function hooksAddStorageDataProvider(): array {
|
||||
return [
|
||||
// applicable all
|
||||
[
|
||||
|
|
@ -301,7 +303,7 @@ class GlobalStoragesServiceTest extends StoragesServiceTest {
|
|||
}
|
||||
}
|
||||
|
||||
public function hooksUpdateStorageDataProvider() {
|
||||
public static function hooksUpdateStorageDataProvider(): array {
|
||||
return [
|
||||
[
|
||||
// nothing to multiple users and groups
|
||||
|
|
@ -421,11 +423,12 @@ class GlobalStoragesServiceTest extends StoragesServiceTest {
|
|||
* @dataProvider hooksUpdateStorageDataProvider
|
||||
*/
|
||||
public function testHooksUpdateStorage(
|
||||
$sourceApplicableUsers,
|
||||
$sourceApplicableGroups,
|
||||
$updatedApplicableUsers,
|
||||
$updatedApplicableGroups,
|
||||
$expectedCalls): void {
|
||||
array $sourceApplicableUsers,
|
||||
array $sourceApplicableGroups,
|
||||
array $updatedApplicableUsers,
|
||||
array $updatedApplicableGroups,
|
||||
array $expectedCalls,
|
||||
): void {
|
||||
$storage = $this->makeTestStorageData();
|
||||
$storage->setApplicableUsers($sourceApplicableUsers);
|
||||
$storage->setApplicableGroups($sourceApplicableGroups);
|
||||
|
|
@ -532,7 +535,7 @@ class GlobalStoragesServiceTest extends StoragesServiceTest {
|
|||
}
|
||||
}
|
||||
|
||||
public function hooksDeleteStorageDataProvider() {
|
||||
public static function hooksDeleteStorageDataProvider(): array {
|
||||
return [
|
||||
[
|
||||
['user1', 'user2'],
|
||||
|
|
@ -580,9 +583,10 @@ class GlobalStoragesServiceTest extends StoragesServiceTest {
|
|||
* @dataProvider hooksDeleteStorageDataProvider
|
||||
*/
|
||||
public function testHooksDeleteStorage(
|
||||
$sourceApplicableUsers,
|
||||
$sourceApplicableGroups,
|
||||
$expectedCalls): void {
|
||||
array $sourceApplicableUsers,
|
||||
array $sourceApplicableGroups,
|
||||
array $expectedCalls,
|
||||
): void {
|
||||
$storage = $this->makeTestStorageData();
|
||||
$storage->setApplicableUsers($sourceApplicableUsers);
|
||||
$storage->setApplicableGroups($sourceApplicableGroups);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
|
|
@ -10,9 +12,10 @@ use OC\Files\Cache\Storage;
|
|||
use OC\Files\Filesystem;
|
||||
use OCA\Files_External\Lib\Auth\AuthMechanism;
|
||||
use OCA\Files_External\Lib\Auth\InvalidAuth;
|
||||
use OCA\Files_External\Lib\Auth\NullMechanism;
|
||||
use OCA\Files_External\Lib\Backend\Backend;
|
||||
use OCA\Files_External\Lib\Backend\InvalidBackend;
|
||||
|
||||
use OCA\Files_External\Lib\Backend\SMB;
|
||||
use OCA\Files_External\Lib\StorageConfig;
|
||||
use OCA\Files_External\MountConfig;
|
||||
use OCA\Files_External\NotFoundException;
|
||||
|
|
@ -31,9 +34,10 @@ use OCP\IUser;
|
|||
use OCP\Security\ICrypto;
|
||||
use OCP\Server;
|
||||
use OCP\Util;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
|
||||
class CleaningDBConfig extends DBConfigService {
|
||||
private $mountIds = [];
|
||||
private array $mountIds = [];
|
||||
|
||||
public function addMount($mountPoint, $storageBackend, $authBackend, $priority, $type) {
|
||||
$id = parent::addMount($mountPoint, $storageBackend, $authBackend, $priority, $type); // TODO: Change the autogenerated stub
|
||||
|
|
@ -51,41 +55,14 @@ class CleaningDBConfig extends DBConfigService {
|
|||
/**
|
||||
* @group DB
|
||||
*/
|
||||
abstract class StoragesServiceTest extends \Test\TestCase {
|
||||
/**
|
||||
* @var StoragesService
|
||||
*/
|
||||
protected $service;
|
||||
|
||||
/** @var BackendService */
|
||||
protected $backendService;
|
||||
|
||||
/**
|
||||
* Data directory
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $dataDir;
|
||||
|
||||
/** @var CleaningDBConfig */
|
||||
protected $dbConfig;
|
||||
|
||||
/**
|
||||
* Hook calls
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $hookCalls;
|
||||
|
||||
/**
|
||||
* @var \PHPUnit\Framework\MockObject\MockObject|IUserMountCache
|
||||
*/
|
||||
protected $mountCache;
|
||||
|
||||
/**
|
||||
* @var \PHPUnit\Framework\MockObject\MockObject|IEventDispatcher
|
||||
*/
|
||||
protected IEventDispatcher $eventDispatcher;
|
||||
abstract class StoragesServiceTestCase extends \Test\TestCase {
|
||||
protected StoragesService $service;
|
||||
protected BackendService $backendService;
|
||||
protected string $dataDir;
|
||||
protected CleaningDBConfig $dbConfig;
|
||||
protected static array $hookCalls;
|
||||
protected IUserMountCache&MockObject $mountCache;
|
||||
protected IEventDispatcher&MockObject $eventDispatcher;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
@ -102,10 +79,7 @@ abstract class StoragesServiceTest extends \Test\TestCase {
|
|||
$this->eventDispatcher = $this->createMock(IEventDispatcher::class);
|
||||
|
||||
// prepare BackendService mock
|
||||
$this->backendService =
|
||||
$this->getMockBuilder('\OCA\Files_External\Service\BackendService')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->backendService = $this->createMock(BackendService::class);
|
||||
|
||||
$authMechanisms = [
|
||||
'identifier:\Auth\Mechanism' => $this->getAuthMechMock('null', '\Auth\Mechanism'),
|
||||
|
|
@ -172,12 +146,11 @@ abstract class StoragesServiceTest extends \Test\TestCase {
|
|||
if ($this->dbConfig) {
|
||||
$this->dbConfig->clean();
|
||||
}
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
protected function getBackendMock($class = '\OCA\Files_External\Lib\Backend\SMB', $storageClass = '\OCA\Files_External\Lib\Storage\SMB') {
|
||||
$backend = $this->getMockBuilder(Backend::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
protected function getBackendMock($class = SMB::class, $storageClass = \OCA\Files_External\Lib\Storage\SMB::class) {
|
||||
$backend = $this->createMock(Backend::class);
|
||||
$backend->method('getStorageClass')
|
||||
->willReturn($storageClass);
|
||||
$backend->method('getIdentifier')
|
||||
|
|
@ -185,10 +158,8 @@ abstract class StoragesServiceTest extends \Test\TestCase {
|
|||
return $backend;
|
||||
}
|
||||
|
||||
protected function getAuthMechMock($scheme = 'null', $class = '\OCA\Files_External\Lib\Auth\NullMechanism') {
|
||||
$authMech = $this->getMockBuilder(AuthMechanism::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
protected function getAuthMechMock($scheme = 'null', $class = NullMechanism::class) {
|
||||
$authMech = $this->createMock(AuthMechanism::class);
|
||||
$authMech->method('getScheme')
|
||||
->willReturn($scheme);
|
||||
$authMech->method('getIdentifier')
|
||||
|
|
@ -199,12 +170,8 @@ abstract class StoragesServiceTest extends \Test\TestCase {
|
|||
|
||||
/**
|
||||
* Creates a StorageConfig instance based on array data
|
||||
*
|
||||
* @param array $data
|
||||
*
|
||||
* @return StorageConfig storage config instance
|
||||
*/
|
||||
protected function makeStorageConfig($data) {
|
||||
protected function makeStorageConfig(array $data): StorageConfig {
|
||||
$storage = new StorageConfig();
|
||||
if (isset($data['id'])) {
|
||||
$storage->setId($data['id']);
|
||||
|
|
@ -259,7 +226,7 @@ abstract class StoragesServiceTest extends \Test\TestCase {
|
|||
$this->ActualNonExistingStorageTest();
|
||||
}
|
||||
|
||||
public function deleteStorageDataProvider() {
|
||||
public static function deleteStorageDataProvider(): array {
|
||||
return [
|
||||
// regular case, can properly delete the oc_storages entry
|
||||
[
|
||||
|
|
@ -286,7 +253,7 @@ abstract class StoragesServiceTest extends \Test\TestCase {
|
|||
/**
|
||||
* @dataProvider deleteStorageDataProvider
|
||||
*/
|
||||
public function testDeleteStorage($backendOptions, $rustyStorageId): void {
|
||||
public function testDeleteStorage(array $backendOptions, string $rustyStorageId): void {
|
||||
$backend = $this->backendService->getBackend('identifier:\OCA\Files_External\Lib\Backend\DAV');
|
||||
$authMechanism = $this->backendService->getAuthMechanism('identifier:\Auth\Mechanism');
|
||||
$storage = new StorageConfig(255);
|
||||
|
|
@ -463,14 +430,14 @@ abstract class StoragesServiceTest extends \Test\TestCase {
|
|||
$this->assertEmpty($this->service->getStorages());
|
||||
}
|
||||
|
||||
public static function createHookCallback($params) {
|
||||
public static function createHookCallback($params): void {
|
||||
self::$hookCalls[] = [
|
||||
'signal' => Filesystem::signal_create_mount,
|
||||
'params' => $params
|
||||
];
|
||||
}
|
||||
|
||||
public static function deleteHookCallback($params) {
|
||||
public static function deleteHookCallback($params): void {
|
||||
self::$hookCalls[] = [
|
||||
'signal' => Filesystem::signal_delete_mount,
|
||||
'params' => $params
|
||||
|
|
@ -16,6 +16,7 @@ use OCP\IGroupManager;
|
|||
use OCP\IUser;
|
||||
use OCP\IUserSession;
|
||||
use OCP\Server;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Test\Traits\UserTrait;
|
||||
|
||||
/**
|
||||
|
|
@ -24,20 +25,9 @@ use Test\Traits\UserTrait;
|
|||
class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest {
|
||||
use UserTrait;
|
||||
|
||||
/** @var IGroupManager|\PHPUnit\Framework\MockObject\MockObject groupManager */
|
||||
protected $groupManager;
|
||||
|
||||
/**
|
||||
* @var StoragesService
|
||||
*/
|
||||
protected $globalStoragesService;
|
||||
|
||||
/**
|
||||
* @var UserGlobalStoragesService
|
||||
*/
|
||||
protected $service;
|
||||
|
||||
protected $user;
|
||||
protected IGroupManager&MockObject $groupManager;
|
||||
protected StoragesService $globalStoragesService;
|
||||
protected User $user;
|
||||
|
||||
public const USER_ID = 'test_user';
|
||||
public const GROUP_ID = 'test_group';
|
||||
|
|
@ -49,7 +39,7 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest {
|
|||
$this->globalStoragesService = $this->service;
|
||||
|
||||
$this->user = new User(self::USER_ID, null, Server::get(IEventDispatcher::class));
|
||||
/** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject $userSession */
|
||||
/** @var IUserSession&MockObject $userSession */
|
||||
$userSession = $this->createMock(IUserSession::class);
|
||||
$userSession
|
||||
->expects($this->any())
|
||||
|
|
@ -87,7 +77,7 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest {
|
|||
);
|
||||
}
|
||||
|
||||
public function applicableStorageProvider() {
|
||||
public static function applicableStorageProvider(): array {
|
||||
return [
|
||||
[[], [], true],
|
||||
|
||||
|
|
@ -211,7 +201,7 @@ class UserGlobalStoragesServiceTest extends GlobalStoragesServiceTest {
|
|||
$this->actualDeletedUnexistingStorageTest();
|
||||
}
|
||||
|
||||
public function getUniqueStoragesProvider() {
|
||||
public static function getUniqueStoragesProvider(): array {
|
||||
return [
|
||||
// 'all' vs group
|
||||
[100, [], [], 100, [], [self::GROUP_ID], 2],
|
||||
|
|
|
|||
|
|
@ -17,22 +17,19 @@ use OCA\Files_External\Service\UserStoragesService;
|
|||
use OCP\IUserManager;
|
||||
use OCP\IUserSession;
|
||||
use OCP\Server;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Test\Traits\UserTrait;
|
||||
|
||||
/**
|
||||
* @group DB
|
||||
*/
|
||||
class UserStoragesServiceTest extends StoragesServiceTest {
|
||||
class UserStoragesServiceTest extends StoragesServiceTestCase {
|
||||
use UserTrait;
|
||||
|
||||
private $user;
|
||||
protected \OC\User\User $user;
|
||||
|
||||
private $userId;
|
||||
|
||||
/**
|
||||
* @var StoragesService
|
||||
*/
|
||||
protected $globalStoragesService;
|
||||
protected string $userId;
|
||||
protected StoragesService $globalStoragesService;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
@ -43,7 +40,7 @@ class UserStoragesServiceTest extends StoragesServiceTest {
|
|||
$this->createUser($this->userId, $this->userId);
|
||||
$this->user = Server::get(IUserManager::class)->get($this->userId);
|
||||
|
||||
/** @var IUserSession|\PHPUnit\Framework\MockObject\MockObject $userSession */
|
||||
/** @var IUserSession&MockObject $userSession */
|
||||
$userSession = $this->createMock(IUserSession::class);
|
||||
$userSession
|
||||
->expects($this->any())
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
|
@ -12,19 +14,15 @@ use OCA\Files_External\Service\GlobalStoragesService;
|
|||
use OCA\Files_External\Settings\Admin;
|
||||
use OCP\AppFramework\Http\TemplateResponse;
|
||||
use OCP\Encryption\IManager;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Test\TestCase;
|
||||
|
||||
class AdminTest extends TestCase {
|
||||
/** @var Admin */
|
||||
private $admin;
|
||||
/** @var IManager|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $encryptionManager;
|
||||
/** @var GlobalStoragesService|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $globalStoragesService;
|
||||
/** @var BackendService|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $backendService;
|
||||
/** @var GlobalAuth|\PHPUnit\Framework\MockObject\MockObject */
|
||||
private $globalAuth;
|
||||
private IManager&MockObject $encryptionManager;
|
||||
private GlobalStoragesService&MockObject $globalStoragesService;
|
||||
private BackendService&MockObject $backendService;
|
||||
private GlobalAuth&MockObject $globalAuth;
|
||||
private Admin $admin;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
|
@ -8,20 +10,18 @@ namespace OCA\Files_External\Tests\Settings;
|
|||
use OCA\Files_External\Settings\Section;
|
||||
use OCP\IL10N;
|
||||
use OCP\IURLGenerator;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use Test\TestCase;
|
||||
|
||||
class SectionTest extends TestCase {
|
||||
/** @var IL10N */
|
||||
private $l;
|
||||
/** @var IURLGenerator */
|
||||
private $urlGenerator;
|
||||
/** @var Section */
|
||||
private $section;
|
||||
private IL10N&MockObject $l;
|
||||
private IURLGenerator&MockObject $urlGenerator;
|
||||
private Section $section;
|
||||
|
||||
protected function setUp(): void {
|
||||
parent::setUp();
|
||||
$this->urlGenerator = $this->getMockBuilder(IURLGenerator::class)->disableOriginalConstructor()->getMock();
|
||||
$this->l = $this->getMockBuilder(IL10N::class)->disableOriginalConstructor()->getMock();
|
||||
$this->urlGenerator = $this->createMock(IURLGenerator::class);
|
||||
$this->l = $this->createMock(IL10N::class);
|
||||
|
||||
$this->section = new Section(
|
||||
$this->urlGenerator,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2023 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
|
|
@ -40,7 +42,7 @@ class SFTP_KeyTest extends \Test\Files\Storage\Storage {
|
|||
parent::tearDown();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function testInvalidAddressShouldThrowException(): void {
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
|
||||
|
|
@ -52,24 +54,24 @@ class SFTP_KeyTest extends \Test\Files\Storage\Storage {
|
|||
$this->assertTrue($this->instance->assertHostAddressValid('localhost'));
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function testNegativePortNumberShouldThrowException(): void {
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
|
||||
$this->instance->assertPortNumberValid('-1');
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function testNonNumericalPortNumberShouldThrowException(): void {
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
|
||||
$this->instance->assertPortNumberValid('a');
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function testHighPortNumberShouldThrowException(): void {
|
||||
$this->expectException(\InvalidArgumentException::class);
|
||||
|
||||
|
||||
$this->instance->assertPortNumberValid('65536');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2019-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
|
|
@ -52,7 +54,7 @@ class SftpTest extends \Test\Files\Storage\Storage {
|
|||
$this->assertEquals($expectedStorageId, $instance->getId());
|
||||
}
|
||||
|
||||
public function configProvider() {
|
||||
public static function configProvider(): array {
|
||||
return [
|
||||
[
|
||||
// no root path
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2018-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
/**
|
||||
* SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
|
||||
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
||||
|
|
@ -13,12 +15,8 @@ use OCA\Files_External\Lib\StorageConfig;
|
|||
|
||||
class StorageConfigTest extends \Test\TestCase {
|
||||
public function testJsonSerialization(): void {
|
||||
$backend = $this->getMockBuilder(Backend::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$parameter = $this->getMockBuilder(DefinitionParameter::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$backend = $this->createMock(Backend::class);
|
||||
$parameter = $this->createMock(DefinitionParameter::class);
|
||||
$parameter
|
||||
->expects($this->once())
|
||||
->method('getType')
|
||||
|
|
@ -30,9 +28,7 @@ class StorageConfigTest extends \Test\TestCase {
|
|||
$backend->method('getIdentifier')
|
||||
->willReturn('storage::identifier');
|
||||
|
||||
$authMech = $this->getMockBuilder(AuthMechanism::class)
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$authMech = $this->createMock(AuthMechanism::class);
|
||||
$authMech->method('getIdentifier')
|
||||
->willReturn('auth::identifier');
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue