GlobalStoragesControllerTest.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OCA\Files_External\Tests\Controller;
  8. use OC\User\User;
  9. use OCA\Files_External\Controller\GlobalStoragesController;
  10. use OCA\Files_External\Service\BackendService;
  11. use OCP\EventDispatcher\IEventDispatcher;
  12. use OCP\IConfig;
  13. use OCP\IGroupManager;
  14. use OCP\IL10N;
  15. use OCP\IRequest;
  16. use OCP\IUserSession;
  17. use Psr\Log\LoggerInterface;
  18. class GlobalStoragesControllerTest extends StoragesControllerTest {
  19. protected function setUp(): void {
  20. parent::setUp();
  21. $this->service = $this->getMockBuilder('\OCA\Files_External\Service\GlobalStoragesService')
  22. ->disableOriginalConstructor()
  23. ->getMock();
  24. $this->service->method('getVisibilityType')
  25. ->willReturn(BackendService::VISIBILITY_ADMIN);
  26. $this->controller = $this->createController(true);
  27. }
  28. private function createController($allowCreateLocal = true) {
  29. $session = $this->createMock(IUserSession::class);
  30. $session->method('getUser')
  31. ->willReturn(new User('test', null, $this->createMock(IEventDispatcher::class)));
  32. $config = $this->createMock(IConfig::class);
  33. $config->method('getSystemValue')
  34. ->with('files_external_allow_create_new_local', true)
  35. ->willReturn($allowCreateLocal);
  36. return new GlobalStoragesController(
  37. 'files_external',
  38. $this->createMock(IRequest::class),
  39. $this->createMock(IL10N::class),
  40. $this->service,
  41. $this->createMock(LoggerInterface::class),
  42. $session,
  43. $this->createMock(IGroupManager::class),
  44. $config
  45. );
  46. }
  47. public function testAddLocalStorageWhenDisabled(): void {
  48. $this->controller = $this->createController(false);
  49. parent::testAddLocalStorageWhenDisabled();
  50. }
  51. }