GlobalStoragesControllerTest.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Joas Schilling <coding@schilljs.com>
  6. * @author Robin Appelman <robin@icewind.nl>
  7. * @author Robin McCorkell <robin@mccorkell.me.uk>
  8. * @author Roeland Jago Douma <roeland@famdouma.nl>
  9. * @author Vincent Petry <vincent@nextcloud.com>
  10. *
  11. * @license AGPL-3.0
  12. *
  13. * This code is free software: you can redistribute it and/or modify
  14. * it under the terms of the GNU Affero General Public License, version 3,
  15. * as published by the Free Software Foundation.
  16. *
  17. * This program is distributed in the hope that it will be useful,
  18. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  20. * GNU Affero General Public License for more details.
  21. *
  22. * You should have received a copy of the GNU Affero General Public License, version 3,
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>
  24. *
  25. */
  26. namespace OCA\Files_External\Tests\Controller;
  27. use OC\User\User;
  28. use OCA\Files_External\Controller\GlobalStoragesController;
  29. use OCA\Files_External\Service\BackendService;
  30. use OCP\EventDispatcher\IEventDispatcher;
  31. use OCP\IConfig;
  32. use OCP\IGroupManager;
  33. use OCP\IL10N;
  34. use OCP\IRequest;
  35. use OCP\IUserSession;
  36. use Psr\Log\LoggerInterface;
  37. class GlobalStoragesControllerTest extends StoragesControllerTest {
  38. protected function setUp(): void {
  39. parent::setUp();
  40. $this->service = $this->getMockBuilder('\OCA\Files_External\Service\GlobalStoragesService')
  41. ->disableOriginalConstructor()
  42. ->getMock();
  43. $this->service->method('getVisibilityType')
  44. ->willReturn(BackendService::VISIBILITY_ADMIN);
  45. $this->controller = $this->createController(true);
  46. }
  47. private function createController($allowCreateLocal = true) {
  48. $session = $this->createMock(IUserSession::class);
  49. $session->method('getUser')
  50. ->willReturn(new User('test', null, $this->createMock(IEventDispatcher::class)));
  51. $config = $this->createMock(IConfig::class);
  52. $config->method('getSystemValue')
  53. ->with('files_external_allow_create_new_local', true)
  54. ->willReturn($allowCreateLocal);
  55. return new GlobalStoragesController(
  56. 'files_external',
  57. $this->createMock(IRequest::class),
  58. $this->createMock(IL10N::class),
  59. $this->service,
  60. $this->createMock(LoggerInterface::class),
  61. $session,
  62. $this->createMock(IGroupManager::class),
  63. $config
  64. );
  65. }
  66. public function testAddLocalStorageWhenDisabled() {
  67. $this->controller = $this->createController(false);
  68. parent::testAddLocalStorageWhenDisabled();
  69. }
  70. }