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.

PluginTest.php 1.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2018 Georg Ehrke
  4. *
  5. * @author Georg Ehrke <oc.list@georgehrke.com>
  6. *
  7. * @license AGPL-3.0
  8. *
  9. * This code is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU Affero General Public License, version 3,
  11. * as published by the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU Affero General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Affero General Public License, version 3,
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>
  20. *
  21. */
  22. namespace OCA\DAV\Tests\unit\CalDAV\WebcalCaching;
  23. use OCA\DAV\CalDAV\WebcalCaching\Plugin;
  24. use OCP\IRequest;
  25. class PluginTest extends \Test\TestCase {
  26. public function testDisabled() {
  27. $request = $this->createMock(IRequest::class);
  28. $request->expects($this->at(0))
  29. ->method('isUserAgent')
  30. ->with([])
  31. ->will($this->returnValue(false));
  32. $request->expects($this->at(1))
  33. ->method('getHeader')
  34. ->with('X-NC-CalDAV-Webcal-Caching')
  35. ->will($this->returnValue(''));
  36. $plugin = new Plugin($request);
  37. $this->assertEquals(false, $plugin->isCachingEnabledForThisRequest());
  38. }
  39. public function testEnabled() {
  40. $request = $this->createMock(IRequest::class);
  41. $request->expects($this->at(0))
  42. ->method('isUserAgent')
  43. ->with([])
  44. ->will($this->returnValue(false));
  45. $request->expects($this->at(1))
  46. ->method('getHeader')
  47. ->with('X-NC-CalDAV-Webcal-Caching')
  48. ->will($this->returnValue('On'));
  49. $plugin = new Plugin($request);
  50. $this->assertEquals(true, $plugin->isCachingEnabledForThisRequest());
  51. }
  52. }