CapabilitiesTest.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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\Share\IManager;
  30. use Test\TestCase;
  31. class CapabilitiesTest extends TestCase {
  32. /** @var Capabilities */
  33. private $capabilities;
  34. /** @var IManager | \PHPUnit\Framework\MockObject\MockObject */
  35. private $manager;
  36. /** @var IManager | \PHPUnit\Framework\MockObject\MockObject */
  37. private $settingsManager;
  38. protected function setUp(): void {
  39. parent::setUp();
  40. $this->manager = $this::createMock(IManager::class);
  41. $this->settingsManager = $this::createMock(SettingsManager::class);
  42. $this->capabilities = new Capabilities($this->manager, $this->settingsManager);
  43. }
  44. public function testGetCapabilities() {
  45. $this->manager->method('shareApiAllowLinks')
  46. ->willReturn(true);
  47. $this->manager->method('shareApiLinkEnforcePassword')
  48. ->willReturn(false);
  49. $this->manager->method('shareApiLinkDefaultExpireDateEnforced')
  50. ->willReturn(false);
  51. $this->settingsManager->method('sendPasswordByMail')
  52. ->willReturn(true);
  53. $capabilities = [
  54. 'files_sharing' =>
  55. [
  56. 'sharebymail' =>
  57. [
  58. 'enabled' => true,
  59. 'send_password_by_mail' => true,
  60. 'upload_files_drop' => [
  61. 'enabled' => true,
  62. ],
  63. 'password' => [
  64. 'enabled' => true,
  65. 'enforced' => false,
  66. ],
  67. 'expire_date' => [
  68. 'enabled' => true,
  69. 'enforced' => false,
  70. ],
  71. ]
  72. ]
  73. ];
  74. $this->assertSame($capabilities, $this->capabilities->getCapabilities());
  75. }
  76. }