PluginTest.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016 Lukas Reschke <lukas@statuscode.ch>
  4. *
  5. * @author Georg Ehrke <oc.list@georgehrke.com>
  6. * @author Lukas Reschke <lukas@statuscode.ch>
  7. * @author Roeland Jago Douma <roeland@famdouma.nl>
  8. *
  9. * @license GNU AGPL version 3 or any later version
  10. *
  11. * This program is free software: you can redistribute it and/or modify
  12. * it under the terms of the GNU Affero General Public License as
  13. * published by the Free Software Foundation, either version 3 of the
  14. * License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU Affero General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU Affero General Public License
  22. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. *
  24. */
  25. namespace OCA\DAV\Tests\unit\CalDAV;
  26. use OCA\DAV\CalDAV\Plugin;
  27. use Test\TestCase;
  28. class PluginTest extends TestCase {
  29. /** @var Plugin */
  30. private $plugin;
  31. protected function setUp(): void {
  32. parent::setUp();
  33. $this->plugin = new Plugin();
  34. }
  35. public function linkProvider() {
  36. return [
  37. [
  38. 'principals/users/MyUserName',
  39. 'calendars/MyUserName',
  40. ],
  41. [
  42. 'principals/calendar-resources/Resource-ABC',
  43. 'system-calendars/calendar-resources/Resource-ABC',
  44. ],
  45. [
  46. 'principals/calendar-rooms/Room-ABC',
  47. 'system-calendars/calendar-rooms/Room-ABC',
  48. ],
  49. ];
  50. }
  51. /**
  52. * @dataProvider linkProvider
  53. *
  54. * @param $input
  55. * @param $expected
  56. */
  57. public function testGetCalendarHomeForPrincipal($input, $expected) {
  58. $this->assertSame($expected, $this->plugin->getCalendarHomeForPrincipal($input));
  59. }
  60. public function testGetCalendarHomeForUnknownPrincipal() {
  61. $this->assertNull($this->plugin->getCalendarHomeForPrincipal('FOO/BAR/BLUB'));
  62. }
  63. }