1
0

CapabilitiesTest.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OCA\ShareByMail\Tests;
  7. use OCA\ShareByMail\Capabilities;
  8. use OCA\ShareByMail\Settings\SettingsManager;
  9. use OCP\App\IAppManager;
  10. use OCP\Share\IManager;
  11. use Test\TestCase;
  12. class CapabilitiesTest extends TestCase {
  13. /** @var Capabilities */
  14. private $capabilities;
  15. /** @var IManager | \PHPUnit\Framework\MockObject\MockObject */
  16. private $manager;
  17. /** @var IManager | \PHPUnit\Framework\MockObject\MockObject */
  18. private $settingsManager;
  19. /** @var IAppManager | \PHPUnit\Framework\MockObject\MockObject */
  20. private $appManager;
  21. protected function setUp(): void {
  22. parent::setUp();
  23. $this->manager = $this::createMock(IManager::class);
  24. $this->settingsManager = $this::createMock(SettingsManager::class);
  25. $this->appManager = $this::createMock(IAppManager::class);
  26. $this->capabilities = new Capabilities($this->manager, $this->settingsManager, $this->appManager);
  27. }
  28. public function testGetCapabilities() {
  29. $this->manager->method('shareApiAllowLinks')
  30. ->willReturn(true);
  31. $this->manager->method('shareApiLinkEnforcePassword')
  32. ->willReturn(false);
  33. $this->manager->method('shareApiLinkDefaultExpireDateEnforced')
  34. ->willReturn(false);
  35. $this->settingsManager->method('sendPasswordByMail')
  36. ->willReturn(true);
  37. $this->appManager->method('isEnabledForUser')
  38. ->willReturn(true);
  39. $capabilities = [
  40. 'files_sharing' =>
  41. [
  42. 'sharebymail' =>
  43. [
  44. 'enabled' => true,
  45. 'send_password_by_mail' => true,
  46. 'upload_files_drop' => [
  47. 'enabled' => true,
  48. ],
  49. 'password' => [
  50. 'enabled' => true,
  51. 'enforced' => false,
  52. ],
  53. 'expire_date' => [
  54. 'enabled' => true,
  55. 'enforced' => false,
  56. ],
  57. ]
  58. ]
  59. ];
  60. $this->assertSame($capabilities, $this->capabilities->getCapabilities());
  61. }
  62. }