You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

CalDAVSettingsTest.php 3.0KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. <?php
  2. /**
  3. * @copyright 2017, Georg Ehrke <oc.list@georgehrke.com>
  4. *
  5. * @author Georg Ehrke <oc.list@georgehrke.com>
  6. * @author Julius Härtl <jus@bitgrid.net>
  7. * @author Morris Jobke <hey@morrisjobke.de>
  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\DAV\Tests\Unit\DAV\Settings;
  27. use OCA\DAV\Settings\CalDAVSettings;
  28. use OCP\AppFramework\Http\TemplateResponse;
  29. use OCP\IConfig;
  30. use OCP\AppFramework\Services\IInitialState;
  31. use OCP\IURLGenerator;
  32. use PHPUnit\Framework\MockObject\MockObject;
  33. use Test\TestCase;
  34. class CalDAVSettingsTest extends TestCase {
  35. /** @var IConfig|MockObject */
  36. private $config;
  37. /** @var IInitialState|MockObject */
  38. private $initialState;
  39. /** @var IURLGenerator|MockObject */
  40. private $urlGenerator;
  41. private CalDAVSettings $settings;
  42. protected function setUp(): void {
  43. parent::setUp();
  44. $this->config = $this->createMock(IConfig::class);
  45. $this->initialState = $this->createMock(IInitialState::class);
  46. $this->urlGenerator = $this->createMock(IURLGenerator::class);
  47. $this->settings = new CalDAVSettings($this->config, $this->initialState, $this->urlGenerator);
  48. }
  49. public function testGetForm() {
  50. $this->config->method('getAppValue')
  51. ->withConsecutive(
  52. ['dav', 'sendInvitations', 'yes'],
  53. ['dav', 'generateBirthdayCalendar', 'yes'],
  54. ['dav', 'sendEventReminders', 'yes'],
  55. ['dav', 'sendEventRemindersToSharedGroupMembers', 'yes'],
  56. ['dav', 'sendEventRemindersPush', 'no'],
  57. )
  58. ->will($this->onConsecutiveCalls('yes', 'no', 'yes', 'yes', 'yes'));
  59. $this->urlGenerator
  60. ->expects($this->once())
  61. ->method('linkToDocs')
  62. ->with('user-sync-calendars')
  63. ->willReturn('Some docs URL');
  64. $this->initialState->method('provideInitialState')
  65. ->withConsecutive(
  66. ['userSyncCalendarsDocUrl', 'Some docs URL'],
  67. ['sendInvitations', true],
  68. ['generateBirthdayCalendar', false],
  69. ['sendEventReminders', true],
  70. ['sendEventRemindersToSharedGroupMembers', true],
  71. ['sendEventRemindersPush', true],
  72. );
  73. $result = $this->settings->getForm();
  74. $this->assertInstanceOf(TemplateResponse::class, $result);
  75. }
  76. public function testGetSection() {
  77. $this->assertEquals('groupware', $this->settings->getSection());
  78. }
  79. public function testGetPriority() {
  80. $this->assertEquals(10, $this->settings->getPriority());
  81. }
  82. }