2014-10-31 06:41:07 -04:00
|
|
|
<?php
|
|
|
|
|
/**
|
2024-06-06 03:55:47 -04:00
|
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2014-10-31 06:41:07 -04:00
|
|
|
*/
|
2016-05-13 05:22:28 -04:00
|
|
|
namespace OCA\Files_External\Tests\Controller;
|
2014-10-31 06:41:07 -04:00
|
|
|
|
2021-01-08 10:14:44 -05:00
|
|
|
use OC\User\User;
|
2016-05-13 05:22:28 -04:00
|
|
|
use OCA\Files_External\Controller\GlobalStoragesController;
|
2019-11-22 14:52:10 -05:00
|
|
|
use OCA\Files_External\Service\BackendService;
|
2023-07-25 15:45:07 -04:00
|
|
|
use OCP\EventDispatcher\IEventDispatcher;
|
2021-12-06 05:18:59 -05:00
|
|
|
use OCP\IConfig;
|
2021-01-08 10:14:44 -05:00
|
|
|
use OCP\IGroupManager;
|
2016-09-02 04:37:20 -04:00
|
|
|
use OCP\IL10N;
|
|
|
|
|
use OCP\IRequest;
|
2021-01-08 10:14:44 -05:00
|
|
|
use OCP\IUserSession;
|
2023-07-20 02:42:15 -04:00
|
|
|
use Psr\Log\LoggerInterface;
|
2014-10-31 06:41:07 -04:00
|
|
|
|
|
|
|
|
class GlobalStoragesControllerTest extends StoragesControllerTest {
|
2019-11-27 09:27:18 -05:00
|
|
|
protected function setUp(): void {
|
2014-10-31 06:41:07 -04:00
|
|
|
parent::setUp();
|
2021-12-06 05:18:59 -05:00
|
|
|
|
2016-05-13 05:22:28 -04:00
|
|
|
$this->service = $this->getMockBuilder('\OCA\Files_External\Service\GlobalStoragesService')
|
2015-08-11 13:45:07 -04:00
|
|
|
->disableOriginalConstructor()
|
|
|
|
|
->getMock();
|
2014-10-31 06:41:07 -04:00
|
|
|
|
2015-09-23 10:35:17 -04:00
|
|
|
$this->service->method('getVisibilityType')
|
|
|
|
|
->willReturn(BackendService::VISIBILITY_ADMIN);
|
|
|
|
|
|
2021-12-06 05:18:59 -05:00
|
|
|
$this->controller = $this->createController(true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private function createController($allowCreateLocal = true) {
|
2021-01-08 10:14:44 -05:00
|
|
|
$session = $this->createMock(IUserSession::class);
|
|
|
|
|
$session->method('getUser')
|
2023-07-25 15:45:07 -04:00
|
|
|
->willReturn(new User('test', null, $this->createMock(IEventDispatcher::class)));
|
2021-01-08 10:14:44 -05:00
|
|
|
|
2021-12-06 05:18:59 -05:00
|
|
|
$config = $this->createMock(IConfig::class);
|
|
|
|
|
$config->method('getSystemValue')
|
|
|
|
|
->with('files_external_allow_create_new_local', true)
|
|
|
|
|
->willReturn($allowCreateLocal);
|
|
|
|
|
|
|
|
|
|
return new GlobalStoragesController(
|
2014-10-31 06:41:07 -04:00
|
|
|
'files_external',
|
2016-09-02 04:37:20 -04:00
|
|
|
$this->createMock(IRequest::class),
|
|
|
|
|
$this->createMock(IL10N::class),
|
2016-01-28 07:07:19 -05:00
|
|
|
$this->service,
|
2023-07-20 02:42:15 -04:00
|
|
|
$this->createMock(LoggerInterface::class),
|
2021-01-08 10:14:44 -05:00
|
|
|
$session,
|
|
|
|
|
$this->createMock(IGroupManager::class),
|
2021-12-06 05:18:59 -05:00
|
|
|
$config
|
2014-10-31 06:41:07 -04:00
|
|
|
);
|
|
|
|
|
}
|
2021-12-06 05:18:59 -05:00
|
|
|
|
|
|
|
|
public function testAddLocalStorageWhenDisabled() {
|
|
|
|
|
$this->controller = $this->createController(false);
|
|
|
|
|
parent::testAddLocalStorageWhenDisabled();
|
|
|
|
|
}
|
2014-10-31 06:41:07 -04:00
|
|
|
}
|