CalDAVSettingsTest.php 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2017 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-License-Identifier: AGPL-3.0-or-later
  5. */
  6. namespace OCA\DAV\Tests\Unit\DAV\Settings;
  7. use OCA\DAV\Settings\CalDAVSettings;
  8. use OCP\AppFramework\Http\TemplateResponse;
  9. use OCP\AppFramework\Services\IInitialState;
  10. use OCP\IConfig;
  11. use OCP\IURLGenerator;
  12. use PHPUnit\Framework\MockObject\MockObject;
  13. use Test\TestCase;
  14. class CalDAVSettingsTest extends TestCase {
  15. /** @var IConfig|MockObject */
  16. private $config;
  17. /** @var IInitialState|MockObject */
  18. private $initialState;
  19. /** @var IURLGenerator|MockObject */
  20. private $urlGenerator;
  21. private CalDAVSettings $settings;
  22. protected function setUp(): void {
  23. parent::setUp();
  24. $this->config = $this->createMock(IConfig::class);
  25. $this->initialState = $this->createMock(IInitialState::class);
  26. $this->urlGenerator = $this->createMock(IURLGenerator::class);
  27. $this->settings = new CalDAVSettings($this->config, $this->initialState, $this->urlGenerator);
  28. }
  29. public function testGetForm(): void {
  30. $this->config->method('getAppValue')
  31. ->withConsecutive(
  32. ['dav', 'sendInvitations', 'yes'],
  33. ['dav', 'generateBirthdayCalendar', 'yes'],
  34. ['dav', 'sendEventReminders', 'yes'],
  35. ['dav', 'sendEventRemindersToSharedUsers', 'yes'],
  36. ['dav', 'sendEventRemindersPush', 'yes'],
  37. )
  38. ->will($this->onConsecutiveCalls('yes', 'no', 'yes', 'yes', 'yes'));
  39. $this->urlGenerator
  40. ->expects($this->once())
  41. ->method('linkToDocs')
  42. ->with('user-sync-calendars')
  43. ->willReturn('Some docs URL');
  44. $this->initialState->method('provideInitialState')
  45. ->withConsecutive(
  46. ['userSyncCalendarsDocUrl', 'Some docs URL'],
  47. ['sendInvitations', true],
  48. ['generateBirthdayCalendar', false],
  49. ['sendEventReminders', true],
  50. ['sendEventRemindersToSharedUsers', true],
  51. ['sendEventRemindersPush', true],
  52. );
  53. $result = $this->settings->getForm();
  54. $this->assertInstanceOf(TemplateResponse::class, $result);
  55. }
  56. public function testGetSection(): void {
  57. $this->assertEquals('groupware', $this->settings->getSection());
  58. }
  59. public function testGetPriority(): void {
  60. $this->assertEquals(10, $this->settings->getPriority());
  61. }
  62. }