CalDAVSettingsTest.php 3.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. /** @var CalDAVSettings */
  42. private CalDAVSettings $settings;
  43. protected function setUp(): void {
  44. parent::setUp();
  45. $this->config = $this->createMock(IConfig::class);
  46. $this->initialState = $this->createMock(IInitialState::class);
  47. $this->urlGenerator = $this->createMock(IURLGenerator::class);
  48. $this->settings = new CalDAVSettings($this->config, $this->initialState, $this->urlGenerator);
  49. }
  50. public function testGetForm() {
  51. $this->config->method('getAppValue')
  52. ->withConsecutive(
  53. ['dav', 'sendInvitations', 'yes'],
  54. ['dav', 'generateBirthdayCalendar', 'yes'],
  55. ['dav', 'sendEventReminders', 'yes'],
  56. ['dav', 'sendEventRemindersToSharedGroupMembers', 'yes'],
  57. ['dav', 'sendEventRemindersPush', 'no'],
  58. )
  59. ->will($this->onConsecutiveCalls('yes', 'no', 'yes', 'yes', 'yes'));
  60. $this->urlGenerator
  61. ->expects($this->once())
  62. ->method('linkToDocs')
  63. ->with('user-sync-calendars')
  64. ->willReturn('Some docs URL');
  65. $this->initialState->method('provideInitialState')
  66. ->withConsecutive(
  67. ['userSyncCalendarsDocUrl', 'Some docs URL'],
  68. ['sendInvitations', true],
  69. ['generateBirthdayCalendar', false],
  70. ['sendEventReminders', true],
  71. ['sendEventRemindersToSharedGroupMembers', true],
  72. ['sendEventRemindersPush', true],
  73. );
  74. $result = $this->settings->getForm();
  75. $this->assertInstanceOf(TemplateResponse::class, $result);
  76. }
  77. public function testGetSection() {
  78. $this->assertEquals('groupware', $this->settings->getSection());
  79. }
  80. public function testGetPriority() {
  81. $this->assertEquals(10, $this->settings->getPriority());
  82. }
  83. }