CapabilitiesTest.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016 MasterOfDeath <rinat.gumirov@mail.ru>
  4. *
  5. * @author Christoph Wurst <christoph@winzerhof-wurst.at>
  6. * @author John Molakvoæ <skjnldsv@protonmail.com>
  7. * @author MasterOfDeath <rinat.gumirov@mail.ru>
  8. * @author Roeland Jago Douma <roeland@famdouma.nl>
  9. *
  10. * @license GNU AGPL version 3 or any later version
  11. *
  12. * This program is free software: you can redistribute it and/or modify
  13. * it under the terms of the GNU Affero General Public License as
  14. * published by the Free Software Foundation, either version 3 of the
  15. * License, or (at your option) any later version.
  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
  23. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  24. *
  25. */
  26. namespace OCA\ShareByMail\Tests;
  27. use OCA\ShareByMail\Capabilities;
  28. use OCA\ShareByMail\Settings\SettingsManager;
  29. use OCP\App\IAppManager;
  30. use OCP\Share\IManager;
  31. use Test\TestCase;
  32. class CapabilitiesTest extends TestCase {
  33. /** @var Capabilities */
  34. private $capabilities;
  35. /** @var IManager | \PHPUnit\Framework\MockObject\MockObject */
  36. private $manager;
  37. /** @var IManager | \PHPUnit\Framework\MockObject\MockObject */
  38. private $settingsManager;
  39. /** @var IAppManager | \PHPUnit\Framework\MockObject\MockObject */
  40. private $appManager;
  41. protected function setUp(): void {
  42. parent::setUp();
  43. $this->manager = $this::createMock(IManager::class);
  44. $this->settingsManager = $this::createMock(SettingsManager::class);
  45. $this->appManager = $this::createMock(IAppManager::class);
  46. $this->capabilities = new Capabilities($this->manager, $this->settingsManager, $this->appManager);
  47. }
  48. public function testGetCapabilities() {
  49. $this->manager->method('shareApiAllowLinks')
  50. ->willReturn(true);
  51. $this->manager->method('shareApiLinkEnforcePassword')
  52. ->willReturn(false);
  53. $this->manager->method('shareApiLinkDefaultExpireDateEnforced')
  54. ->willReturn(false);
  55. $this->settingsManager->method('sendPasswordByMail')
  56. ->willReturn(true);
  57. $this->appManager->method('isEnabledForUser')
  58. ->willReturn(true);
  59. $capabilities = [
  60. 'files_sharing' =>
  61. [
  62. 'sharebymail' =>
  63. [
  64. 'enabled' => true,
  65. 'send_password_by_mail' => true,
  66. 'upload_files_drop' => [
  67. 'enabled' => true,
  68. ],
  69. 'password' => [
  70. 'enabled' => true,
  71. 'enforced' => false,
  72. ],
  73. 'expire_date' => [
  74. 'enabled' => true,
  75. 'enforced' => false,
  76. ],
  77. ]
  78. ]
  79. ];
  80. $this->assertSame($capabilities, $this->capabilities->getCapabilities());
  81. }
  82. }