GetEventsByTimerangeTest.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace Sabre\CalDAV;
  3. use Sabre\HTTP;
  4. /**
  5. * This unittest is created to check if queries for time-range include the start timestamp or not
  6. *
  7. * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
  8. * @author Evert Pot (http://evertpot.com/)
  9. * @license http://sabre.io/license/ Modified BSD License
  10. */
  11. class GetEventsByTimerangeTest extends \Sabre\DAVServerTest {
  12. protected $setupCalDAV = true;
  13. protected $caldavCalendars = [
  14. [
  15. 'id' => 1,
  16. 'name' => 'Calendar',
  17. 'principaluri' => 'principals/user1',
  18. 'uri' => 'calendar1',
  19. ]
  20. ];
  21. protected $caldavCalendarObjects = [
  22. 1 => [
  23. 'event.ics' => [
  24. 'calendardata' => 'BEGIN:VCALENDAR
  25. VERSION:2.0
  26. BEGIN:VEVENT
  27. CREATED:20120313T142342Z
  28. UID:171EBEFC-C951-499D-B234-7BA7D677B45D
  29. DTEND;TZID=Europe/Berlin:20120227T010000
  30. TRANSP:OPAQUE
  31. SUMMARY:Monday 0h
  32. DTSTART;TZID=Europe/Berlin:20120227T000000
  33. DTSTAMP:20120313T142416Z
  34. SEQUENCE:4
  35. END:VEVENT
  36. END:VCALENDAR
  37. ',
  38. ],
  39. ],
  40. ];
  41. function testQueryTimerange() {
  42. $request = new HTTP\Request(
  43. 'REPORT',
  44. '/calendars/user1/calendar1',
  45. [
  46. 'Content-Type' => 'application/xml',
  47. 'Depth' => '1',
  48. ]
  49. );
  50. $request->setBody('<?xml version="1.0" encoding="utf-8" ?>
  51. <C:calendar-query xmlns:D="DAV:" xmlns:C="urn:ietf:params:xml:ns:caldav">
  52. <D:prop>
  53. <C:calendar-data>
  54. <C:expand start="20120226T220000Z" end="20120228T225959Z"/>
  55. </C:calendar-data>
  56. <D:getetag/>
  57. </D:prop>
  58. <C:filter>
  59. <C:comp-filter name="VCALENDAR">
  60. <C:comp-filter name="VEVENT">
  61. <C:time-range start="20120226T220000Z" end="20120228T225959Z"/>
  62. </C:comp-filter>
  63. </C:comp-filter>
  64. </C:filter>
  65. </C:calendar-query>');
  66. $response = $this->request($request);
  67. $this->assertTrue(strpos($response->body, 'BEGIN:VCALENDAR')!==false);
  68. }
  69. }