diff --git a/dav/SabreDAV/ChangeLog b/dav/SabreDAV/ChangeLog index 1199ae766..3f424d953 100644 --- a/dav/SabreDAV/ChangeLog +++ b/dav/SabreDAV/ChangeLog @@ -14,6 +14,7 @@ only used for informational purposes. * BC Break: The DAV: namespace is no longer converted to urn:DAV. This was a workaround for a bug in older PHP versions (pre-5.3). + * Changed: The Sabre_VObject library now spawned into it's own project! * New feature: Support for caldav notifications! * Changed: Responsibility for dealing with the calendar-query is now moved from the CalDAV plugin to the CalDAV backends. This allows for @@ -33,13 +34,14 @@ * Fixed: Uploaded VCards without a UID are now rejected. (thanks Dominik!) * Fixed: Rejecting calendar objects if they are not in the supported-calendar-component list. (thanks Armin!) - * Fixed: Workaround for 10.8 Mountain Lion vCards, as it needs \r line - endings to parse them correctly. * Fixed: Issue 219: serialize() now reorders correctly. * Fixed: Sabre_DAV_XMLUtil no longer returns empty $dom->childNodes if there is whitespace in $dom. -1.6.4-stable (2012-??-??) +1.6.5-stable (2012-??-??) + * Fixed: Workaround for line-ending bug OS X 10.8 addressbook has. + +1.6.4-stable (2012-08-02) * Fixed: Issue 220: Calendar-query filters may fail when filtering on alarms, if an overridden event has it's alarm removed. * Fixed: Compatibility for OS/X 10.8 iCal in the IMipHandler. @@ -56,6 +58,8 @@ exactly on the start of a time-range. * Fixed: HTTP basic auth did not correctly deal with passwords containing colons on some servers. + * Fixed: Issue 228: DTEND is now non-inclusive for all-day events in the + calendar-query REPORT and free-busy calculations. 1.6.3-stable (2012-06-12) * Added: It's now possible to specify in Sabre_DAV_Client which type of diff --git a/dav/SabreDAV/composer.json b/dav/SabreDAV/composer.json index 8875829ec..1a427e762 100644 --- a/dav/SabreDAV/composer.json +++ b/dav/SabreDAV/composer.json @@ -1,21 +1,30 @@ { - "name": "evert/sabredav", + "name": "sabre/dav", "type": "library", "description": "WebDAV Framework for PHP", "keywords": ["Framework", "WebDAV", "CalDAV", "CardDAV", "iCalendar"], "homepage": "http://code.google.com/p/sabredav/", - "license": "New BSD License", + "license" : "BSD-3-Clause", "authors": [ { "name": "Evert Pot", "email": "evert@rooftopsolutions.nl", - "homepage" : "http://www.rooftopsolutions.nl/" + "homepage" : "http://www.rooftopsolutions.nl/", + "role" : "Developer" } ], "require": { - "php": ">=5.3.1" + "php": ">=5.3.1", + "sabre/vobject" : "master-dev" + }, + "provide" : { + "evert/sabredav" : "2.0.0" }, "autoload": { "psr-0": { "Sabre": "lib/" } + }, + "support" : { + "forum" : "https://groups.google.com/group/sabredav-discuss", + "source" : "https://github.com/evert/sabredav" } } diff --git a/dav/SabreDAV/lib/Sabre/CalDAV/Backend/Abstract.php b/dav/SabreDAV/lib/Sabre/CalDAV/Backend/Abstract.php index 480e6329f..8adf10e1b 100644 --- a/dav/SabreDAV/lib/Sabre/CalDAV/Backend/Abstract.php +++ b/dav/SabreDAV/lib/Sabre/CalDAV/Backend/Abstract.php @@ -1,5 +1,7 @@ getCalendarObject($object['calendarid'], $object['uri']); } - $vObject = Sabre_VObject_Reader::read($object['calendardata']); + $vObject = VObject\Reader::read($object['calendardata']); $validator = new Sabre_CalDAV_CalendarQueryValidator(); return $validator->validate($vObject, $filters); diff --git a/dav/SabreDAV/lib/Sabre/CalDAV/Backend/PDO.php b/dav/SabreDAV/lib/Sabre/CalDAV/Backend/PDO.php index 105ebd338..74b34267f 100644 --- a/dav/SabreDAV/lib/Sabre/CalDAV/Backend/PDO.php +++ b/dav/SabreDAV/lib/Sabre/CalDAV/Backend/PDO.php @@ -1,5 +1,7 @@ DTEND->getDateTime()->getTimeStamp(); } elseif (isset($component->DURATION)) { $endDate = clone $component->DTSTART->getDateTime(); - $endDate->add(Sabre_VObject_DateTimeParser::parse($component->DURATION->value)); + $endDate->add(VObject\DateTimeParser::parse($component->DURATION->value)); $lastOccurence = $endDate->getTimeStamp(); - } elseif ($component->DTSTART->getDateType()===Sabre_VObject_Property_DateTime::DATE) { + } elseif ($component->DTSTART->getDateType()===VObject\Property\DateTime::DATE) { $endDate = clone $component->DTSTART->getDateTime(); $endDate->modify('+1 day'); $lastOccurence = $endDate->getTimeStamp(); @@ -494,7 +496,7 @@ class Sabre_CalDAV_Backend_PDO extends Sabre_CalDAV_Backend_Abstract { $lastOccurence = $firstOccurence; } } else { - $it = new Sabre_VObject_RecurrenceIterator($vObject, (string)$component->UID); + $it = new VObject\RecurrenceIterator($vObject, (string)$component->UID); $maxDate = new DateTime(self::MAX_DATE); if ($it->isInfinite()) { $lastOccurence = $maxDate->getTimeStamp(); diff --git a/dav/SabreDAV/lib/Sabre/CalDAV/CalendarQueryParser.php b/dav/SabreDAV/lib/Sabre/CalDAV/CalendarQueryParser.php index 098edccca..b95095f96 100644 --- a/dav/SabreDAV/lib/Sabre/CalDAV/CalendarQueryParser.php +++ b/dav/SabreDAV/lib/Sabre/CalDAV/CalendarQueryParser.php @@ -1,5 +1,7 @@ item(0); if ($start = $timeRangeNode->getAttribute('start')) { - $start = Sabre_VObject_DateTimeParser::parseDateTime($start); + $start = VObject\DateTimeParser::parseDateTime($start); } else { $start = null; } if ($end = $timeRangeNode->getAttribute('end')) { - $end = Sabre_VObject_DateTimeParser::parseDateTime($end); + $end = VObject\DateTimeParser::parseDateTime($end); } else { $end = null; } @@ -274,13 +276,13 @@ class Sabre_CalDAV_CalendarQueryParser { if(!$start) { throw new Sabre_DAV_Exception_BadRequest('The "start" attribute is required for the CALDAV:expand element'); } - $start = Sabre_VObject_DateTimeParser::parseDateTime($start); + $start = VObject\DateTimeParser::parseDateTime($start); $end = $parentNode->getAttribute('end'); if(!$end) { throw new Sabre_DAV_Exception_BadRequest('The "end" attribute is required for the CALDAV:expand element'); } - $end = Sabre_VObject_DateTimeParser::parseDateTime($end); + $end = VObject\DateTimeParser::parseDateTime($end); if ($end <= $start) { throw new Sabre_DAV_Exception_BadRequest('The end-date must be larger than the start-date in the expand element.'); diff --git a/dav/SabreDAV/lib/Sabre/CalDAV/CalendarQueryValidator.php b/dav/SabreDAV/lib/Sabre/CalDAV/CalendarQueryValidator.php index 8f674840e..53e86fc50 100644 --- a/dav/SabreDAV/lib/Sabre/CalDAV/CalendarQueryValidator.php +++ b/dav/SabreDAV/lib/Sabre/CalDAV/CalendarQueryValidator.php @@ -1,5 +1,7 @@ parent->name === 'VEVENT' && $component->parent->RRULE) { // Fire up the iterator! - $it = new Sabre_VObject_RecurrenceIterator($component->parent->parent, (string)$component->parent->UID); + $it = new VObject\RecurrenceIterator($component->parent->parent, (string)$component->parent->UID); while($it->valid()) { $expandedEvent = $it->getEventObject(); diff --git a/dav/SabreDAV/lib/Sabre/CalDAV/ICSExportPlugin.php b/dav/SabreDAV/lib/Sabre/CalDAV/ICSExportPlugin.php index ec42b406b..d3e4e7b72 100644 --- a/dav/SabreDAV/lib/Sabre/CalDAV/ICSExportPlugin.php +++ b/dav/SabreDAV/lib/Sabre/CalDAV/ICSExportPlugin.php @@ -1,5 +1,7 @@ version = '2.0'; if (Sabre_DAV_Server::$exposeVersion) { $calendar->prodid = '-//SabreDAV//SabreDAV ' . Sabre_DAV_Version::VERSION . '//EN'; @@ -103,7 +105,7 @@ class Sabre_CalDAV_ICSExportPlugin extends Sabre_DAV_ServerPlugin { } $nodeData = $node[200]['{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}calendar-data']; - $nodeComp = Sabre_VObject_Reader::read($nodeData); + $nodeComp = VObject\Reader::read($nodeData); foreach($nodeComp->children() as $child) { diff --git a/dav/SabreDAV/lib/Sabre/CalDAV/Plugin.php b/dav/SabreDAV/lib/Sabre/CalDAV/Plugin.php index 0b0978f14..c0e4a206d 100644 --- a/dav/SabreDAV/lib/Sabre/CalDAV/Plugin.php +++ b/dav/SabreDAV/lib/Sabre/CalDAV/Plugin.php @@ -1,5 +1,7 @@ server->getPropertiesForPath($uri,$properties); if ($expand && isset($objProps[200]['{' . self::NS_CALDAV . '}calendar-data'])) { - $vObject = Sabre_VObject_Reader::read($objProps[200]['{' . self::NS_CALDAV . '}calendar-data']); + $vObject = VObject\Reader::read($objProps[200]['{' . self::NS_CALDAV . '}calendar-data']); $vObject->expand($start, $end); $objProps[200]['{' . self::NS_CALDAV . '}calendar-data'] = $vObject->serialize(); } @@ -543,7 +545,7 @@ class Sabre_CalDAV_Plugin extends Sabre_DAV_ServerPlugin { if (isset($properties[200]['{urn:ietf:params:xml:ns:caldav}calendar-data'])) { $validator = new Sabre_CalDAV_CalendarQueryValidator(); - $vObject = Sabre_VObject_Reader::read($properties[200]['{urn:ietf:params:xml:ns:caldav}calendar-data']); + $vObject = VObject\Reader::read($properties[200]['{urn:ietf:params:xml:ns:caldav}calendar-data']); if ($validator->validate($vObject,$parser->filters)) { // If the client didn't require the calendar-data property, @@ -577,7 +579,7 @@ class Sabre_CalDAV_Plugin extends Sabre_DAV_ServerPlugin { if ($parser->expand) { // We need to do some post-processing - $vObject = Sabre_VObject_Reader::read($properties[200]['{urn:ietf:params:xml:ns:caldav}calendar-data']); + $vObject = VObject\Reader::read($properties[200]['{urn:ietf:params:xml:ns:caldav}calendar-data']); $vObject->expand($parser->expand['start'], $parser->expand['end']); $properties[200]['{' . self::NS_CALDAV . '}calendar-data'] = $vObject->serialize(); } @@ -617,10 +619,10 @@ class Sabre_CalDAV_Plugin extends Sabre_DAV_ServerPlugin { } if ($start) { - $start = Sabre_VObject_DateTimeParser::parseDateTime($start); + $start = VObject\DateTimeParser::parseDateTime($start); } if ($end) { - $end = Sabre_VObject_DateTimeParser::parseDateTime($end); + $end = VObject\DateTimeParser::parseDateTime($end); } if (!$start && !$end) { @@ -647,7 +649,7 @@ class Sabre_CalDAV_Plugin extends Sabre_DAV_ServerPlugin { return $obj; }, $calendar->getChildren()); - $generator = new Sabre_VObject_FreeBusyGenerator(); + $generator = new VObject\FreeBusyGenerator(); $generator->setObjects($objects); $generator->setTimeRange($start, $end); $result = $generator->getResult(); @@ -763,9 +765,9 @@ class Sabre_CalDAV_Plugin extends Sabre_DAV_ServerPlugin { try { - $vobj = Sabre_VObject_Reader::read($data); + $vobj = VObject\Reader::read($data); - } catch (Sabre_VObject_ParseException $e) { + } catch (VObject\ParseException $e) { throw new Sabre_DAV_Exception_UnsupportedMediaType('This resource only supports valid iCalendar 2.0 data. Parse error: ' . $e->getMessage()); @@ -868,8 +870,8 @@ class Sabre_CalDAV_Plugin extends Sabre_DAV_ServerPlugin { } try { - $vObject = Sabre_VObject_Reader::read($this->server->httpRequest->getBody(true)); - } catch (Sabre_VObject_ParseException $e) { + $vObject = VObject\Reader::read($this->server->httpRequest->getBody(true)); + } catch (VObject\ParseException $e) { throw new Sabre_DAV_Exception_BadRequest('The request body must be a valid iCalendar object. Parse error: ' . $e->getMessage()); } @@ -920,10 +922,10 @@ class Sabre_CalDAV_Plugin extends Sabre_DAV_ServerPlugin { * * @param string $originator * @param array $recipients - * @param Sabre_VObject_Component $vObject + * @param Sabre\VObject\Component $vObject * @return array */ - protected function iMIPMessage($originator, array $recipients, Sabre_VObject_Component $vObject, $principal) { + protected function iMIPMessage($originator, array $recipients, VObject\Component $vObject, $principal) { if (!$this->imipHandler) { $resultStatus = '5.2;This server does not support this operation'; diff --git a/dav/SabreDAV/lib/Sabre/CalDAV/Schedule/IMip.php b/dav/SabreDAV/lib/Sabre/CalDAV/Schedule/IMip.php index 1be63a06b..f62f94af3 100644 --- a/dav/SabreDAV/lib/Sabre/CalDAV/Schedule/IMip.php +++ b/dav/SabreDAV/lib/Sabre/CalDAV/Schedule/IMip.php @@ -1,5 +1,7 @@ getMessage()); @@ -441,7 +443,7 @@ class Sabre_CardDAV_Plugin extends Sabre_DAV_ServerPlugin { */ public function validateFilters($vcardData, array $filters, $test) { - $vcard = Sabre_VObject_Reader::read($vcardData); + $vcard = VObject\Reader::read($vcardData); if (!$filters) return true; diff --git a/dav/SabreDAV/lib/Sabre/VObject/includes.php b/dav/SabreDAV/lib/Sabre/VObject/includes.php deleted file mode 100644 index 76497d6ff..000000000 --- a/dav/SabreDAV/lib/Sabre/VObject/includes.php +++ /dev/null @@ -1,39 +0,0 @@ -RRULE = 'FREQ=MONTHLY'; $vevent->DTSTART = '20120101T120000Z'; $vevent->UID = 'bla'; - $valarm = Sabre_VObject_Component::create('VALARM'); + $valarm = VObject\Component::create('VALARM'); $valarm->TRIGGER = '-P15D'; $vevent->add($valarm); - $vcalendar = Sabre_VObject_Component::create('VCALENDAR'); + $vcalendar = VObject\Component::create('VCALENDAR'); $vcalendar->add($vevent); $filter = array( @@ -52,16 +54,16 @@ class Sabre_CalDAV_CalendarQueryVAlarmTest extends PHPUnit_Framework_TestCase { // A limited recurrence rule, should return false - $vevent = Sabre_VObject_Component::create('VEVENT'); + $vevent = VObject\Component::create('VEVENT'); $vevent->RRULE = 'FREQ=MONTHLY;COUNT=1'; $vevent->DTSTART = '20120101T120000Z'; $vevent->UID = 'bla'; - $valarm = Sabre_VObject_Component::create('VALARM'); + $valarm = VObject\Component::create('VALARM'); $valarm->TRIGGER = '-P15D'; $vevent->add($valarm); - $vcalendar = Sabre_VObject_Component::create('VCALENDAR'); + $vcalendar = VObject\Component::create('VCALENDAR'); $vcalendar->add($vevent); $this->assertFalse($validator->validate($vcalendar, $filter)); @@ -69,15 +71,15 @@ class Sabre_CalDAV_CalendarQueryVAlarmTest extends PHPUnit_Framework_TestCase { function testAlarmWayBefore() { - $vevent = Sabre_VObject_Component::create('VEVENT'); + $vevent = VObject\Component::create('VEVENT'); $vevent->DTSTART = '20120101T120000Z'; $vevent->UID = 'bla'; - $valarm = Sabre_VObject_Component::create('VALARM'); + $valarm = VObject\Component::create('VALARM'); $valarm->TRIGGER = '-P2W1D'; $vevent->add($valarm); - $vcalendar = Sabre_VObject_Component::create('VCALENDAR'); + $vcalendar = VObject\Component::create('VCALENDAR'); $vcalendar->add($vevent); $filter = array( diff --git a/dav/SabreDAV/tests/Sabre/CalDAV/CalendarQueryValidatorTest.php b/dav/SabreDAV/tests/Sabre/CalDAV/CalendarQueryValidatorTest.php index 18c8330db..dede4764b 100644 --- a/dav/SabreDAV/tests/Sabre/CalDAV/CalendarQueryValidatorTest.php +++ b/dav/SabreDAV/tests/Sabre/CalDAV/CalendarQueryValidatorTest.php @@ -1,5 +1,7 @@ null, ); - $vObject = Sabre_VObject_Reader::read($icalObject); + $vObject = VObject\Reader::read($icalObject); switch($outcome) { case 0 : @@ -31,7 +33,7 @@ class Sabre_CalDAV_CalendarQueryValidatorTest extends PHPUnit_Framework_TestCase case -1 : try { $validator->validate($vObject, $filters); - } catch (Sabre_DAV_Exception $e) { + } catch (Exception $e) { // Success } break; diff --git a/dav/SabreDAV/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDTest.php b/dav/SabreDAV/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDTest.php index 984212aa2..444dc496b 100644 --- a/dav/SabreDAV/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDTest.php +++ b/dav/SabreDAV/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDTest.php @@ -1,5 +1,7 @@ VEVENT as $vevent) { - /** @var $vevent Sabre_VObject_Component_VEvent */ + /** @var $vevent Sabre\VObject\Component_VEvent */ foreach ($vevent->children as $child) { - /** @var $child Sabre_VObject_Property */ + /** @var $child Sabre\VObject\Property */ if ($child->name == 'DTSTART') { // DTSTART has to be one of three valid values diff --git a/dav/SabreDAV/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDbyDayTest.php b/dav/SabreDAV/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDbyDayTest.php index a2c2fc275..a183082b5 100644 --- a/dav/SabreDAV/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDbyDayTest.php +++ b/dav/SabreDAV/tests/Sabre/CalDAV/ExpandEventsDTSTARTandDTENDbyDayTest.php @@ -1,5 +1,7 @@ assertEquals(2, count($vObject->VEVENT)); // check if DTSTARTs and DTENDs are correct foreach ($vObject->VEVENT as $vevent) { - /** @var $vevent Sabre_VObject_Component_VEvent */ + /** @var $vevent Sabre\VObject\Component\VEvent */ foreach ($vevent->children as $child) { - /** @var $child Sabre_VObject_Property */ + /** @var $child Sabre\VObject\Property */ if ($child->name == 'DTSTART') { // DTSTART has to be one of two valid values diff --git a/dav/SabreDAV/tests/Sabre/CalDAV/ExpandEventsDoubleEventsTest.php b/dav/SabreDAV/tests/Sabre/CalDAV/ExpandEventsDoubleEventsTest.php index 55d06b231..087c384fa 100644 --- a/dav/SabreDAV/tests/Sabre/CalDAV/ExpandEventsDoubleEventsTest.php +++ b/dav/SabreDAV/tests/Sabre/CalDAV/ExpandEventsDoubleEventsTest.php @@ -1,5 +1,7 @@ assertEquals(3, count($vObject->VEVENT),'We got 6 events instead of 3. Output: ' . $body); diff --git a/dav/SabreDAV/tests/Sabre/CalDAV/GetEventsByTimerangeTest.php b/dav/SabreDAV/tests/Sabre/CalDAV/GetEventsByTimerangeTest.php index b8a97ca1d..d9a6d586b 100644 --- a/dav/SabreDAV/tests/Sabre/CalDAV/GetEventsByTimerangeTest.php +++ b/dav/SabreDAV/tests/Sabre/CalDAV/GetEventsByTimerangeTest.php @@ -1,5 +1,7 @@ assertEquals(1, count($vObject->VEVENT), 'We got 0 events instead of 1. Output: ' . $body); diff --git a/dav/SabreDAV/tests/Sabre/CalDAV/ICSExportPluginTest.php b/dav/SabreDAV/tests/Sabre/CalDAV/ICSExportPluginTest.php index d23b81231..c569da8f7 100644 --- a/dav/SabreDAV/tests/Sabre/CalDAV/ICSExportPluginTest.php +++ b/dav/SabreDAV/tests/Sabre/CalDAV/ICSExportPluginTest.php @@ -1,5 +1,7 @@ 'text/calendar', ), $s->httpResponse->headers); - $obj = Sabre_VObject_Reader::read($s->httpResponse->body); + $obj = VObject\Reader::read($s->httpResponse->body); $this->assertEquals(5,count($obj->children())); $this->assertEquals(1,count($obj->VERSION)); @@ -98,7 +100,7 @@ class Sabre_CalDAV_ICSExportPluginTest extends PHPUnit_Framework_TestCase { 'Content-Type' => 'text/calendar', ), $s->httpResponse->headers); - $obj = Sabre_VObject_Reader::read($s->httpResponse->body); + $obj = VObject\Reader::read($s->httpResponse->body); $this->assertEquals(5,count($obj->children())); $this->assertEquals(1,count($obj->VERSION)); @@ -211,7 +213,7 @@ class Sabre_CalDAV_ICSExportPluginTest extends PHPUnit_Framework_TestCase { 'Content-Type' => 'text/calendar', ), $s->httpResponse->headers); - $obj = Sabre_VObject_Reader::read($s->httpResponse->body); + $obj = VObject\Reader::read($s->httpResponse->body); $this->assertEquals(5,count($obj->children())); $this->assertEquals(1,count($obj->VERSION)); diff --git a/dav/SabreDAV/tests/Sabre/CalDAV/Issue166Test.php b/dav/SabreDAV/tests/Sabre/CalDAV/Issue166Test.php index 3a61663ec..11d2f21ce 100644 --- a/dav/SabreDAV/tests/Sabre/CalDAV/Issue166Test.php +++ b/dav/SabreDAV/tests/Sabre/CalDAV/Issue166Test.php @@ -1,5 +1,7 @@ false, 'time-range' => null, ); - $input = Sabre_VObject_Reader::read($input); + $input = VObject\Reader::read($input); $this->assertTrue($validator->validate($input,$filters)); } diff --git a/dav/SabreDAV/tests/Sabre/CalDAV/Issue172Test.php b/dav/SabreDAV/tests/Sabre/CalDAV/Issue172Test.php index 024b25579..90e13fd84 100644 --- a/dav/SabreDAV/tests/Sabre/CalDAV/Issue172Test.php +++ b/dav/SabreDAV/tests/Sabre/CalDAV/Issue172Test.php @@ -1,5 +1,7 @@ array(), ); - $input = Sabre_VObject_Reader::read($input); + $input = VObject\Reader::read($input); $this->assertTrue($validator->validate($input,$filters)); } @@ -77,7 +79,7 @@ HI; ), 'prop-filters' => array(), ); - $input = Sabre_VObject_Reader::read($input); + $input = VObject\Reader::read($input); $this->assertTrue($validator->validate($input,$filters)); } @@ -125,7 +127,7 @@ HI; ), 'prop-filters' => array(), ); - $input = Sabre_VObject_Reader::read($input); + $input = VObject\Reader::read($input); $this->assertTrue($validator->validate($input,$filters)); } } diff --git a/dav/SabreDAV/tests/Sabre/CalDAV/Issue203Test.php b/dav/SabreDAV/tests/Sabre/CalDAV/Issue203Test.php index e9eaecab8..4cb8eec9a 100644 --- a/dav/SabreDAV/tests/Sabre/CalDAV/Issue203Test.php +++ b/dav/SabreDAV/tests/Sabre/CalDAV/Issue203Test.php @@ -1,5 +1,7 @@ assertEquals(2, count($vObject->VEVENT)); @@ -113,10 +115,10 @@ END:VCALENDAR $matching = false; foreach ($vObject->VEVENT as $vevent) { - /** @var $vevent Sabre_VObject_Component_VEvent */ + /** @var $vevent Sabre\VObject\Component\VEvent */ foreach ($vevent->children as $child) { - /** @var $child Sabre_VObject_Property */ + /** @var $child Sabre\VObject\Property */ if (isset($expectedEvent[$child->name])) { if ($expectedEvent[$child->name] != $child->value) { diff --git a/dav/SabreDAV/tests/Sabre/CalDAV/Issue205Test.php b/dav/SabreDAV/tests/Sabre/CalDAV/Issue205Test.php index 20098252e..6e9e497ca 100644 --- a/dav/SabreDAV/tests/Sabre/CalDAV/Issue205Test.php +++ b/dav/SabreDAV/tests/Sabre/CalDAV/Issue205Test.php @@ -1,5 +1,7 @@ assertEquals(1, count($vObject->VEVENT)); diff --git a/dav/SabreDAV/tests/Sabre/CalDAV/Issue228Test.php b/dav/SabreDAV/tests/Sabre/CalDAV/Issue228Test.php new file mode 100644 index 000000000..f251ab13e --- /dev/null +++ b/dav/SabreDAV/tests/Sabre/CalDAV/Issue228Test.php @@ -0,0 +1,75 @@ + 1, + 'name' => 'Calendar', + 'principaluri' => 'principals/user1', + 'uri' => 'calendar1', + ) + ); + + protected $caldavCalendarObjects = array( + 1 => array( + 'event.ics' => array( + 'calendardata' => 'BEGIN:VCALENDAR +VERSION:2.0 +BEGIN:VEVENT +UID:20120730T113415CEST-6804EGphkd@xxxxxx.de +DTSTAMP:20120730T093415Z +DTSTART;VALUE=DATE:20120729 +DTEND;VALUE=DATE:20120730 +SUMMARY:sunday event +TRANSP:TRANSPARENT +END:VEVENT +END:VCALENDAR +', + ), + ), + ); + + function testIssue228() { + + $request = new Sabre_HTTP_Request(array( + 'REQUEST_METHOD' => 'REPORT', + 'HTTP_CONTENT_TYPE' => 'application/xml', + 'REQUEST_URI' => '/calendars/user1/calendar1', + 'HTTP_DEPTH' => '1', + )); + + $request->setBody(' + + + + + + + + + + + + + + +'); + + $response = $this->request($request); + + // We must check if absolutely nothing was returned from this query. + $this->assertFalse(strpos($response->body, 'BEGIN:VCALENDAR')); + + } +} diff --git a/dav/SabreDAV/tests/Sabre/VObject/Component/VEventTest.php b/dav/SabreDAV/tests/Sabre/VObject/Component/VEventTest.php deleted file mode 100644 index 90579cb41..000000000 --- a/dav/SabreDAV/tests/Sabre/VObject/Component/VEventTest.php +++ /dev/null @@ -1,69 +0,0 @@ -assertEquals($outcome, $vevent->isInTimeRange($start, $end)); - - } - - public function timeRangeTestData() { - - $tests = array(); - - $vevent = new Sabre_VObject_Component_VEvent('VEVENT'); - $vevent->DTSTART = '20111223T120000Z'; - $tests[] = array($vevent, new DateTime('2011-01-01'), new DateTime('2012-01-01'), true); - $tests[] = array($vevent, new DateTime('2011-01-01'), new DateTime('2011-11-01'), false); - - $vevent2 = clone $vevent; - $vevent2->DTEND = '20111225T120000Z'; - $tests[] = array($vevent2, new DateTime('2011-01-01'), new DateTime('2012-01-01'), true); - $tests[] = array($vevent2, new DateTime('2011-01-01'), new DateTime('2011-11-01'), false); - - $vevent3 = clone $vevent; - $vevent3->DURATION = 'P1D'; - $tests[] = array($vevent3, new DateTime('2011-01-01'), new DateTime('2012-01-01'), true); - $tests[] = array($vevent3, new DateTime('2011-01-01'), new DateTime('2011-11-01'), false); - - $vevent4 = clone $vevent; - $vevent4->DTSTART = '20111225'; - $vevent4->DTSTART['VALUE'] = 'DATE'; - $tests[] = array($vevent4, new DateTime('2011-01-01'), new DateTime('2012-01-01'), true); - $tests[] = array($vevent4, new DateTime('2011-01-01'), new DateTime('2011-11-01'), false); - // Event with no end date should be treated as lasting the entire day. - $tests[] = array($vevent4, new DateTime('2011-12-25 16:00:00'), new DateTime('2011-12-25 17:00:00'), true); - - - $vevent5 = clone $vevent; - $vevent5->DURATION = 'P1D'; - $vevent5->RRULE = 'FREQ=YEARLY'; - $tests[] = array($vevent5, new DateTime('2011-01-01'), new DateTime('2012-01-01'), true); - $tests[] = array($vevent5, new DateTime('2011-01-01'), new DateTime('2011-11-01'), false); - $tests[] = array($vevent5, new DateTime('2013-12-01'), new DateTime('2013-12-31'), true); - - $vevent6 = clone $vevent; - $vevent6->DTSTART = '20111225'; - $vevent6->DTSTART['VALUE'] = 'DATE'; - $vevent6->DTEND = '20111225'; - $vevent6->DTEND['VALUE'] = 'DATE'; - $tests[] = array($vevent6, new DateTime('2011-01-01'), new DateTime('2012-01-01'), true); - $tests[] = array($vevent6, new DateTime('2011-01-01'), new DateTime('2011-11-01'), false); - - // Added this test to ensure that recurrence rules with no DTEND also - // get checked for the entire day. - $vevent7 = clone $vevent; - $vevent7->DTSTART = '20120101'; - $vevent7->DTSTART['VALUE'] = 'DATE'; - $vevent7->RRULE = 'FREQ=MONTHLY'; - $tests[] = array($vevent7, new DateTime('2012-02-01 15:00:00'), new DateTime('2012-02-02'), true); - return $tests; - - } - -} - diff --git a/dav/SabreDAV/tests/Sabre/VObject/Component/VJournalTest.php b/dav/SabreDAV/tests/Sabre/VObject/Component/VJournalTest.php deleted file mode 100644 index 04fcc9dba..000000000 --- a/dav/SabreDAV/tests/Sabre/VObject/Component/VJournalTest.php +++ /dev/null @@ -1,37 +0,0 @@ -assertEquals($outcome, $vtodo->isInTimeRange($start, $end)); - - } - - public function timeRangeTestData() { - - $tests = array(); - - $vjournal = Sabre_VObject_Component::create('VJOURNAL'); - $vjournal->DTSTART = '20111223T120000Z'; - $tests[] = array($vjournal, new DateTime('2011-01-01'), new DateTime('2012-01-01'), true); - $tests[] = array($vjournal, new DateTime('2011-01-01'), new DateTime('2011-11-01'), false); - - $vjournal2 = Sabre_VObject_Component::create('VJOURNAL'); - $vjournal2->DTSTART = '20111223'; - $vjournal2->DTSTART['VALUE'] = 'DATE'; - $tests[] = array($vjournal2, new DateTime('2011-01-01'), new DateTime('2012-01-01'), true); - $tests[] = array($vjournal2, new DateTime('2011-01-01'), new DateTime('2011-11-01'), false); - - $vjournal3 = Sabre_VObject_Component::create('VJOURNAL'); - $tests[] = array($vjournal3, new DateTime('2011-01-01'), new DateTime('2012-01-01'), false); - $tests[] = array($vjournal3, new DateTime('2011-01-01'), new DateTime('2011-11-01'), false); - - return $tests; - } - -} - diff --git a/dav/SabreDAV/tests/Sabre/VObject/Component/VTodoTest.php b/dav/SabreDAV/tests/Sabre/VObject/Component/VTodoTest.php deleted file mode 100644 index a8bd619af..000000000 --- a/dav/SabreDAV/tests/Sabre/VObject/Component/VTodoTest.php +++ /dev/null @@ -1,63 +0,0 @@ -assertEquals($outcome, $vtodo->isInTimeRange($start, $end)); - - } - - public function timeRangeTestData() { - - $tests = array(); - - $vtodo = Sabre_VObject_Component::create('VTODO'); - $vtodo->DTSTART = '20111223T120000Z'; - $tests[] = array($vtodo, new DateTime('2011-01-01'), new DateTime('2012-01-01'), true); - $tests[] = array($vtodo, new DateTime('2011-01-01'), new DateTime('2011-11-01'), false); - - $vtodo2 = clone $vtodo; - $vtodo2->DURATION = 'P1D'; - $tests[] = array($vtodo2, new DateTime('2011-01-01'), new DateTime('2012-01-01'), true); - $tests[] = array($vtodo2, new DateTime('2011-01-01'), new DateTime('2011-11-01'), false); - - $vtodo3 = clone $vtodo; - $vtodo3->DUE = '20111225'; - $tests[] = array($vtodo3, new DateTime('2011-01-01'), new DateTime('2012-01-01'), true); - $tests[] = array($vtodo3, new DateTime('2011-01-01'), new DateTime('2011-11-01'), false); - - $vtodo4 = Sabre_VObject_Component::create('VTODO'); - $vtodo4->DUE = '20111225'; - $tests[] = array($vtodo4, new DateTime('2011-01-01'), new DateTime('2012-01-01'), true); - $tests[] = array($vtodo4, new DateTime('2011-01-01'), new DateTime('2011-11-01'), false); - - $vtodo5 = Sabre_VObject_Component::create('VTODO'); - $vtodo5->COMPLETED = '20111225'; - $tests[] = array($vtodo5, new DateTime('2011-01-01'), new DateTime('2012-01-01'), true); - $tests[] = array($vtodo5, new DateTime('2011-01-01'), new DateTime('2011-11-01'), false); - - $vtodo6 = Sabre_VObject_Component::create('VTODO'); - $vtodo6->CREATED = '20111225'; - $tests[] = array($vtodo6, new DateTime('2011-01-01'), new DateTime('2012-01-01'), true); - $tests[] = array($vtodo6, new DateTime('2011-01-01'), new DateTime('2011-11-01'), false); - - $vtodo7 = Sabre_VObject_Component::create('VTODO'); - $vtodo7->CREATED = '20111225'; - $vtodo7->COMPLETED = '20111226'; - $tests[] = array($vtodo7, new DateTime('2011-01-01'), new DateTime('2012-01-01'), true); - $tests[] = array($vtodo7, new DateTime('2011-01-01'), new DateTime('2011-11-01'), false); - - $vtodo7 = Sabre_VObject_Component::create('VTODO'); - $tests[] = array($vtodo7, new DateTime('2011-01-01'), new DateTime('2012-01-01'), true); - $tests[] = array($vtodo7, new DateTime('2011-01-01'), new DateTime('2011-11-01'), true); - - return $tests; - - } - -} - diff --git a/dav/SabreDAV/tests/Sabre/VObject/DateTimeParserTest.php b/dav/SabreDAV/tests/Sabre/VObject/DateTimeParserTest.php deleted file mode 100644 index 83e4c4299..000000000 --- a/dav/SabreDAV/tests/Sabre/VObject/DateTimeParserTest.php +++ /dev/null @@ -1,117 +0,0 @@ -assertEquals('+1 weeks', Sabre_VObject_DateTimeParser::parseDuration('P1W',true)); - $this->assertEquals('+5 days', Sabre_VObject_DateTimeParser::parseDuration('P5D',true)); - $this->assertEquals('+5 days 3 hours 50 minutes 12 seconds', Sabre_VObject_DateTimeParser::parseDuration('P5DT3H50M12S',true)); - $this->assertEquals('-1 weeks 50 minutes', Sabre_VObject_DateTimeParser::parseDuration('-P1WT50M',true)); - $this->assertEquals('+50 days 3 hours 2 seconds', Sabre_VObject_DateTimeParser::parseDuration('+P50DT3H2S',true)); - $this->assertEquals(new DateInterval('PT0S'), Sabre_VObject_DateTimeParser::parseDuration('PT0S')); - - } - - function testParseICalendarDurationDateInterval() { - - $expected = new DateInterval('P7D'); - $this->assertEquals($expected, Sabre_VObject_DateTimeParser::parseDuration('P1W')); - $this->assertEquals($expected, Sabre_VObject_DateTimeParser::parse('P1W')); - - $expected = new DateInterval('PT3M'); - $expected->invert = true; - $this->assertEquals($expected, Sabre_VObject_DateTimeParser::parseDuration('-PT3M')); - - } - - /** - * @expectedException Sabre_DAV_Exception_BadRequest - */ - function testParseICalendarDurationFail() { - - Sabre_VObject_DateTimeParser::parseDuration('P1X',true); - - } - - function testParseICalendarDateTime() { - - $dateTime = Sabre_VObject_DateTimeParser::parseDateTime('20100316T141405'); - - $compare = new DateTime('2010-03-16 14:14:05',new DateTimeZone('UTC')); - - $this->assertEquals($compare, $dateTime); - - } - - /** - * @depends testParseICalendarDateTime - * @expectedException Sabre_DAV_Exception_BadRequest - */ - function testParseICalendarDateTimeBadFormat() { - - $dateTime = Sabre_VObject_DateTimeParser::parseDateTime('20100316T141405 '); - - } - - /** - * @depends testParseICalendarDateTime - */ - function testParseICalendarDateTimeUTC() { - - $dateTime = Sabre_VObject_DateTimeParser::parseDateTime('20100316T141405Z'); - - $compare = new DateTime('2010-03-16 14:14:05',new DateTimeZone('UTC')); - $this->assertEquals($compare, $dateTime); - - } - - /** - * @depends testParseICalendarDateTime - */ - function testParseICalendarDateTimeUTC2() { - - $dateTime = Sabre_VObject_DateTimeParser::parseDateTime('20101211T160000Z'); - - $compare = new DateTime('2010-12-11 16:00:00',new DateTimeZone('UTC')); - $this->assertEquals($compare, $dateTime); - - } - - /** - * @depends testParseICalendarDateTime - */ - function testParseICalendarDateTimeCustomTimeZone() { - - $dateTime = Sabre_VObject_DateTimeParser::parseDateTime('20100316T141405', new DateTimeZone('Europe/Amsterdam')); - - $compare = new DateTime('2010-03-16 13:14:05',new DateTimeZone('UTC')); - $this->assertEquals($compare, $dateTime); - - } - - function testParseICalendarDate() { - - $dateTime = Sabre_VObject_DateTimeParser::parseDate('20100316'); - - $expected = new DateTime('2010-03-16 00:00:00',new DateTimeZone('UTC')); - - $this->assertEquals($expected, $dateTime); - - $dateTime = Sabre_VObject_DateTimeParser::parse('20100316'); - $this->assertEquals($expected, $dateTime); - - } - - /** - * @depends testParseICalendarDate - * @expectedException Sabre_DAV_Exception_BadRequest - */ - function testParseICalendarDateBadFormat() { - - $dateTime = Sabre_VObject_DateTimeParser::parseDate('20100316T141405'); - - } -} diff --git a/dav/SabreDAV/tests/Sabre/VObject/Issue153Test.php b/dav/SabreDAV/tests/Sabre/VObject/Issue153Test.php deleted file mode 100644 index 16557c525..000000000 --- a/dav/SabreDAV/tests/Sabre/VObject/Issue153Test.php +++ /dev/null @@ -1,12 +0,0 @@ -assertEquals('Test Benutzer', (string)$obj->fn); - - } - -} diff --git a/dav/SabreDAV/tests/bootstrap.php b/dav/SabreDAV/tests/bootstrap.php index 8dcae248b..c3be7366c 100644 --- a/dav/SabreDAV/tests/bootstrap.php +++ b/dav/SabreDAV/tests/bootstrap.php @@ -4,9 +4,9 @@ define('SABRE_MYSQLDSN','mysql:host=127.0.0.1;dbname=sabredav'); define('SABRE_MYSQLUSER','root'); define('SABRE_MYSQLPASS',''); -set_include_path(dirname(__FILE__) . PATH_SEPARATOR . dirname(__FILE__) . '/../lib/' . PATH_SEPARATOR . get_include_path()); +set_include_path(__DIR__ . '/../lib/' . PATH_SEPARATOR . __DIR__ . PATH_SEPARATOR . get_include_path()); -include 'Sabre/autoload.php'; +include __DIR__ . '/../vendor/autoload.php'; include 'Sabre/DAVServerTest.php'; date_default_timezone_set('GMT'); diff --git a/dav/common/calendar.fnk.php b/dav/common/calendar.fnk.php index cd5efa57f..13d2cdbb8 100644 --- a/dav/common/calendar.fnk.php +++ b/dav/common/calendar.fnk.php @@ -298,7 +298,7 @@ function dav_get_current_user_calendars(&$server, $with_privilege = "") * @param Sabre_CalDAV_Calendar $calendar * @param string $calendarobject_uri * @param string $with_privilege - * @return null|Sabre_VObject_Component_VCalendar + * @return null|Sabre\VObject\Component\VCalendar */ function dav_get_current_user_calendarobject(&$server, &$calendar, $calendarobject_uri, $with_privilege = "") { @@ -314,7 +314,7 @@ function dav_get_current_user_calendarobject(&$server, &$calendar, $calendarobje if (!$aclplugin->checkPrivileges($uri, $with_privilege, Sabre_DAVACL_Plugin::R_PARENT, false)) return null; $data = $obj->get(); - $vObject = Sabre_VObject_Reader::read($data); + $vObject = Sabre\VObject\Reader::read($data); return $vObject; } @@ -342,20 +342,20 @@ function dav_get_current_user_calendar_by_id(&$server, $id, $with_privilege = "" /** * @param string $uid - * @return Sabre_VObject_Component_VCalendar $vObject + * @return Sabre\VObject\Component\VCalendar $vObject */ function dav_create_empty_vevent($uid = "") { $a = get_app(); if ($uid == "") $uid = uniqid(); - return Sabre_VObject_Reader::read("BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//" . DAV_APPNAME . "//DAV-Plugin//EN\r\nBEGIN:VEVENT\r\nUID:" . $uid . "@" . dav_compat_get_hostname() . + return Sabre\VObject\Reader::read("BEGIN:VCALENDAR\r\nVERSION:2.0\r\nPRODID:-//" . DAV_APPNAME . "//DAV-Plugin//EN\r\nBEGIN:VEVENT\r\nUID:" . $uid . "@" . dav_compat_get_hostname() . "\r\nDTSTAMP:" . date("Ymd") . "T" . date("His") . "Z\r\nEND:VEVENT\r\nEND:VCALENDAR\r\n"); } /** - * @param Sabre_VObject_Component_VCalendar $vObject - * @return Sabre_VObject_Component_VEvent|null + * @param Sabre\VObject\Component\VCalendar $vObject + * @return Sabre\VObject\Component\VEvent|null */ function dav_get_eventComponent(&$vObject) { diff --git a/dav/common/calendar_rendering.fnk.php b/dav/common/calendar_rendering.fnk.php index f82247957..d80892f7c 100644 --- a/dav/common/calendar_rendering.fnk.php +++ b/dav/common/calendar_rendering.fnk.php @@ -3,8 +3,8 @@ /** - * @param Sabre_VObject_Component_VAlarm $alarm - * @param Sabre_VObject_Component_VEvent|Sabre_VObject_Component_VTodo $parent + * @param Sabre\VObject\Component\VAlarm $alarm + * @param Sabre\VObject\Component\VEvent|Sabre\VObject\Component\VTodo $parent * @return DateTime|null * @throws Sabre_DAV_Exception */ @@ -12,12 +12,12 @@ function renderCalDavEntry_calcalarm(&$alarm, &$parent) { $trigger = $alarm->__get("TRIGGER"); if (!isset($trigger['VALUE']) || strtoupper($trigger['VALUE']) === 'DURATION') { - $triggerDuration = Sabre_VObject_DateTimeParser::parseDuration($trigger->value); + $triggerDuration = Sabre\VObject\DateTimeParser::parseDuration($trigger->value); $related = (isset($trigger['RELATED']) && strtoupper($trigger['RELATED']) == 'END') ? 'END' : 'START'; if ($related === 'START') { - /** @var Sabre_VObject_Property_DateTime $dtstart */ + /** @var Sabre\VObject\Property\DateTime $dtstart */ $dtstart = $parent->__get("DTSTART"); $effectiveTrigger = $dtstart->getDateTime(); $effectiveTrigger->add($triggerDuration); @@ -28,14 +28,14 @@ function renderCalDavEntry_calcalarm(&$alarm, &$parent) $endProp = 'DTEND'; } - /** @var Sabre_VObject_Property_DateTime $dtstart */ + /** @var Sabre\VObject\Property\DateTime $dtstart */ $dtstart = $parent->__get("DTSTART"); if (isset($parent->$endProp)) { $effectiveTrigger = clone $parent->$endProp->getDateTime(); $effectiveTrigger->add($triggerDuration); } elseif ($parent->__get("DURATION") != "") { $effectiveTrigger = clone $dtstart->getDateTime(); - $duration = Sabre_VObject_DateTimeParser::parseDuration($parent->__get("DURATION")); + $duration = Sabre\VObject\DateTimeParser::parseDuration($parent->__get("DURATION")); $effectiveTrigger->add($duration); $effectiveTrigger->add($triggerDuration); } else { @@ -58,10 +58,10 @@ function renderCalDavEntry_calcalarm(&$alarm, &$parent) */ function renderCalDavEntry_data(&$calendar, &$calendarobject) { - /** @var Sabre_VObject_Component_VCalendar $vObject */ - $vObject = Sabre_VObject_Reader::read($calendarobject["calendardata"]); + /** @var Sabre\VObject\Component\VCalendar $vObject */ + $vObject = Sabre\VObject\Reader::read($calendarobject["calendardata"]); $componentType = null; - /** @var Sabre_VObject_Component_VEvent $component */ + /** @var Sabre\VObject\Component\VEvent $component */ $component = null; foreach ($vObject->getComponents() as $component) { if ($component->name !== 'VTIMEZONE') { @@ -86,18 +86,18 @@ function renderCalDavEntry_data(&$calendar, &$calendarobject) ); $recurring = ($component->__get("RRULE") ? 1 : 0); - /** @var Sabre_VObject_Property_DateTime $dtstart */ + /** @var Sabre\VObject\Property\DateTime $dtstart */ $dtstart = $component->__get("DTSTART"); - $allday = ($dtstart->getDateType() == Sabre_VObject_Property_DateTime::DATE ? 1 : 0); + $allday = ($dtstart->getDateType() == Sabre\VObject\Property\DateTime::DATE ? 1 : 0); - /** @var array|Sabre_VObject_Component_VAlarm[] $alarms */ + /** @var array|Sabre\VObject\Component\VAlarm[] $alarms */ $alarms = array(); foreach ($component->getComponents() as $a_component) if ($a_component->name == "VALARM") { - /** var Sabre_VObject_Component_VAlarm $component */ + /** var Sabre\VObject\Component\VAlarm $component */ $alarms[] = $a_component; } - $it = new Sabre_VObject_RecurrenceIterator($vObject, (string)$component->__get("UID")); + $it = new Sabre\VObject\RecurrenceIterator($vObject, (string)$component->__get("UID")); $last_end = 0; $max_ts = mktime(0, 0, 0, 1, 1, CALDAV_MAX_YEAR * 1); $first = true; diff --git a/dav/common/dav_caldav_backend_common.inc.php b/dav/common/dav_caldav_backend_common.inc.php index 99fcb6c10..97d5722a9 100644 --- a/dav/common/dav_caldav_backend_common.inc.php +++ b/dav/common/dav_caldav_backend_common.inc.php @@ -81,22 +81,22 @@ abstract class Sabre_CalDAV_Backend_Common extends Sabre_CalDAV_Backend_Abstract /** * @static - * @param Sabre_VObject_Component_VEvent $component + * @param Sabre\VObject\Component\VEvent $component * @return int */ public static function getDtEndTimeStamp(&$component) { - /** @var Sabre_VObject_Property_DateTime $dtstart */ + /** @var Sabre\VObject\Property\DateTime $dtstart */ $dtstart = $component->__get("DTSTART"); if ($component->__get("DTEND")) { - /** @var Sabre_VObject_Property_DateTime $dtend */ + /** @var Sabre\VObject\Property\DateTime $dtend */ $dtend = $component->__get("DTEND"); return $dtend->getDateTime()->getTimeStamp(); } elseif ($component->__get("DURATION")) { $endDate = clone $dtstart->getDateTime(); - $endDate->add(Sabre_VObject_DateTimeParser::parse($component->__get("DURATION")->value)); + $endDate->add(Sabre\VObject\DateTimeParser::parse($component->__get("DURATION")->value)); return $endDate->getTimeStamp(); - } elseif ($dtstart->getDateType() === Sabre_VObject_Property_DateTime::DATE) { + } elseif ($dtstart->getDateType() === Sabre\VObject\Property\DateTime::DATE) { $endDate = clone $dtstart->getDateTime(); $endDate->modify('+1 day'); return $endDate->getTimeStamp(); @@ -124,8 +124,8 @@ abstract class Sabre_CalDAV_Backend_Common extends Sabre_CalDAV_Backend_Abstract */ protected function getDenormalizedData($calendarData) { - /** @var Sabre_VObject_Component_VEvent $vObject */ - $vObject = Sabre_VObject_Reader::read($calendarData); + /** @var Sabre\VObject\Component\VEvent $vObject */ + $vObject = Sabre\VObject\Reader::read($calendarData); $componentType = null; $component = null; $firstOccurence = null; @@ -141,15 +141,15 @@ abstract class Sabre_CalDAV_Backend_Common extends Sabre_CalDAV_Backend_Abstract throw new Sabre_DAV_Exception_BadRequest('Calendar objects must have a VJOURNAL, VEVENT or VTODO component'); } if ($componentType === 'VEVENT') { - /** @var Sabre_VObject_Component_VEvent $component */ - /** @var Sabre_VObject_Property_DateTime $dtstart */ + /** @var Sabre\VObject\Component\VEvent $component */ + /** @var Sabre\VObject\Property\DateTime $dtstart */ $dtstart = $component->__get("DTSTART"); $firstOccurence = $dtstart->getDateTime()->getTimeStamp(); // Finding the last occurence is a bit harder if (!$component->__get("RRULE")) { $lastOccurence = self::getDtEndTimeStamp($component); } else { - $it = new Sabre_VObject_RecurrenceIterator($vObject, (string)$component->__get("UID")); + $it = new Sabre\VObject\RecurrenceIterator($vObject, (string)$component->__get("UID")); $maxDate = new DateTime(CALDAV_MAX_YEAR . "-01-01"); if ($it->isInfinite()) { $lastOccurence = $maxDate->getTimeStamp(); diff --git a/dav/common/wdcal_backend.inc.php b/dav/common/wdcal_backend.inc.php index 9233da6e2..330f29889 100644 --- a/dav/common/wdcal_backend.inc.php +++ b/dav/common/wdcal_backend.inc.php @@ -97,12 +97,12 @@ function wdcal_print_feed($base_path = "") $component = dav_get_eventComponent($item); $component->add("SUMMARY", icalendar_sanitize_string(dav_compat_parse_text_serverside("CalendarTitle"))); - if (isset($_REQUEST["allday"])) $type = Sabre_VObject_Property_DateTime::DATE; - else $type = Sabre_VObject_Property_DateTime::LOCALTZ; + if (isset($_REQUEST["allday"])) $type = Sabre\VObject\Property\DateTime::DATE; + else $type = Sabre\VObject\Property\DateTime::LOCALTZ; - $datetime_start = new Sabre_VObject_Property_DateTime("DTSTART"); + $datetime_start = new Sabre\VObject\Property\DateTime("DTSTART"); $datetime_start->setDateTime(new DateTime(date("Y-m-d H:i:s", IntVal($_REQUEST["CalendarStartTime"]))), $type); - $datetime_end = new Sabre_VObject_Property_DateTime("DTEND"); + $datetime_end = new Sabre\VObject\Property\DateTime("DTEND"); $datetime_end->setDateTime(new DateTime(date("Y-m-d H:i:s", IntVal($_REQUEST["CalendarEndTime"]))), $type); $component->add($datetime_start); @@ -179,12 +179,12 @@ function wdcal_print_feed($base_path = "") killme(); } - if (isset($_REQUEST["allday"])) $type = Sabre_VObject_Property_DateTime::DATE; - else $type = Sabre_VObject_Property_DateTime::LOCALTZ; + if (isset($_REQUEST["allday"])) $type = Sabre\VObject\Property\DateTime::DATE; + else $type = Sabre\VObject\Property\DateTime::LOCALTZ; - $datetime_start = new Sabre_VObject_Property_DateTime("DTSTART"); + $datetime_start = new Sabre\VObject\Property\DateTime("DTSTART"); $datetime_start->setDateTime(new DateTime(date("Y-m-d H:i:s", IntVal($_REQUEST["CalendarStartTime"]))), $type); - $datetime_end = new Sabre_VObject_Property_DateTime("DTEND"); + $datetime_end = new Sabre\VObject\Property\DateTime("DTEND"); $datetime_end->setDateTime(new DateTime(date("Y-m-d H:i:s", IntVal($_REQUEST["CalendarEndTime"]))), $type); $component->__unset("DTSTART"); diff --git a/dav/friendica/dav_caldav_backend_virtual_friendica.inc.php b/dav/friendica/dav_caldav_backend_virtual_friendica.inc.php index d2810b4f8..0afc03bd7 100644 --- a/dav/friendica/dav_caldav_backend_virtual_friendica.inc.php +++ b/dav/friendica/dav_caldav_backend_virtual_friendica.inc.php @@ -82,11 +82,11 @@ class Sabre_CalDAV_Backend_Friendica extends Sabre_CalDAV_Backend_Virtual $ts_end = wdcal_mySql2PhpTime($start); $allday = (strpos($start, "00:00:00") !== false && strpos($finish, "00:00:00") !== false); - $type = ($allday ? Sabre_VObject_Property_DateTime::DATE : Sabre_VObject_Property_DateTime::LOCALTZ); + $type = ($allday ? Sabre\VObject\Property\DateTime::DATE : Sabre\VObject\Property\DateTime::LOCALTZ); - $datetime_start = new Sabre_VObject_Property_DateTime("DTSTART"); + $datetime_start = new Sabre\VObject\Property\DateTime("DTSTART"); $datetime_start->setDateTime(new DateTime(date("Y-m-d H:i:s", $ts_start)), $type); - $datetime_end = new Sabre_VObject_Property_DateTime("DTEND"); + $datetime_end = new Sabre\VObject\Property\DateTime("DTEND"); $datetime_end->setDateTime(new DateTime(date("Y-m-d H:i:s", $ts_end)), $type); $component->add($datetime_start); diff --git a/dav/friendica/layout.fnk.php b/dav/friendica/layout.fnk.php index 5b65ec244..80a9ae2d0 100644 --- a/dav/friendica/layout.fnk.php +++ b/dav/friendica/layout.fnk.php @@ -86,12 +86,12 @@ function wdcal_import_user_ics($calendar_id) { if ($_FILES["ics_file"]["tmp_name"] != "" && is_uploaded_file($_FILES["ics_file"]["tmp_name"])) try { $text = file_get_contents($_FILES["ics_file"]["tmp_name"]); - /** @var Sabre_VObject_Component_VCalendar $vObject */ - $vObject = Sabre_VObject_Reader::read($text); + /** @var Sabre\VObject\Component\VCalendar $vObject */ + $vObject = Sabre\VObject\Reader::read($text); $comp = $vObject->getComponents(); $imported = array(); foreach ($comp as $c) try { - /** @var Sabre_VObject_Component_VEvent $c */ + /** @var Sabre\VObject\Component\VEvent $c */ $uid = $c->__get("UID")->value; if (!isset($imported[$uid])) $imported[$uid] = ""; $imported[$uid] .= $c->serialize(); diff --git a/dav/friendica/main.php b/dav/friendica/main.php index 602bda6d7..712b6c7b8 100644 --- a/dav/friendica/main.php +++ b/dav/friendica/main.php @@ -28,6 +28,27 @@ function dav_include_files() { require_once (__DIR__ . "/../SabreDAV/lib/Sabre/autoload.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/Node.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/Element.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/Component.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/DateTimeParser.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/ElementList.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/FreeBusyGenerator.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/Parameter.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/ParseException.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/Property.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/Reader.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/RecurrenceIterator.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/TimeZoneUtil.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/Version.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/Property/DateTime.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/Property/MultiDateTime.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/Component/VAlarm.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/Component/VCalendar.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/Component/VEvent.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/Component/VJournal.php"); + require_once (__DIR__ . "/../sabre-vobject/lib/Sabre/VObject/Component/VTodo.php"); + require_once (__DIR__ . "/../common/calendar.fnk.php"); require_once (__DIR__ . "/../common/calendar_rendering.fnk.php"); @@ -109,7 +130,7 @@ function dav_init(&$a) } - $server = dav_create_server(); + $server = dav_create_server(); $browser = new Sabre_DAV_Browser_Plugin(); $server->addPlugin($browser); @@ -293,8 +314,7 @@ function dav_plugin_admin_post(&$a = null, &$o = null) if (count($errs) == 0) { renderAllCalDavEntries(); info(t('The database tables have been updated.') . EOL); - } - else notice(t("An error occurred during the update.") . EOL); + } else notice(t("An error occurred during the update.") . EOL); } } diff --git a/dav/sabre-vobject/.travis.yml b/dav/sabre-vobject/.travis.yml new file mode 100644 index 000000000..aca128bc8 --- /dev/null +++ b/dav/sabre-vobject/.travis.yml @@ -0,0 +1,8 @@ +language: php +php: + - 5.3 + - 5.4 + +script: phpunit --configuration tests/phpunit.xml + +before_script: composer install diff --git a/dav/sabre-vobject/ChangeLog b/dav/sabre-vobject/ChangeLog new file mode 100644 index 000000000..0f26abbbc --- /dev/null +++ b/dav/sabre-vobject/ChangeLog @@ -0,0 +1,7 @@ +2.0.0-stable (2012-08-08) + * VObject is now a separate project from SabreDAV. See the SabreDAV + changelog for version information before 2.0. + * New: VObject library now uses PHP 5.3 namespaces. + * New: It's possible to specify lists of parameters when constructing + properties. + * New: made it easier to construct the FreeBusyGenerator. diff --git a/dav/sabre-vobject/LICENSE b/dav/sabre-vobject/LICENSE new file mode 100644 index 000000000..8e09aec68 --- /dev/null +++ b/dav/sabre-vobject/LICENSE @@ -0,0 +1,27 @@ +Copyright (C) 2007-2012 Rooftop Solutions. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of the Sabre nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. diff --git a/dav/sabre-vobject/README.md b/dav/sabre-vobject/README.md new file mode 100644 index 000000000..13107039f --- /dev/null +++ b/dav/sabre-vobject/README.md @@ -0,0 +1,388 @@ +# SabreTooth VObject library + +[![Build Status](https://secure.travis-ci.org/evert/sabre-vobject.png?branch=master)](http://travis-ci.org/evert/sabre-vobject) + +The VObject library allows you to easily parse and manipulate [iCalendar](https://tools.ietf.org/html/rfc5545) +and [vCard](https://tools.ietf.org/html/rfc6350) objects using PHP. +The goal of the VObject library is to create a very complete library, with an easy to use API. + +This project is a spin-off from [SabreDAV](http://code.google.com/p/sabredav/), where it has +been used for several years. The VObject library has 100% unittest coverage. + +# Installation + +VObject requires PHP 5.3, and should be installed using composer. +The general composer instructions can be found on the [composer website](http://getcomposer.org/doc/00-intro.md composer website). + +After that, just declare the vobject dependency as follows: + +``` +"require" : { + "sabre/vobject" : "dev-master" +} +``` + +Then, run `composer.phar update` and you should be good. As soon as the first release is out, you should switch `dev-master` to `2.0.*` though. + +# Usage + +## Parsing + +For our example, we will be using the following vcard: + +``` +BEGIN:VCARD +VERSION:3.0 +PRODID:-//Sabre//Sabre VObject 2.0//EN +N:Planck;Max;;; +FN:Max Planck +EMAIL;TYPE=WORK:mplanck@example.org +item1.TEL;TYPE=CELL:(+49)3144435678 +item1.X-ABLabel:Private cell +item2.TEL;TYPE=WORK:(+49)5554564744 +item2.X-ABLabel:Work +END:VCARD +``` + + +If we want to just print out Max' full name, you can just use property access: + + +```php + +use Sabre\VObject; + +$card = VObject\Reader::read($data); +echo $card->FN; + +``` + +## Changing properties + +Creating properties is pretty similar. If we like to add his birthday, we just +set the property: + +```php + +$card->BDAY = '1858-04-23'; + +``` + +Note that in the previous example, we're actually updating any existing BDAY that +may already exist. If we want to add a new property, without overwriting the previous +we can do this with the `add` method. + +```php + +$card->add('EMAIL','max@example.org'); + +``` + +## Parameters + +If we want to also specify that this is max' home email addresses, we can do this with +a third parameter: + +``` + +$card->add('EMAIL', 'max@example'org', array('type' => 'HOME')); + +``` + +If we want to read out all the email addresses and their type, this would look something +like this: + +``` +foreach($card->EMAIL as $email) { + + echo $email['TYPE'], ' - ', $email; + +} +``` + +## Groups + +In our example, you can see that the TEL properties are prefixed. These are 'groups' and +allow you to group multiple related properties together. The group can be any user-defined +name. + +This particular example as generated by the OS X addressbook, which uses the `X-ABLabel` +to allow the user to specify custom labels for properties. OS X addressbook uses groups +to tie the label to the property. + +The VObject library simply ignores the group if you don't specify it, so this will work: + +```php + +foreach($card->TEL as $tel) { + echo $tel, "\n"; +} +``` + +But if you would like to target a specific group + property, this is possible too: + +```php + +echo $card->{'ITEM1.TEL'}; + +``` + +So if you would like to show all the phone numbers, along with their custom label, the +following syntax is used: + +``` +foreach($card->TEL as $tel) { + + echo $card->{$tel->group . '.X-ABLABEL'}, ": "; + echo $tel, "\n"; + +} +``` + +## Serializing / Saving + +If you want to generate your updated VObject, you can simply call the serialize() method. + +``` + +echo $card->serialize(); + +``` + +## Components + +iCalendar, unlike vCards always have sub-components. Where vCards are often just a flat +list, iCalendar objects tend to have a tree-like structure. For the following paragraphs, +we will use the following object as the example: + +``` +BEGIN:VCALENDAR +VERSION:2.0 +PRODID:-//Sabre//Sabre VObject 2.0//EN +BEGIN:VEVENT +SUMMARY:Curiosity landing +DTSTART:20120806T051439Z +LOCATION:Mars +END:VEVENT +END:VCALENDAR +``` + +Since events, tasks and journals are always in a sub component, this is also how we +access them. + +```php + +use Sabre\VObject; + +$calendar = VObject\Reader::read($data); +echo $calendar->VEVENT->SUMMARY; + +``` + +Adding components to a calendar is done with a factory method: + +```php + +$event = VObject\Component::create('VEVENT'); +$calendar->add($event); + +$event->SUMMARY = 'Curiosity launch'; +$event->DTSTART = '20111126T150202Z'; +$event->LOCATION = 'Cape Carnival'; + +``` + +By the way.. cloning also works as expected, as the entire structure is cloned along with it: + +```php + +$clonedEvent = clone $calendar->VEVENT[0]; +$calendar->add($clonedEvent); + +``` + +## Date and time handling + +If you ever had to deal with iCalendar timezones, you know it can be complicated. +The way timezones are specified is flawed, which is something I may write an essay about some +day. VObject does its best to determine the correct timezone. Many standard formats +have been tested and verified, and special code has been implemented for special-casing +microsoft generated timezone information, and others. + +To get a real php `DateTime` object, you can request this as follows: + +``` +$event = $calendar->VEVENT; +$start = $event->DTSTART->getDateTime(); +echo $start->format(\DateTime::W3C); +``` + +To set the property with a DateTime object, you can use the following syntax: + +``` +$dateTime = new \DateTime('2012-08-07 23:53:00', new DateTimeZone('Europe/Amsterdam')); +$event->DTSTART->setDateTime($dateTime, VObject\Property\DateTime::DATE); +``` + +The second argument specifies the type of date you're setting. The following three +options exist: + +1. `LOCAL` This is a floating time, with no timezone information. This basically specifies that the event happens in whatever the timezone's currently in. This would be encoded as `DTSTART;VALUE=DATE-TIME:20120807235300` +2. `UTC` This specifies that the time should be encoded as a UTC time. This is encoded as `DTSTART;VALUE=DATE-TIME:20120807205300Z`. Note the extra Z and the fact that it's two hours 'earlier'. +3. `LOCALTZ` specifies that it's supposed to be encoded in its local timezone. For example `DTSTART;VALUE=DATE-TIME;TZID=Europe/Amsterdam:20120807235300`. +4. `DATE` This is a date-only, and does not contain the time. In this case this would be encoded as `DTSTART;VALUE=DATE:20120807`. + +A few important notes: + +* When a `TZID` is specified, there should also be a matching `VTIMEZONE` object with all the timezone information. VObject cannot currently automatically embed this. However, in reality other clients seem to do fine without this information. Yet, for completeness, this will be added in the future. +* As mentioned, the timezone-determination process may sometimes fail. Report any issues you find, and I'll be quick to add workarounds! + +## Recurrence rules + +Recurrence rules allow events to recur, for example for a weekly meeting, or an anniversary. +This is done with the `RRULE` property. The `RRULE` property allows for a LOT of different +rules. VObject only implements the ones that actually appear in calendar software. + +To read more about `RRULE` and all the options, check out [RFC5545](https://tools.ietf.org/html/rfc5545#section-3.8.5). +VObject supports the following options: + +1. `UNTIL` for an end date. +2. `INTERVAL` for for example "every 2 days". +3. `COUNT` to stop recurring after x items. +4. `FREQ=DAILY` to recur every day, and `BYDAY` to limit it to certain days. +5. `FREQ=WEEKLY` to recur every week, `BYDAY` to expand this to multiple weekdays in every week and `WKST` to specify on which day the week starts. +6. `FREQ=MONTHLY` to recur every month, `BYMONTHDAY` to expand this to certain days in a month, `BYDAY` to expand it to certain weekdays occuring in a month, and `BYSETPOS` to limit the last two expansions. +7. `FREQ=YEARLY` to recur every year, `BYMONTH` to expand that to certain months in a year, and `BYDAY` and `BYWEEKDAY` to expand the `BYMONTH` rule even further. + +VObject supports the `EXDATE` property for exclusions, but not yet the `RDATE` and `EXRULE` +properties. If you're interested in this, please file a github issue, as this will put it +on my radar. + +This is a bit of a complex subject to go in excruciating detail. The +[RFC](https://tools.ietf.org/html/rfc5545#section-3.8.5) has a lot of examples though. + +The hard part is not to write the RRULE, it is to expand them. The most complex and +hard-to-read code is hidden in this component. Dragons be here. + +So, if we have a meeting every 2nd monday of the month, this would be specified as such: + +``` +BEGIN:VCALENDAR + VERSION:2.0 + BEGIN:VEVENT + UID:1102c450-e0d7-11e1-9b23-0800200c9a66 + DTSTART:20120109T140000Z + RRULE:FREQ=MONTHLY;BYDAY=MO;BYSETPOS=2 + END:VEVENT +END:VCALENDAR +``` + +Note that normally it's not allowed to indent the object like this, but it does make +it easier to read. This is also the first time I added in a UID, which is required +for all VEVENT, VTODO and VJOURNAL objects! + +To figure out all the meetings for this year, we can use the following syntax: + +```php +use Sabre\VObject; + +$calendar = VObject\Reader::read($data); +$calendar->expand(new DateTime('2012-01-01'), new DateTime('2012-12-31')); +``` + +What the expand method does, is look at its inner events, and expand the recurring +rule. Our calendar now contains 12 events. The first will have its RRULE stripped, +and every subsequent VEVENT has the correct meeting date and a `RECURRENCE-ID` set. + +This results in something like this: + +``` +BEGIN:VCALENDAR + VERSION:2.0 + BEGIN:VEVENT + UID:1102c450-e0d7-11e1-9b23-0800200c9a66 + DTSTART:20120109T140000Z + END:VEVENT + BEGIN:VEVENT + UID:1102c450-e0d7-11e1-9b23-0800200c9a66 + RECURRENCE-ID:20120213T140000Z + DTSTART:20120213T140000Z + END:VEVENT + BEGIN:VEVENT + UID:1102c450-e0d7-11e1-9b23-0800200c9a66 + RECURRENCE-ID:20120312T140000Z + DTSTART:20120312T140000Z + END:VEVENT + ..etc.. +END:VCALENDAR +``` + +To show the list of dates, we would do this as such: + +``` +foreach($calendar->VEVENT as $event) { + echo $event->DTSTART->getDateTime()->format(\DateTime::ATOM); +} +``` + +In a recurring event, single instances can also be overriden. VObject also takes these +into consideration. The reason we needed to specify a start and end-date, is because +some recurrence rules can be 'never ending'. + +You should make sure you pick a sane date-range. Because if you pick a 50 year +time-range, for a daily recurring event; this would result in over 18K objects. + +# Free-busy report generation + +Some calendaring software can make use of FREEBUSY reports to show when people are +available. + +You can automatically generate these reports from calendars using the `FreeBusyGenerator`. + +Example based on our last event: + +``` + +// We're giving it the calendar object. It's also possible to specify multiple objects, +// by setting them as an array. +// +// We must also specify a start and end date, because recurring events are expanded. +$fbGenerator = new VObject\FreeBusyGenerator( + new DateTime('2012-01-01'), + new DateTime('2012-12-31'), + $calendar +); + +// Grabbing the report +$freebusy = $fbGenerator->result(); + +// The freebusy report is another VCALENDAR object, so we can serialize it as usual: +echo $freebusy->serialize(); +``` + +The output of this script will look like this: + +``` +BEGIN:VCALENDAR +VERSION:2.0 +PRODID:-//Sabre//Sabre VObject 2.0//EN +CALSCALE:GREGORIAN +BEGIN:VFREEBUSY +DTSTART;VALUE=DATE-TIME:20111231T230000Z +DTEND;VALUE=DATE-TIME:20111231T230000Z +DTSTAMP;VALUE=DATE-TIME:20120808T131628Z +FREEBUSY;FBTYPE=BUSY:20120109T140000Z/20120109T140000Z +FREEBUSY;FBTYPE=BUSY:20120213T140000Z/20120213T140000Z +FREEBUSY;FBTYPE=BUSY:20120312T140000Z/20120312T140000Z +FREEBUSY;FBTYPE=BUSY:20120409T140000Z/20120409T140000Z +FREEBUSY;FBTYPE=BUSY:20120514T140000Z/20120514T140000Z +FREEBUSY;FBTYPE=BUSY:20120611T140000Z/20120611T140000Z +FREEBUSY;FBTYPE=BUSY:20120709T140000Z/20120709T140000Z +FREEBUSY;FBTYPE=BUSY:20120813T140000Z/20120813T140000Z +FREEBUSY;FBTYPE=BUSY:20120910T140000Z/20120910T140000Z +FREEBUSY;FBTYPE=BUSY:20121008T140000Z/20121008T140000Z +FREEBUSY;FBTYPE=BUSY:20121112T140000Z/20121112T140000Z +FREEBUSY;FBTYPE=BUSY:20121210T140000Z/20121210T140000Z +END:VFREEBUSY +END:VCALENDAR +``` diff --git a/dav/sabre-vobject/composer.json b/dav/sabre-vobject/composer.json new file mode 100644 index 000000000..9ecdf4558 --- /dev/null +++ b/dav/sabre-vobject/composer.json @@ -0,0 +1,27 @@ +{ + "name": "sabre/vobject", + "description" : "The VObject library for PHP allows you to easily parse and manipulate iCalendar and vCard objects", + "keywords" : [ "VObject", "iCalendar", "vCard" ], + "homepage" : "https://github.com/evert/sabre-vobject", + "license" : "BSD-3-Clause", + "require" : { + "php" : ">=5.3.1" + }, + "authors" : [ + { + "name" : "Evert Pot", + "email" : "evert@rooftopsolutions.nl", + "homepage" : "http://www.rooftopsolutions.nl/", + "role" : "Developer" + } + ], + "support" : { + "forum" : "https://groups.google.com/group/sabredav-discuss", + "source" : "https://github.com/evert/sabre-vobject" + }, + "autoload" : { + "psr-0" : { + "Sabre\\VObject" : "lib/" + } + } +} diff --git a/dav/SabreDAV/lib/Sabre/VObject/Component.php b/dav/sabre-vobject/lib/Sabre/VObject/Component.php similarity index 79% rename from dav/SabreDAV/lib/Sabre/VObject/Component.php rename to dav/sabre-vobject/lib/Sabre/VObject/Component.php index ced593848..d17cb895e 100644 --- a/dav/SabreDAV/lib/Sabre/VObject/Component.php +++ b/dav/sabre-vobject/lib/Sabre/VObject/Component.php @@ -1,5 +1,7 @@ 'Sabre_VObject_Component_VCalendar', - 'VEVENT' => 'Sabre_VObject_Component_VEvent', - 'VTODO' => 'Sabre_VObject_Component_VTodo', - 'VJOURNAL' => 'Sabre_VObject_Component_VJournal', - 'VALARM' => 'Sabre_VObject_Component_VAlarm', + 'VALARM' => 'Sabre\\VObject\\Component\\VAlarm', + 'VCALENDAR' => 'Sabre\\VObject\\Component\\VCalendar', + 'VCARD' => 'Sabre\\VObject\\Component\\VCard', + 'VEVENT' => 'Sabre\\VObject\\Component\\VEvent', + 'VJOURNAL' => 'Sabre\\VObject\\Component\\VJournal', + 'VTODO' => 'Sabre\\VObject\\Component\\VTodo', ); /** @@ -50,7 +56,7 @@ class Sabre_VObject_Component extends Sabre_VObject_Element { * * @param string $name * @param string $value - * @return Sabre_VObject_Component + * @return Component */ static public function create($name, $value = null) { @@ -71,9 +77,9 @@ class Sabre_VObject_Component extends Sabre_VObject_Element { * be overridden with the iterator argument * * @param string $name - * @param Sabre_VObject_ElementList $iterator + * @param ElementList $iterator */ - public function __construct($name, Sabre_VObject_ElementList $iterator = null) { + public function __construct($name, ElementList $iterator = null) { $this->name = strtoupper($name); if (!is_null($iterator)) $this->iterator = $iterator; @@ -100,12 +106,13 @@ class Sabre_VObject_Component extends Sabre_VObject_Element { * preserve the original relative order of elements. * * @param int $key - * @param Sabre_VObject $array + * @param array $array * @return int */ $sortScore = function($key, $array) { - if ($array[$key] instanceof Sabre_VObject_Component) { + if ($array[$key] instanceof Component) { + // We want to encode VTIMEZONE first, this is a personal // preference. if ($array[$key]->name === 'VTIMEZONE') { @@ -118,7 +125,7 @@ class Sabre_VObject_Component extends Sabre_VObject_Element { } else { // Properties get encoded first // VCARD version 4.0 wants the VERSION property to appear first - if ($array[$key] instanceof Sabre_VObject_Property) { + if ($array[$key] instanceof Property) { if ($array[$key]->name === 'VERSION') { $score=100000000; return $score+$key; @@ -129,7 +136,6 @@ class Sabre_VObject_Component extends Sabre_VObject_Element { } } } - next($children); }; @@ -157,8 +163,8 @@ class Sabre_VObject_Component extends Sabre_VObject_Element { * * You can call this method with the following syntaxes: * - * add(Sabre_VObject_Element $element) - * add(string $name, $value) + * add(Element $element) + * add(string $name, $value, array $parameters = array()) * * The first version adds an Element * The second adds a property as a string. @@ -167,26 +173,26 @@ class Sabre_VObject_Component extends Sabre_VObject_Element { * @param mixed $itemValue * @return void */ - public function add($item, $itemValue = null) { + public function add($item, $itemValue = null, array $parameters = array()) { - if ($item instanceof Sabre_VObject_Element) { + if ($item instanceof Element) { if (!is_null($itemValue)) { - throw new InvalidArgumentException('The second argument must not be specified, when passing a VObject'); + throw new \InvalidArgumentException('The second argument must not be specified, when passing a VObject'); } $item->parent = $this; $this->children[] = $item; } elseif(is_string($item)) { if (!is_scalar($itemValue)) { - throw new InvalidArgumentException('The second argument must be scalar'); + throw new \InvalidArgumentException('The second argument must be scalar'); } - $item = Sabre_VObject_Property::create($item,$itemValue); + $item = Property::create($item,$itemValue, $parameters); $item->parent = $this; $this->children[] = $item; } else { - throw new InvalidArgumentException('The first argument must either be a Sabre_VObject_Element or a string'); + throw new \InvalidArgumentException('The first argument must either be a \\Sabre\\VObject\\Element or a string'); } @@ -195,11 +201,11 @@ class Sabre_VObject_Component extends Sabre_VObject_Element { /** * Returns an iterable list of children * - * @return Sabre_VObject_ElementList + * @return ElementList */ public function children() { - return new Sabre_VObject_ElementList($this->children); + return new ElementList($this->children); } @@ -232,7 +238,7 @@ class Sabre_VObject_Component extends Sabre_VObject_Element { if ( strtoupper($child->name) === $name && - (is_null($group) || ( $child instanceof Sabre_VObject_Property && strtoupper($child->group) === $group)) + (is_null($group) || ( $child instanceof Property && strtoupper($child->group) === $group)) ) { $result[$key] = $child; @@ -255,7 +261,7 @@ class Sabre_VObject_Component extends Sabre_VObject_Element { $result = array(); foreach($this->children as $child) { - if ($child instanceof Sabre_VObject_Component) { + if ($child instanceof Component) { $result[] = $child; } } @@ -266,6 +272,11 @@ class Sabre_VObject_Component extends Sabre_VObject_Element { /** * Validates the node for correctness. + * + * The following options are supported: + * - Component::REPAIR - If something is broken, and automatic repair may + * be attempted. + * * An array is returned with warnings. * * Every item in the array has the following properties: @@ -273,9 +284,10 @@ class Sabre_VObject_Component extends Sabre_VObject_Element { * * message - (human readable message) * * node - (reference to the offending node) * + * @param int $options * @return array */ - public function validate() { + public function validate($options = 0) { $result = array(); foreach($this->children as $child) { @@ -294,7 +306,7 @@ class Sabre_VObject_Component extends Sabre_VObject_Element { * null is returned. * * @param string $name - * @return Sabre_VObject_Property + * @return Property */ public function __get($name) { @@ -303,8 +315,8 @@ class Sabre_VObject_Component extends Sabre_VObject_Element { return null; } else { $firstMatch = current($matches); - /** @var $firstMatch Sabre_VObject_Property */ - $firstMatch->setIterator(new Sabre_VObject_ElementList(array_values($matches))); + /** @var $firstMatch Property */ + $firstMatch->setIterator(new ElementList(array_values($matches))); return $firstMatch; } @@ -326,7 +338,7 @@ class Sabre_VObject_Component extends Sabre_VObject_Element { /** * Using the setter method you can add properties or subcomponents * - * You can either pass a Sabre_VObject_Component, Sabre_VObject_Property + * You can either pass a Component, Property * object, or a string to automatically create a Property. * * If the item already exists, it will be removed. If you want to add @@ -341,7 +353,7 @@ class Sabre_VObject_Component extends Sabre_VObject_Element { $matches = $this->select($name); $overWrite = count($matches)?key($matches):null; - if ($value instanceof Sabre_VObject_Component || $value instanceof Sabre_VObject_Property) { + if ($value instanceof Component || $value instanceof Property) { $value->parent = $this; if (!is_null($overWrite)) { $this->children[$overWrite] = $value; @@ -349,7 +361,7 @@ class Sabre_VObject_Component extends Sabre_VObject_Element { $this->children[] = $value; } } elseif (is_scalar($value)) { - $property = Sabre_VObject_Property::create($name,$value); + $property = Property::create($name,$value); $property->parent = $this; if (!is_null($overWrite)) { $this->children[$overWrite] = $property; @@ -357,7 +369,7 @@ class Sabre_VObject_Component extends Sabre_VObject_Element { $this->children[] = $property; } } else { - throw new InvalidArgumentException('You must pass a Sabre_VObject_Component, Sabre_VObject_Property or scalar type'); + throw new \InvalidArgumentException('You must pass a \\Sabre\\VObject\\Component, \\Sabre\\VObject\\Property or scalar type'); } } diff --git a/dav/SabreDAV/lib/Sabre/VObject/Component/VAlarm.php b/dav/sabre-vobject/lib/Sabre/VObject/Component/VAlarm.php similarity index 79% rename from dav/SabreDAV/lib/Sabre/VObject/Component/VAlarm.php rename to dav/sabre-vobject/lib/Sabre/VObject/Component/VAlarm.php index 1d1dd69d5..6bf7f5a2e 100644 --- a/dav/SabreDAV/lib/Sabre/VObject/Component/VAlarm.php +++ b/dav/sabre-vobject/lib/Sabre/VObject/Component/VAlarm.php @@ -1,17 +1,18 @@ TRIGGER; if(!isset($trigger['VALUE']) || strtoupper($trigger['VALUE']) === 'DURATION') { - $triggerDuration = Sabre_VObject_DateTimeParser::parseDuration($this->TRIGGER); + $triggerDuration = VObject\DateTimeParser::parseDuration($this->TRIGGER); $related = (isset($trigger['RELATED']) && strtoupper($trigger['RELATED']) == 'END') ? 'END' : 'START'; $parentComponent = $this->parent; @@ -37,7 +38,7 @@ class Sabre_VObject_Component_VAlarm extends Sabre_VObject_Component { } elseif ($parentComponent->name === 'VEVENT') { $endProp = 'DTEND'; } else { - throw new Sabre_DAV_Exception('time-range filters on VALARM components are only supported when they are a child of VTODO or VEVENT'); + throw new \LogicException('time-range filters on VALARM components are only supported when they are a child of VTODO or VEVENT'); } if (isset($parentComponent->$endProp)) { @@ -45,7 +46,7 @@ class Sabre_VObject_Component_VAlarm extends Sabre_VObject_Component { $effectiveTrigger->add($triggerDuration); } elseif (isset($parentComponent->DURATION)) { $effectiveTrigger = clone $parentComponent->DTSTART->getDateTime(); - $duration = Sabre_VObject_DateTimeParser::parseDuration($parentComponent->DURATION); + $duration = VObject\DateTimeParser::parseDuration($parentComponent->DURATION); $effectiveTrigger->add($duration); $effectiveTrigger->add($triggerDuration); } else { @@ -67,22 +68,22 @@ class Sabre_VObject_Component_VAlarm extends Sabre_VObject_Component { * The rules used to determine if an event falls within the specified * time-range is based on the CalDAV specification. * - * @param DateTime $start - * @param DateTime $end + * @param \DateTime $start + * @param \DateTime $end * @return bool */ - public function isInTimeRange(DateTime $start, DateTime $end) { + public function isInTimeRange(\DateTime $start, \DateTime $end) { $effectiveTrigger = $this->getEffectiveTriggerTime(); if (isset($this->DURATION)) { - $duration = Sabre_VObject_DateTimeParser::parseDuration($this->DURATION); + $duration = VObject\DateTimeParser::parseDuration($this->DURATION); $repeat = (string)$this->repeat; if (!$repeat) { $repeat = 1; } - $period = new DatePeriod($effectiveTrigger, $duration, (int)$repeat); + $period = new \DatePeriod($effectiveTrigger, $duration, (int)$repeat); foreach($period as $occurrence) { diff --git a/dav/SabreDAV/lib/Sabre/VObject/Component/VCalendar.php b/dav/sabre-vobject/lib/Sabre/VObject/Component/VCalendar.php similarity index 90% rename from dav/SabreDAV/lib/Sabre/VObject/Component/VCalendar.php rename to dav/sabre-vobject/lib/Sabre/VObject/Component/VCalendar.php index 35dd90f23..73f2f6d34 100644 --- a/dav/SabreDAV/lib/Sabre/VObject/Component/VCalendar.php +++ b/dav/sabre-vobject/lib/Sabre/VObject/Component/VCalendar.php @@ -1,17 +1,19 @@ children as $component) { - if (!$component instanceof Sabre_VObject_Component) + if (!$component instanceof VObject\Component) continue; if (isset($component->{'RECURRENCE-ID'})) @@ -69,7 +71,7 @@ class Sabre_VObject_Component_VCalendar extends Sabre_VObject_Component { * @param DateTime $end * @return void */ - public function expand(DateTime $start, DateTime $end) { + public function expand(\DateTime $start, \DateTime $end) { $newEvents = array(); @@ -91,10 +93,10 @@ class Sabre_VObject_Component_VCalendar extends Sabre_VObject_Component { $uid = (string)$vevent->uid; if (!$uid) { - throw new LogicException('Event did not have a UID!'); + throw new \LogicException('Event did not have a UID!'); } - $it = new Sabre_VObject_RecurrenceIterator($this, $vevent->uid); + $it = new VObject\RecurrenceIterator($this, $vevent->uid); $it->fastForward($start); while($it->valid() && $it->getDTStart() < $end) { @@ -114,9 +116,9 @@ class Sabre_VObject_Component_VCalendar extends Sabre_VObject_Component { foreach($newEvents as $newEvent) { foreach($newEvent->children as $child) { - if ($child instanceof Sabre_VObject_Property_DateTime && - $child->getDateType() == Sabre_VObject_Property_DateTime::LOCALTZ) { - $child->setDateTime($child->getDateTime(),Sabre_VObject_Property_DateTime::UTC); + if ($child instanceof VObject\Property\DateTime && + $child->getDateType() == VObject\Property\DateTime::LOCALTZ) { + $child->setDateTime($child->getDateTime(),VObject\Property\DateTime::UTC); } } @@ -140,6 +142,7 @@ class Sabre_VObject_Component_VCalendar extends Sabre_VObject_Component { * * @return array */ + /* public function validate() { $warnings = array(); @@ -198,7 +201,7 @@ class Sabre_VObject_Component_VCalendar extends Sabre_VObject_Component { ); $componentsFound = 0; foreach($this->children as $child) { - if($child instanceof Sabre_VObject_Component) { + if($child instanceof Component) { $componentsFound++; if (!in_array($child->name, $allowedComponents)) { $warnings[] = array( @@ -208,7 +211,7 @@ class Sabre_VObject_Component_VCalendar extends Sabre_VObject_Component { ); } } - if ($child instanceof Sabre_VObject_Property) { + if ($child instanceof Property) { if (!in_array($child->name, $allowedProperties)) { $warnings[] = array( 'level' => 2, @@ -233,6 +236,7 @@ class Sabre_VObject_Component_VCalendar extends Sabre_VObject_Component { ); } + */ } diff --git a/dav/sabre-vobject/lib/Sabre/VObject/Component/VCard.php b/dav/sabre-vobject/lib/Sabre/VObject/Component/VCard.php new file mode 100644 index 000000000..002c4db2b --- /dev/null +++ b/dav/sabre-vobject/lib/Sabre/VObject/Component/VCard.php @@ -0,0 +1,105 @@ +select('VERSION'); + if (count($version)!==1) { + $warnings[] = array( + 'level' => 1, + 'message' => 'The VERSION property must appear in the VCARD component exactly 1 time', + 'node' => $this, + ); + if ($options & self::REPAIR) { + $this->VERSION = self::DEFAULT_VERSION; + } + } else { + $version = (string)$this->VERSION; + if ($version!=='2.1' && $version!=='3.0' && $version!=='4.0') { + $warnings[] = array( + 'level' => 1, + 'message' => 'Only vcard version 4.0 (RFC6350), version 3.0 (RFC2426) or version 2.1 (icm-vcard-2.1) are supported.', + 'node' => $this, + ); + if ($options & self::REPAIR) { + $this->VERSION = '4.0'; + } + } + + } + $version = $this->select('FN'); + if (count($version)!==1) { + $warnings[] = array( + 'level' => 1, + 'message' => 'The FN property must appear in the VCARD component exactly 1 time', + 'node' => $this, + ); + if (($options & self::REPAIR) && count($version) === 0) { + // We're going to try to see if we can use the contents of the + // N property. + if (isset($this->N)) { + $value = explode(';', (string)$this->N); + if (isset($value[1]) && $value[1]) { + $this->FN = $value[1] . ' ' . $value[0]; + } else { + $this->FN = $value[0]; + } + + // Otherwise, the ORG property may work + } elseif (isset($this->ORG)) { + $this->FN = (string)$this->ORG; + } + + } + } + + return array_merge( + parent::validate($options), + $warnings + ); + + } + +} + diff --git a/dav/SabreDAV/lib/Sabre/VObject/Component/VEvent.php b/dav/sabre-vobject/lib/Sabre/VObject/Component/VEvent.php similarity index 64% rename from dav/SabreDAV/lib/Sabre/VObject/Component/VEvent.php rename to dav/sabre-vobject/lib/Sabre/VObject/Component/VEvent.php index 684f5f5a7..9d10966e2 100644 --- a/dav/SabreDAV/lib/Sabre/VObject/Component/VEvent.php +++ b/dav/sabre-vobject/lib/Sabre/VObject/Component/VEvent.php @@ -1,17 +1,18 @@ RRULE) { - $it = new Sabre_VObject_RecurrenceIterator($this); + $it = new VObject\RecurrenceIterator($this); $it->fastForward($start); // We fast-forwarded to a spot where the end-time of the @@ -42,18 +43,19 @@ class Sabre_VObject_Component_VEvent extends Sabre_VObject_Component { $effectiveStart = $this->DTSTART->getDateTime(); if (isset($this->DTEND)) { + + // The DTEND property is considered non inclusive. So for a 3 day + // event in july, dtstart and dtend would have to be July 1st and + // July 4th respectively. + // + // See: + // http://tools.ietf.org/html/rfc5545#page-54 $effectiveEnd = $this->DTEND->getDateTime(); - // If this was an all-day event, we should just increase the - // end-date by 1. Otherwise the event will last until the second - // the date changed, by increasing this by 1 day the event lasts - // all of the last day as well. - if ($this->DTSTART->getDateType() == Sabre_VObject_Property_DateTime::DATE) { - $effectiveEnd->modify('+1 day'); - } + } elseif (isset($this->DURATION)) { $effectiveEnd = clone $effectiveStart; - $effectiveEnd->add( Sabre_VObject_DateTimeParser::parseDuration($this->DURATION) ); - } elseif ($this->DTSTART->getDateType() == Sabre_VObject_Property_DateTime::DATE) { + $effectiveEnd->add( VObject\DateTimeParser::parseDuration($this->DURATION) ); + } elseif ($this->DTSTART->getDateType() == VObject\Property\DateTime::DATE) { $effectiveEnd = clone $effectiveStart; $effectiveEnd->modify('+1 day'); } else { diff --git a/dav/SabreDAV/lib/Sabre/VObject/Component/VJournal.php b/dav/sabre-vobject/lib/Sabre/VObject/Component/VJournal.php similarity index 79% rename from dav/SabreDAV/lib/Sabre/VObject/Component/VJournal.php rename to dav/sabre-vobject/lib/Sabre/VObject/Component/VJournal.php index 6d3949289..f104a1f66 100644 --- a/dav/SabreDAV/lib/Sabre/VObject/Component/VJournal.php +++ b/dav/sabre-vobject/lib/Sabre/VObject/Component/VJournal.php @@ -1,17 +1,19 @@ DTSTART)?$this->DTSTART->getDateTime():null; if ($dtstart) { $effectiveEnd = clone $dtstart; - if ($this->DTSTART->getDateType() == Sabre_VObject_Property_DateTime::DATE) { + if ($this->DTSTART->getDateType() == VObject\Property\DateTime::DATE) { $effectiveEnd->modify('+1 day'); } diff --git a/dav/SabreDAV/lib/Sabre/VObject/Component/VTodo.php b/dav/sabre-vobject/lib/Sabre/VObject/Component/VTodo.php similarity index 87% rename from dav/SabreDAV/lib/Sabre/VObject/Component/VTodo.php rename to dav/sabre-vobject/lib/Sabre/VObject/Component/VTodo.php index 2fb6654ed..5f879aea4 100644 --- a/dav/SabreDAV/lib/Sabre/VObject/Component/VTodo.php +++ b/dav/sabre-vobject/lib/Sabre/VObject/Component/VTodo.php @@ -1,17 +1,19 @@ DTSTART)?$this->DTSTART->getDateTime():null; - $duration = isset($this->DURATION)?Sabre_VObject_DateTimeParser::parseDuration($this->DURATION):null; + $duration = isset($this->DURATION)?VObject\DateTimeParser::parseDuration($this->DURATION):null; $due = isset($this->DUE)?$this->DUE->getDateTime():null; $completed = isset($this->COMPLETED)?$this->COMPLETED->getDateTime():null; $created = isset($this->CREATED)?$this->CREATED->getDateTime():null; diff --git a/dav/SabreDAV/lib/Sabre/VObject/DateTimeParser.php b/dav/sabre-vobject/lib/Sabre/VObject/DateTimeParser.php similarity index 83% rename from dav/SabreDAV/lib/Sabre/VObject/DateTimeParser.php rename to dav/sabre-vobject/lib/Sabre/VObject/DateTimeParser.php index 23a4bb699..0ef8460dd 100644 --- a/dav/SabreDAV/lib/Sabre/VObject/DateTimeParser.php +++ b/dav/sabre-vobject/lib/Sabre/VObject/DateTimeParser.php @@ -1,18 +1,18 @@ setTimeZone(new DateTimeZone('UTC')); + $date->setTimeZone(new \DateTimeZone('UTC')); return $date; } @@ -57,10 +57,10 @@ class Sabre_VObject_DateTimeParser { $result = preg_match('/^([1-3][0-9]{3})([0-1][0-9])([0-3][0-9])$/',$date,$matches); if (!$result) { - throw new Sabre_DAV_Exception_BadRequest('The supplied iCalendar date value is incorrect: ' . $date); + throw new \LogicException('The supplied iCalendar date value is incorrect: ' . $date); } - $date = new DateTime($matches[1] . '-' . $matches[2] . '-' . $matches[3], new DateTimeZone('UTC')); + $date = new \DateTime($matches[1] . '-' . $matches[2] . '-' . $matches[3], new \DateTimeZone('UTC')); return $date; } @@ -79,7 +79,7 @@ class Sabre_VObject_DateTimeParser { $result = preg_match('/^(?P\+|-)?P((?P\d+)W)?((?P\d+)D)?(T((?P\d+)H)?((?P\d+)M)?((?P\d+)S)?)?$/', $duration, $matches); if (!$result) { - throw new Sabre_DAV_Exception_BadRequest('The supplied iCalendar duration value is incorrect: ' . $duration); + throw new \LogicException('The supplied iCalendar duration value is incorrect: ' . $duration); } if (!$asString) { @@ -128,7 +128,7 @@ class Sabre_VObject_DateTimeParser { if ($duration==='P') { $duration = 'PT0S'; } - $iv = new DateInterval($duration); + $iv = new \DateInterval($duration); if ($invert) $iv->invert = true; return $iv; diff --git a/dav/SabreDAV/lib/Sabre/VObject/Element.php b/dav/sabre-vobject/lib/Sabre/VObject/Element.php similarity index 73% rename from dav/SabreDAV/lib/Sabre/VObject/Element.php rename to dav/sabre-vobject/lib/Sabre/VObject/Element.php index e20ff0b35..151ae76ad 100644 --- a/dav/SabreDAV/lib/Sabre/VObject/Element.php +++ b/dav/sabre-vobject/lib/Sabre/VObject/Element.php @@ -1,15 +1,15 @@ vevent where there's multiple VEVENT objects. * - * @package Sabre - * @subpackage VObject * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved. * @author Evert Pot (http://www.rooftopsolutions.nl/) * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License */ -class Sabre_VObject_ElementList implements Iterator, Countable, ArrayAccess { +class ElementList implements \Iterator, \Countable, \ArrayAccess { /** * Inner elements @@ -44,7 +44,7 @@ class Sabre_VObject_ElementList implements Iterator, Countable, ArrayAccess { /** * Returns current item in iteration * - * @return Sabre_VObject_Element + * @return Element */ public function current() { @@ -149,7 +149,7 @@ class Sabre_VObject_ElementList implements Iterator, Countable, ArrayAccess { */ public function offsetSet($offset,$value) { - throw new LogicException('You can not add new objects to an ElementList'); + throw new \LogicException('You can not add new objects to an ElementList'); } @@ -163,7 +163,7 @@ class Sabre_VObject_ElementList implements Iterator, Countable, ArrayAccess { */ public function offsetUnset($offset) { - throw new LogicException('You can not remove objects from an ElementList'); + throw new \LogicException('You can not remove objects from an ElementList'); } diff --git a/dav/SabreDAV/lib/Sabre/VObject/FreeBusyGenerator.php b/dav/sabre-vobject/lib/Sabre/VObject/FreeBusyGenerator.php similarity index 74% rename from dav/SabreDAV/lib/Sabre/VObject/FreeBusyGenerator.php rename to dav/sabre-vobject/lib/Sabre/VObject/FreeBusyGenerator.php index 1c96a64a0..bfb89b018 100644 --- a/dav/SabreDAV/lib/Sabre/VObject/FreeBusyGenerator.php +++ b/dav/sabre-vobject/lib/Sabre/VObject/FreeBusyGenerator.php @@ -1,5 +1,7 @@ setTimeRange($start, $end); + } + + if ($objects) { + $this->setObjects($objects); + } + + } + /** * Sets the VCALENDAR object. * @@ -54,10 +77,10 @@ class Sabre_VObject_FreeBusyGenerator { * * The VFREEBUSY object will be automatically added though. * - * @param Sabre_VObject_Component $vcalendar + * @param Component $vcalendar * @return void */ - public function setBaseObject(Sabre_VObject_Component $vcalendar) { + public function setBaseObject(Component $vcalendar) { $this->baseObject = $vcalendar; @@ -66,22 +89,28 @@ class Sabre_VObject_FreeBusyGenerator { /** * Sets the input objects * - * Every object must either be a string or a Sabre_VObject_Component. + * You must either specify a valendar object as a strong, or as the parse + * Component. + * It's also possible to specify multiple objects as an array. * - * @param array $objects + * @param mixed $objects * @return void */ - public function setObjects(array $objects) { + public function setObjects($objects) { + + if (!is_array($objects)) { + $objects = array($objects); + } $this->objects = array(); foreach($objects as $object) { if (is_string($object)) { - $this->objects[] = Sabre_VObject_Reader::read($object); - } elseif ($object instanceof Sabre_VObject_Component) { + $this->objects[] = Reader::read($object); + } elseif ($object instanceof Component) { $this->objects[] = $object; } else { - throw new InvalidArgumentException('You can only pass strings or Sabre_VObject_Component arguments to setObjects'); + throw new \InvalidArgumentException('You can only pass strings or \\Sabre\\VObject\\Component arguments to setObjects'); } } @@ -97,7 +126,7 @@ class Sabre_VObject_FreeBusyGenerator { * @param DateTime $end * @return void */ - public function setTimeRange(DateTime $start = null, DateTime $end = null) { + public function setTimeRange(\DateTime $start = null, \DateTime $end = null) { $this->start = $start; $this->end = $end; @@ -108,7 +137,7 @@ class Sabre_VObject_FreeBusyGenerator { * Parses the input data and returns a correct VFREEBUSY object, wrapped in * a VCALENDAR. * - * @return Sabre_VObject_Component + * @return Component */ public function getResult() { @@ -140,7 +169,7 @@ class Sabre_VObject_FreeBusyGenerator { if ($component->RRULE) { - $iterator = new Sabre_VObject_RecurrenceIterator($object, (string)$component->uid); + $iterator = new RecurrenceIterator($object, (string)$component->uid); if ($this->start) { $iterator->fastForward($this->start); } @@ -172,10 +201,10 @@ class Sabre_VObject_FreeBusyGenerator { if (isset($component->DTEND)) { $endTime = $component->DTEND->getDateTime(); } elseif (isset($component->DURATION)) { - $duration = Sabre_VObject_DateTimeParser::parseDuration((string)$component->DURATION); + $duration = DateTimeParser::parseDuration((string)$component->DURATION); $endTime = clone $startTime; $endTime->add($duration); - } elseif ($component->DTSTART->getDateType() === Sabre_VObject_Property_DateTime::DATE) { + } elseif ($component->DTSTART->getDateType() === Property\DateTime::DATE) { $endTime = clone $startTime; $endTime->modify('+1 day'); } else { @@ -212,14 +241,14 @@ class Sabre_VObject_FreeBusyGenerator { $values = explode(',', $freebusy); foreach($values as $value) { list($startTime, $endTime) = explode('/', $value); - $startTime = Sabre_VObject_DateTimeParser::parseDateTime($startTime); + $startTime = DateTimeParser::parseDateTime($startTime); if (substr($endTime,0,1)==='P' || substr($endTime,0,2)==='-P') { - $duration = Sabre_VObject_DateTimeParser::parseDuration($endTime); + $duration = DateTimeParser::parseDuration($endTime); $endTime = clone $startTime; $endTime->add($duration); } else { - $endTime = Sabre_VObject_DateTimeParser::parseDateTime($endTime); + $endTime = DateTimeParser::parseDateTime($endTime); } if($this->start && $this->start > $endTime) continue; @@ -248,39 +277,35 @@ class Sabre_VObject_FreeBusyGenerator { if ($this->baseObject) { $calendar = $this->baseObject; } else { - $calendar = new Sabre_VObject_Component('VCALENDAR'); + $calendar = new Component('VCALENDAR'); $calendar->version = '2.0'; - if (Sabre_DAV_Server::$exposeVersion) { - $calendar->prodid = '-//SabreDAV//Sabre VObject ' . Sabre_VObject_Version::VERSION . '//EN'; - } else { - $calendar->prodid = '-//SabreDAV//Sabre VObject//EN'; - } + $calendar->prodid = '-//Sabre//Sabre VObject ' . Version::VERSION . '//EN'; $calendar->calscale = 'GREGORIAN'; } - $vfreebusy = new Sabre_VObject_Component('VFREEBUSY'); + $vfreebusy = new Component('VFREEBUSY'); $calendar->add($vfreebusy); if ($this->start) { - $dtstart = new Sabre_VObject_Property_DateTime('DTSTART'); - $dtstart->setDateTime($this->start,Sabre_VObject_Property_DateTime::UTC); + $dtstart = new Property\DateTime('DTSTART'); + $dtstart->setDateTime($this->start,Property\DateTime::UTC); $vfreebusy->add($dtstart); } if ($this->end) { - $dtend = new Sabre_VObject_Property_DateTime('DTEND'); - $dtend->setDateTime($this->start,Sabre_VObject_Property_DateTime::UTC); + $dtend = new Property\DateTime('DTEND'); + $dtend->setDateTime($this->start,Property\DateTime::UTC); $vfreebusy->add($dtend); } - $dtstamp = new Sabre_VObject_Property_DateTime('DTSTAMP'); - $dtstamp->setDateTime(new DateTime('now'), Sabre_VObject_Property_DateTime::UTC); + $dtstamp = new Property\DateTime('DTSTAMP'); + $dtstamp->setDateTime(new \DateTime('now'), Property\DateTime::UTC); $vfreebusy->add($dtstamp); foreach($busyTimes as $busyTime) { - $busyTime[0]->setTimeZone(new DateTimeZone('UTC')); - $busyTime[1]->setTimeZone(new DateTimeZone('UTC')); + $busyTime[0]->setTimeZone(new \DateTimeZone('UTC')); + $busyTime[1]->setTimeZone(new \DateTimeZone('UTC')); - $prop = new Sabre_VObject_Property( + $prop = new Property( 'FREEBUSY', $busyTime[0]->format('Ymd\\THis\\Z') . '/' . $busyTime[1]->format('Ymd\\THis\\Z') ); diff --git a/dav/SabreDAV/lib/Sabre/VObject/Node.php b/dav/sabre-vobject/lib/Sabre/VObject/Node.php similarity index 87% rename from dav/SabreDAV/lib/Sabre/VObject/Node.php rename to dav/sabre-vobject/lib/Sabre/VObject/Node.php index 6c8319f76..88d1d8c35 100644 --- a/dav/SabreDAV/lib/Sabre/VObject/Node.php +++ b/dav/sabre-vobject/lib/Sabre/VObject/Node.php @@ -1,15 +1,15 @@ iterator)) return $this->iterator; - return new Sabre_VObject_ElementList(array($this)); + return new ElementList(array($this)); } @@ -70,10 +70,10 @@ abstract class Sabre_VObject_Node implements IteratorAggregate, ArrayAccess, Cou * * Note that this is not actually part of the iterator interface * - * @param Sabre_VObject_ElementList $iterator + * @param ElementList $iterator * @return void */ - public function setIterator(Sabre_VObject_ElementList $iterator) { + public function setIterator(ElementList $iterator) { $this->iterator = $iterator; diff --git a/dav/SabreDAV/lib/Sabre/VObject/Parameter.php b/dav/sabre-vobject/lib/Sabre/VObject/Parameter.php similarity index 93% rename from dav/SabreDAV/lib/Sabre/VObject/Parameter.php rename to dav/sabre-vobject/lib/Sabre/VObject/Parameter.php index 2e39af5f7..0355b0a0f 100644 --- a/dav/SabreDAV/lib/Sabre/VObject/Parameter.php +++ b/dav/sabre-vobject/lib/Sabre/VObject/Parameter.php @@ -1,5 +1,7 @@ 'Sabre_VObject_Property_DateTime', - 'CREATED' => 'Sabre_VObject_Property_DateTime', - 'DTEND' => 'Sabre_VObject_Property_DateTime', - 'DTSTAMP' => 'Sabre_VObject_Property_DateTime', - 'DTSTART' => 'Sabre_VObject_Property_DateTime', - 'DUE' => 'Sabre_VObject_Property_DateTime', - 'EXDATE' => 'Sabre_VObject_Property_MultiDateTime', - 'LAST-MODIFIED' => 'Sabre_VObject_Property_DateTime', - 'RECURRENCE-ID' => 'Sabre_VObject_Property_DateTime', - 'TRIGGER' => 'Sabre_VObject_Property_DateTime', + 'COMPLETED' => 'Sabre\\VObject\\Property\\DateTime', + 'CREATED' => 'Sabre\\VObject\\Property\\DateTime', + 'DTEND' => 'Sabre\\VObject\\Property\\DateTime', + 'DTSTAMP' => 'Sabre\\VObject\\Property\\DateTime', + 'DTSTART' => 'Sabre\\VObject\\Property\\DateTime', + 'DUE' => 'Sabre\\VObject\\Property\\DateTime', + 'EXDATE' => 'Sabre\\VObject\\Property\\MultiDateTime', + 'LAST-MODIFIED' => 'Sabre\\VObject\\Property\\DateTime', + 'RECURRENCE-ID' => 'Sabre\\VObject\\Property\\DateTime', + 'TRIGGER' => 'Sabre\\VObject\\Property\\DateTime', ); /** * Creates the new property by name, but in addition will also see if * there's a class mapped to the property name. * + * Parameters can be specified with the optional third argument. Parameters + * must be a key->value map of the parameter name, and value. If the value + * is specified as an array, it is assumed that multiple parameters with + * the same name should be added. + * * @param string $name * @param string $value - * @return Sabre_VObject_Property + * @param array $parameters + * @return Property */ - static public function create($name, $value = null) { + static public function create($name, $value = null, array $parameters = array()) { $name = strtoupper($name); $shortName = $name; @@ -87,9 +93,9 @@ class Sabre_VObject_Property extends Sabre_VObject_Element { } if (isset(self::$classMap[$shortName])) { - return new self::$classMap[$shortName]($name, $value); + return new self::$classMap[$shortName]($name, $value, $parameters); } else { - return new self($name, $value); + return new self($name, $value, $parameters); } } @@ -97,14 +103,16 @@ class Sabre_VObject_Property extends Sabre_VObject_Element { /** * Creates a new property object * - * By default this object will iterate over its own children, but this can - * be overridden with the iterator argument + * Parameters can be specified with the optional third argument. Parameters + * must be a key->value map of the parameter name, and value. If the value + * is specified as an array, it is assumed that multiple parameters with + * the same name should be added. * * @param string $name * @param string $value - * @param Sabre_VObject_ElementList $iterator + * @param array $parameters */ - public function __construct($name, $value = null, $iterator = null) { + public function __construct($name, $value = null, array $parameters = array()) { $name = strtoupper($name); $group = null; @@ -113,13 +121,22 @@ class Sabre_VObject_Property extends Sabre_VObject_Element { } $this->name = $name; $this->group = $group; - if (!is_null($iterator)) $this->iterator = $iterator; $this->setValue($value); + foreach($parameters as $paramName => $paramValues) { + + if (!is_array($paramValues)) { + $paramValues = array($paramValues); + } + + foreach($paramValues as $paramValue) { + $this->add($paramName, $paramValue); + } + + } + } - - /** * Updates the internal value * @@ -180,7 +197,7 @@ class Sabre_VObject_Property extends Sabre_VObject_Element { * * You can call this method with the following syntaxes: * - * add(Sabre_VObject_Parameter $element) + * add(Parameter $element) * add(string $name, $value) * * The first version adds an Parameter @@ -192,24 +209,24 @@ class Sabre_VObject_Property extends Sabre_VObject_Element { */ public function add($item, $itemValue = null) { - if ($item instanceof Sabre_VObject_Parameter) { + if ($item instanceof Parameter) { if (!is_null($itemValue)) { - throw new InvalidArgumentException('The second argument must not be specified, when passing a VObject'); + throw new \InvalidArgumentException('The second argument must not be specified, when passing a VObject'); } $item->parent = $this; $this->parameters[] = $item; } elseif(is_string($item)) { if (!is_scalar($itemValue) && !is_null($itemValue)) { - throw new InvalidArgumentException('The second argument must be scalar'); + throw new \InvalidArgumentException('The second argument must be scalar'); } - $parameter = new Sabre_VObject_Parameter($item,$itemValue); + $parameter = new Parameter($item,$itemValue); $parameter->parent = $this; $this->parameters[] = $parameter; } else { - throw new InvalidArgumentException('The first argument must either be a Sabre_VObject_Element or a string'); + throw new \InvalidArgumentException('The first argument must either be a Element or a string'); } @@ -240,7 +257,7 @@ class Sabre_VObject_Property extends Sabre_VObject_Element { * Returns a parameter, or parameter list. * * @param string $name - * @return Sabre_VObject_Element + * @return Element */ public function offsetGet($name) { @@ -258,7 +275,7 @@ class Sabre_VObject_Property extends Sabre_VObject_Element { } elseif (count($result)===1) { return $result[0]; } else { - $result[0]->setIterator(new Sabre_VObject_ElementList($result)); + $result[0]->setIterator(new ElementList($result)); return $result[0]; } @@ -277,21 +294,21 @@ class Sabre_VObject_Property extends Sabre_VObject_Element { if (is_scalar($value)) { if (!is_string($name)) - throw new InvalidArgumentException('A parameter name must be specified. This means you cannot use the $array[]="string" to add parameters.'); + throw new \InvalidArgumentException('A parameter name must be specified. This means you cannot use the $array[]="string" to add parameters.'); $this->offsetUnset($name); - $parameter = new Sabre_VObject_Parameter($name, $value); + $parameter = new Parameter($name, $value); $parameter->parent = $this; $this->parameters[] = $parameter; - } elseif ($value instanceof Sabre_VObject_Parameter) { + } elseif ($value instanceof Parameter) { if (!is_null($name)) - throw new InvalidArgumentException('Don\'t specify a parameter name if you\'re passing a Sabre_VObject_Parameter. Add using $array[]=$parameterObject.'); + throw new \InvalidArgumentException('Don\'t specify a parameter name if you\'re passing a \\Sabre\\VObject\\Parameter. Add using $array[]=$parameterObject.'); $value->parent = $this; $this->parameters[] = $value; } else { - throw new InvalidArgumentException('You can only add parameters to the property object'); + throw new \InvalidArgumentException('You can only add parameters to the property object'); } } diff --git a/dav/SabreDAV/lib/Sabre/VObject/Property/DateTime.php b/dav/sabre-vobject/lib/Sabre/VObject/Property/DateTime.php similarity index 79% rename from dav/SabreDAV/lib/Sabre/VObject/Property/DateTime.php rename to dav/sabre-vobject/lib/Sabre/VObject/Property/DateTime.php index ff2c867a3..556cd441d 100644 --- a/dav/SabreDAV/lib/Sabre/VObject/Property/DateTime.php +++ b/dav/sabre-vobject/lib/Sabre/VObject/Property/DateTime.php @@ -1,5 +1,9 @@ offsetSet('VALUE','DATE-TIME'); break; case self::UTC : - $dt->setTimeZone(new DateTimeZone('UTC')); + $dt->setTimeZone(new \DateTimeZone('UTC')); $this->setValue($dt->format('Ymd\\THis\\Z')); $this->offsetUnset('VALUE'); $this->offsetUnset('TZID'); @@ -93,7 +95,7 @@ class Sabre_VObject_Property_DateTime extends Sabre_VObject_Property { $this->offsetSet('VALUE','DATE'); break; default : - throw new InvalidArgumentException('You must pass a valid dateType constant'); + throw new \InvalidArgumentException('You must pass a valid dateType constant'); } $this->dateTime = $dt; @@ -106,7 +108,7 @@ class Sabre_VObject_Property_DateTime extends Sabre_VObject_Property { * * If no value was set, this method returns null. * - * @return DateTime|null + * @return \DateTime|null */ public function getDateTime() { @@ -152,11 +154,11 @@ class Sabre_VObject_Property_DateTime extends Sabre_VObject_Property { * * @param string|null $propertyValue The string to parse (yymmdd or * ymmddThhmmss, etc..) - * @param Sabre_VObject_Property|null $property The instance of the + * @param \Sabre\VObject\Property|null $property The instance of the * property we're parsing. * @return array */ - static public function parseData($propertyValue, Sabre_VObject_Property $property = null) { + static public function parseData($propertyValue, VObject\Property $property = null) { if (is_null($propertyValue)) { return array(null, null); @@ -167,14 +169,14 @@ class Sabre_VObject_Property_DateTime extends Sabre_VObject_Property { $regex = "/^$date(T$time(?PZ)?)?$/"; if (!preg_match($regex, $propertyValue, $matches)) { - throw new InvalidArgumentException($propertyValue . ' is not a valid DateTime or Date string'); + throw new \InvalidArgumentException($propertyValue . ' is not a valid \DateTime or Date string'); } if (!isset($matches['hour'])) { // Date-only return array( self::DATE, - new DateTime($matches['year'] . '-' . $matches['month'] . '-' . $matches['date'] . ' 00:00:00'), + new \DateTime($matches['year'] . '-' . $matches['month'] . '-' . $matches['date'] . ' 00:00:00', new \DateTimeZone('UTC')), ); } @@ -187,8 +189,8 @@ class Sabre_VObject_Property_DateTime extends Sabre_VObject_Property { $matches['second']; if (isset($matches['isutc'])) { - $dt = new DateTime($dateStr,new DateTimeZone('UTC')); - $dt->setTimeZone(new DateTimeZone('UTC')); + $dt = new \DateTime($dateStr,new \DateTimeZone('UTC')); + $dt->setTimeZone(new \DateTimeZone('UTC')); return array( self::UTC, $dt @@ -198,9 +200,12 @@ class Sabre_VObject_Property_DateTime extends Sabre_VObject_Property { // Finding the timezone. $tzid = $property['TZID']; if (!$tzid) { + // This was a floating time string. This implies we use the + // timezone from date_default_timezone_set / date.timezone ini + // setting. return array( self::LOCAL, - new DateTime($dateStr) + new \DateTime($dateStr) ); } @@ -210,12 +215,12 @@ class Sabre_VObject_Property_DateTime extends Sabre_VObject_Property { $root = $root->parent; } if ($root->name === 'VCALENDAR') { - $tz = Sabre_VObject_TimeZoneUtil::getTimeZone((string)$tzid, $root); + $tz = VObject\TimeZoneUtil::getTimeZone((string)$tzid, $root); } else { - $tz = Sabre_VObject_TimeZoneUtil::getTimeZone((string)$tzid); + $tz = VObject\TimeZoneUtil::getTimeZone((string)$tzid); } - $dt = new DateTime($dateStr, $tz); + $dt = new \DateTime($dateStr, $tz); $dt->setTimeZone($tz); return array( diff --git a/dav/SabreDAV/lib/Sabre/VObject/Property/MultiDateTime.php b/dav/sabre-vobject/lib/Sabre/VObject/Property/MultiDateTime.php similarity index 80% rename from dav/SabreDAV/lib/Sabre/VObject/Property/MultiDateTime.php rename to dav/sabre-vobject/lib/Sabre/VObject/Property/MultiDateTime.php index ae53ab6a6..629ef4a13 100644 --- a/dav/SabreDAV/lib/Sabre/VObject/Property/MultiDateTime.php +++ b/dav/sabre-vobject/lib/Sabre/VObject/Property/MultiDateTime.php @@ -1,5 +1,9 @@ offsetUnset('VALUE'); $this->offsetUnset('TZID'); switch($dateType) { - case Sabre_VObject_Property_DateTime::LOCAL : + case DateTime::LOCAL : $val = array(); foreach($dt as $i) { $val[] = $i->format('Ymd\\THis'); @@ -62,16 +64,16 @@ class Sabre_VObject_Property_MultiDateTime extends Sabre_VObject_Property { $this->setValue(implode(',',$val)); $this->offsetSet('VALUE','DATE-TIME'); break; - case Sabre_VObject_Property_DateTime::UTC : + case DateTime::UTC : $val = array(); foreach($dt as $i) { - $i->setTimeZone(new DateTimeZone('UTC')); + $i->setTimeZone(new \DateTimeZone('UTC')); $val[] = $i->format('Ymd\\THis\\Z'); } $this->setValue(implode(',',$val)); $this->offsetSet('VALUE','DATE-TIME'); break; - case Sabre_VObject_Property_DateTime::LOCALTZ : + case DateTime::LOCALTZ : $val = array(); foreach($dt as $i) { $val[] = $i->format('Ymd\\THis'); @@ -80,7 +82,7 @@ class Sabre_VObject_Property_MultiDateTime extends Sabre_VObject_Property { $this->offsetSet('VALUE','DATE-TIME'); $this->offsetSet('TZID', $dt[0]->getTimeZone()->getName()); break; - case Sabre_VObject_Property_DateTime::DATE : + case DateTime::DATE : $val = array(); foreach($dt as $i) { $val[] = $i->format('Ymd'); @@ -89,7 +91,7 @@ class Sabre_VObject_Property_MultiDateTime extends Sabre_VObject_Property { $this->offsetSet('VALUE','DATE'); break; default : - throw new InvalidArgumentException('You must pass a valid dateType constant'); + throw new \InvalidArgumentException('You must pass a valid dateType constant'); } $this->dateTimes = $dt; @@ -121,7 +123,7 @@ class Sabre_VObject_Property_MultiDateTime extends Sabre_VObject_Property { list( $type, $dt - ) = Sabre_VObject_Property_DateTime::parseData($val, $this); + ) = DateTime::parseData($val, $this); $dts[] = $dt; $this->dateType = $type; } @@ -154,7 +156,7 @@ class Sabre_VObject_Property_MultiDateTime extends Sabre_VObject_Property { list( $type, $dt - ) = Sabre_VObject_Property_DateTime::parseData($val, $this); + ) = DateTime::parseData($val, $this); $dts[] = $dt; $this->dateType = $type; } diff --git a/dav/SabreDAV/lib/Sabre/VObject/Reader.php b/dav/sabre-vobject/lib/Sabre/VObject/Reader.php similarity index 83% rename from dav/SabreDAV/lib/Sabre/VObject/Reader.php rename to dav/sabre-vobject/lib/Sabre/VObject/Reader.php index eea73fa3d..8fed7e275 100644 --- a/dav/SabreDAV/lib/Sabre/VObject/Reader.php +++ b/dav/sabre-vobject/lib/Sabre/VObject/Reader.php @@ -1,5 +1,7 @@ name) { - throw new Sabre_VObject_ParseException('Invalid VObject, expected: "END:' . $obj->name . '" got: "' . $nextLine . '"'); + throw new ParseException('Invalid VObject, expected: "END:' . $obj->name . '" got: "' . $nextLine . '"'); } next($lines); @@ -107,7 +107,7 @@ class Sabre_VObject_Reader { $result = preg_match($regex,$line,$matches); if (!$result) { - throw new Sabre_VObject_ParseException('Invalid VObject, line ' . ($lineNr+1) . ' did not follow the icalendar/vcard format'); + throw new ParseException('Invalid VObject, line ' . ($lineNr+1) . ' did not follow the icalendar/vcard format'); } $propertyName = strtoupper($matches['name']); @@ -119,7 +119,7 @@ class Sabre_VObject_Reader { } }, $matches['value']); - $obj = Sabre_VObject_Property::create($propertyName, $propertyValue); + $obj = Property::create($propertyName, $propertyValue); if ($matches['parameters']) { @@ -137,7 +137,7 @@ class Sabre_VObject_Reader { /** * Reads a parameter list from a property * - * This method returns an array of Sabre_VObject_Parameter + * This method returns an array of Parameter * * @param string $parameters * @return array @@ -171,7 +171,7 @@ class Sabre_VObject_Reader { } }, $value); - $params[] = new Sabre_VObject_Parameter($match['paramName'], $value); + $params[] = new Parameter($match['paramName'], $value); } diff --git a/dav/SabreDAV/lib/Sabre/VObject/RecurrenceIterator.php b/dav/sabre-vobject/lib/Sabre/VObject/RecurrenceIterator.php similarity index 96% rename from dav/SabreDAV/lib/Sabre/VObject/RecurrenceIterator.php rename to dav/sabre-vobject/lib/Sabre/VObject/RecurrenceIterator.php index 7ccd2049b..374b16e83 100644 --- a/dav/SabreDAV/lib/Sabre/VObject/RecurrenceIterator.php +++ b/dav/sabre-vobject/lib/Sabre/VObject/RecurrenceIterator.php @@ -1,5 +1,7 @@ name === 'VCALENDAR') { - throw new InvalidArgumentException('If you pass a VCALENDAR object, you must pass a uid argument as well'); + throw new \InvalidArgumentException('If you pass a VCALENDAR object, you must pass a uid argument as well'); } $components = array($vcal); $uid = (string)$vcal->uid; @@ -325,7 +325,7 @@ class Sabre_VObject_RecurrenceIterator implements Iterator { } } if (!$this->baseEvent) { - throw new InvalidArgumentException('Could not find a base event with uid: ' . $uid); + throw new \InvalidArgumentException('Could not find a base event with uid: ' . $uid); } $this->startDate = clone $this->baseEvent->DTSTART->getDateTime(); @@ -336,8 +336,8 @@ class Sabre_VObject_RecurrenceIterator implements Iterator { } else { $this->endDate = clone $this->startDate; if (isset($this->baseEvent->DURATION)) { - $this->endDate->add(Sabre_VObject_DateTimeParser::parse($this->baseEvent->DURATION->value)); - } elseif ($this->baseEvent->DTSTART->getDateType()===Sabre_VObject_Property_DateTime::DATE) { + $this->endDate->add(DateTimeParser::parse($this->baseEvent->DURATION->value)); + } elseif ($this->baseEvent->DTSTART->getDateType()===Property\DateTime::DATE) { $this->endDate->modify('+1 day'); } } @@ -362,14 +362,14 @@ class Sabre_VObject_RecurrenceIterator implements Iterator { strtolower($value), array('secondly','minutely','hourly','daily','weekly','monthly','yearly') )) { - throw new InvalidArgumentException('Unknown value for FREQ=' . strtoupper($value)); + throw new \InvalidArgumentException('Unknown value for FREQ=' . strtoupper($value)); } $this->frequency = strtolower($value); break; case 'UNTIL' : - $this->until = Sabre_VObject_DateTimeParser::parse($value); + $this->until = DateTimeParser::parse($value); break; case 'COUNT' : @@ -431,7 +431,7 @@ class Sabre_VObject_RecurrenceIterator implements Iterator { foreach(explode(',', (string)$exDate) as $exceptionDate) { $this->exceptionDates[] = - Sabre_VObject_DateTimeParser::parse($exceptionDate, $this->startDate->getTimeZone()); + DateTimeParser::parse($exceptionDate, $this->startDate->getTimeZone()); } @@ -489,7 +489,7 @@ class Sabre_VObject_RecurrenceIterator implements Iterator { * * This method always returns a cloned instance. * - * @return Sabre_VObject_Component_VEvent + * @return Component\VEvent */ public function getEventObject() { @@ -565,7 +565,7 @@ class Sabre_VObject_RecurrenceIterator implements Iterator { * @param DateTime $dt * @return void */ - public function fastForward(DateTime $dt) { + public function fastForward(\DateTime $dt) { while($this->valid() && $this->getDTEnd() <= $dt) { $this->next(); diff --git a/dav/SabreDAV/lib/Sabre/VObject/TimeZoneUtil.php b/dav/sabre-vobject/lib/Sabre/VObject/TimeZoneUtil.php similarity index 96% rename from dav/SabreDAV/lib/Sabre/VObject/TimeZoneUtil.php rename to dav/sabre-vobject/lib/Sabre/VObject/TimeZoneUtil.php index 276288aaa..8e01210b0 100644 --- a/dav/SabreDAV/lib/Sabre/VObject/TimeZoneUtil.php +++ b/dav/sabre-vobject/lib/Sabre/VObject/TimeZoneUtil.php @@ -1,18 +1,18 @@ {'X-LIC-LOCATION'})) { try { - return new DateTimeZone($vtimezone->{'X-LIC-LOCATION'}); + return new \DateTimeZone($vtimezone->{'X-LIC-LOCATION'}); } catch (\Exception $e) { } @@ -332,7 +332,7 @@ class Sabre_VObject_TimeZoneUtil { // answer for. if (isset($vtimezone->{'X-MICROSOFT-CDO-TZID'})) { if (isset(self::$microsoftExchangeMap[(int)$vtimezone->{'X-MICROSOFT-CDO-TZID'}->value])) { - return new DateTimeZone(self::$microsoftExchangeMap[(int)$vtimezone->{'X-MICROSOFT-CDO-TZID'}->value]); + return new \DateTimeZone(self::$microsoftExchangeMap[(int)$vtimezone->{'X-MICROSOFT-CDO-TZID'}->value]); } } } @@ -342,7 +342,7 @@ class Sabre_VObject_TimeZoneUtil { } // If we got all the way here, we default to UTC. - return new DateTimeZone(date_default_timezone_get()); + return new \DateTimeZone(date_default_timezone_get()); } diff --git a/dav/SabreDAV/lib/Sabre/VObject/Version.php b/dav/sabre-vobject/lib/Sabre/VObject/Version.php similarity index 81% rename from dav/SabreDAV/lib/Sabre/VObject/Version.php rename to dav/sabre-vobject/lib/Sabre/VObject/Version.php index 9ee03d871..a35c852e1 100644 --- a/dav/SabreDAV/lib/Sabre/VObject/Version.php +++ b/dav/sabre-vobject/lib/Sabre/VObject/Version.php @@ -1,20 +1,20 @@ assertEquals($outcome, $valarm->isInTimeRange($start, $end)); @@ -16,7 +21,7 @@ class Sabre_VObject_Component_VAlarmTest extends PHPUnit_Framework_TestCase { $tests = array(); // Hard date and time - $valarm1 = Sabre_VObject_Component::create('VALARM'); + $valarm1 = Component::create('VALARM'); $valarm1->TRIGGER = '20120312T130000Z'; $valarm1->TRIGGER['VALUE'] = 'DATE-TIME'; @@ -24,11 +29,11 @@ class Sabre_VObject_Component_VAlarmTest extends PHPUnit_Framework_TestCase { $tests[] = array($valarm1, new DateTime('2012-03-01 01:00:00'), new DateTime('2012-03-10 01:00:00'), false); // Relation to start time of event - $valarm2 = Sabre_VObject_Component::create('VALARM'); + $valarm2 = Component::create('VALARM'); $valarm2->TRIGGER = '-P1D'; $valarm2->TRIGGER['VALUE'] = 'DURATION'; - $vevent2 = Sabre_VObject_Component::create('VEVENT'); + $vevent2 = Component::create('VEVENT'); $vevent2->DTSTART = '20120313T130000Z'; $vevent2->add($valarm2); @@ -36,12 +41,12 @@ class Sabre_VObject_Component_VAlarmTest extends PHPUnit_Framework_TestCase { $tests[] = array($valarm2, new DateTime('2012-03-01 01:00:00'), new DateTime('2012-03-10 01:00:00'), false); // Relation to end time of event - $valarm3 = Sabre_VObject_Component::create('VALARM'); + $valarm3 = Component::create('VALARM'); $valarm3->TRIGGER = '-P1D'; $valarm3->TRIGGER['VALUE'] = 'DURATION'; $valarm3->TRIGGER['RELATED']= 'END'; - $vevent3 = Sabre_VObject_Component::create('VEVENT'); + $vevent3 = Component::create('VEVENT'); $vevent3->DTSTART = '20120301T130000Z'; $vevent3->DTEND = '20120401T130000Z'; $vevent3->add($valarm3); @@ -50,12 +55,12 @@ class Sabre_VObject_Component_VAlarmTest extends PHPUnit_Framework_TestCase { $tests[] = array($valarm3, new DateTime('2012-03-25 01:00:00'), new DateTime('2012-04-05 01:00:00'), true); // Relation to end time of todo - $valarm4 = Sabre_VObject_Component::create('VALARM'); + $valarm4 = Component::create('VALARM'); $valarm4->TRIGGER = '-P1D'; $valarm4->TRIGGER['VALUE'] = 'DURATION'; $valarm4->TRIGGER['RELATED']= 'END'; - $vtodo4 = Sabre_VObject_Component::create('VTODO'); + $vtodo4 = Component::create('VTODO'); $vtodo4->DTSTART = '20120301T130000Z'; $vtodo4->DUE = '20120401T130000Z'; $vtodo4->add($valarm4); @@ -64,25 +69,25 @@ class Sabre_VObject_Component_VAlarmTest extends PHPUnit_Framework_TestCase { $tests[] = array($valarm4, new DateTime('2012-03-25 01:00:00'), new DateTime('2012-04-05 01:00:00'), true); // Relation to start time of event + repeat - $valarm5 = Sabre_VObject_Component::create('VALARM'); + $valarm5 = Component::create('VALARM'); $valarm5->TRIGGER = '-P1D'; $valarm5->TRIGGER['VALUE'] = 'DURATION'; $valarm5->REPEAT = 10; $valarm5->DURATION = 'P1D'; - $vevent5 = Sabre_VObject_Component::create('VEVENT'); + $vevent5 = Component::create('VEVENT'); $vevent5->DTSTART = '20120301T130000Z'; $vevent5->add($valarm5); $tests[] = array($valarm5, new DateTime('2012-03-09 01:00:00'), new DateTime('2012-03-10 01:00:00'), true); // Relation to start time of event + duration, but no repeat - $valarm6 = Sabre_VObject_Component::create('VALARM'); + $valarm6 = Component::create('VALARM'); $valarm6->TRIGGER = '-P1D'; $valarm6->TRIGGER['VALUE'] = 'DURATION'; $valarm6->DURATION = 'P1D'; - $vevent6 = Sabre_VObject_Component::create('VEVENT'); + $vevent6 = Component::create('VEVENT'); $vevent6->DTSTART = '20120313T130000Z'; $vevent6->add($valarm6); @@ -91,12 +96,12 @@ class Sabre_VObject_Component_VAlarmTest extends PHPUnit_Framework_TestCase { // Relation to end time of event (DURATION instead of DTEND) - $valarm7 = Sabre_VObject_Component::create('VALARM'); + $valarm7 = Component::create('VALARM'); $valarm7->TRIGGER = '-P1D'; $valarm7->TRIGGER['VALUE'] = 'DURATION'; $valarm7->TRIGGER['RELATED']= 'END'; - $vevent7 = Sabre_VObject_Component::create('VEVENT'); + $vevent7 = Component::create('VEVENT'); $vevent7->DTSTART = '20120301T130000Z'; $vevent7->DURATION = 'P30D'; $vevent7->add($valarm7); @@ -105,12 +110,12 @@ class Sabre_VObject_Component_VAlarmTest extends PHPUnit_Framework_TestCase { $tests[] = array($valarm7, new DateTime('2012-03-25 01:00:00'), new DateTime('2012-04-05 01:00:00'), true); // Relation to end time of event (No DTEND or DURATION) - $valarm7 = Sabre_VObject_Component::create('VALARM'); + $valarm7 = Component::create('VALARM'); $valarm7->TRIGGER = '-P1D'; $valarm7->TRIGGER['VALUE'] = 'DURATION'; $valarm7->TRIGGER['RELATED']= 'END'; - $vevent7 = Sabre_VObject_Component::create('VEVENT'); + $vevent7 = Component::create('VEVENT'); $vevent7->DTSTART = '20120301T130000Z'; $vevent7->add($valarm7); @@ -122,15 +127,15 @@ class Sabre_VObject_Component_VAlarmTest extends PHPUnit_Framework_TestCase { } /** - * @expectedException Sabre_DAV_Exception + * @expectedException LogicException */ public function testInTimeRangeInvalidComponent() { - $valarm = Sabre_VObject_Component::create('VALARM'); + $valarm = Component::create('VALARM'); $valarm->TRIGGER = '-P1D'; $valarm->TRIGGER['RELATED'] = 'END'; - $vjournal = Sabre_VObject_Component::create('VJOURNAL'); + $vjournal = Component::create('VJOURNAL'); $vjournal->add($valarm); $valarm->isInTimeRange(new DateTime('2012-02-25 01:00:00'), new DateTime('2012-03-05 01:00:00')); diff --git a/dav/SabreDAV/tests/Sabre/VObject/Component/VCalendarTest.php b/dav/sabre-vobject/tests/Sabre/VObject/Component/VCalendarTest.php similarity index 90% rename from dav/SabreDAV/tests/Sabre/VObject/Component/VCalendarTest.php rename to dav/sabre-vobject/tests/Sabre/VObject/Component/VCalendarTest.php index b1b503b4d..1d7e0c603 100644 --- a/dav/SabreDAV/tests/Sabre/VObject/Component/VCalendarTest.php +++ b/dav/sabre-vobject/tests/Sabre/VObject/Component/VCalendarTest.php @@ -1,20 +1,24 @@ expand( - new DateTime('2011-12-01'), - new DateTime('2011-12-31') + new \DateTime('2011-12-01'), + new \DateTime('2011-12-31') ); // This will normalize the output - $output = Sabre_VObject_Reader::read($output)->serialize(); + $output = VObject\Reader::read($output)->serialize(); $this->assertEquals($output, $vcal->serialize()); @@ -229,10 +233,10 @@ DTSTART;VALUE=DATE:20111202 END:VEVENT END:VCALENDAR '; - $vcal = Sabre_VObject_Reader::read($input); + $vcal = VObject\Reader::read($input); $vcal->expand( - new DateTime('2011-12-01'), - new DateTime('2011-12-31') + new \DateTime('2011-12-01'), + new \DateTime('2011-12-31') ); } diff --git a/dav/sabre-vobject/tests/Sabre/VObject/Component/VCardTest.php b/dav/sabre-vobject/tests/Sabre/VObject/Component/VCardTest.php new file mode 100644 index 000000000..584a007d9 --- /dev/null +++ b/dav/sabre-vobject/tests/Sabre/VObject/Component/VCardTest.php @@ -0,0 +1,100 @@ +validate(); + + $warnMsg = array(); + foreach($warnings as $warning) { + $warnMsg[] = $warning['message']; + } + + $this->assertEquals($expectedWarnings, $warnMsg); + + $vcard->validate(VObject\Component::REPAIR); + + $this->assertEquals( + $expectedRepairedOutput, + $vcard->serialize() + ); + + } + + public function validateData() { + + $tests = array(); + + // Correct + $tests[] = array( + "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:John Doe\r\nEND:VCARD\r\n", + array(), + "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:John Doe\r\nEND:VCARD\r\n", + ); + + // No VERSION + $tests[] = array( + "BEGIN:VCARD\r\nFN:John Doe\r\nEND:VCARD\r\n", + array( + 'The VERSION property must appear in the VCARD component exactly 1 time', + ), + "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:John Doe\r\nEND:VCARD\r\n", + ); + + // Unknown version + $tests[] = array( + "BEGIN:VCARD\r\nVERSION:2.2\r\nFN:John Doe\r\nEND:VCARD\r\n", + array( + 'Only vcard version 4.0 (RFC6350), version 3.0 (RFC2426) or version 2.1 (icm-vcard-2.1) are supported.', + ), + "BEGIN:VCARD\r\nVERSION:4.0\r\nFN:John Doe\r\nEND:VCARD\r\n", + ); + + // No FN + $tests[] = array( + "BEGIN:VCARD\r\nVERSION:4.0\r\nEND:VCARD\r\n", + array( + 'The FN property must appear in the VCARD component exactly 1 time', + ), + "BEGIN:VCARD\r\nVERSION:4.0\r\nEND:VCARD\r\n", + ); + // No FN, N fallback + $tests[] = array( + "BEGIN:VCARD\r\nVERSION:4.0\r\nN:Doe;John;;;;;\r\nEND:VCARD\r\n", + array( + 'The FN property must appear in the VCARD component exactly 1 time', + ), + "BEGIN:VCARD\r\nVERSION:4.0\r\nN:Doe;John;;;;;\r\nFN:John Doe\r\nEND:VCARD\r\n", + ); + // No FN, N fallback, no first name + $tests[] = array( + "BEGIN:VCARD\r\nVERSION:4.0\r\nN:Doe;;;;;;\r\nEND:VCARD\r\n", + array( + 'The FN property must appear in the VCARD component exactly 1 time', + ), + "BEGIN:VCARD\r\nVERSION:4.0\r\nN:Doe;;;;;;\r\nFN:Doe\r\nEND:VCARD\r\n", + ); + + // No FN, ORG fallback + $tests[] = array( + "BEGIN:VCARD\r\nVERSION:4.0\r\nORG:Acme Co.\r\nEND:VCARD\r\n", + array( + 'The FN property must appear in the VCARD component exactly 1 time', + ), + "BEGIN:VCARD\r\nVERSION:4.0\r\nORG:Acme Co.\r\nFN:Acme Co.\r\nEND:VCARD\r\n", + ); + return $tests; + + } + +} diff --git a/dav/sabre-vobject/tests/Sabre/VObject/Component/VEventTest.php b/dav/sabre-vobject/tests/Sabre/VObject/Component/VEventTest.php new file mode 100644 index 000000000..616da4ac7 --- /dev/null +++ b/dav/sabre-vobject/tests/Sabre/VObject/Component/VEventTest.php @@ -0,0 +1,74 @@ +assertEquals($outcome, $vevent->isInTimeRange($start, $end)); + + } + + public function timeRangeTestData() { + + $tests = array(); + + $vevent = new VEvent('VEVENT'); + $vevent->DTSTART = '20111223T120000Z'; + $tests[] = array($vevent, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true); + $tests[] = array($vevent, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false); + + $vevent2 = clone $vevent; + $vevent2->DTEND = '20111225T120000Z'; + $tests[] = array($vevent2, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true); + $tests[] = array($vevent2, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false); + + $vevent3 = clone $vevent; + $vevent3->DURATION = 'P1D'; + $tests[] = array($vevent3, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true); + $tests[] = array($vevent3, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false); + + $vevent4 = clone $vevent; + $vevent4->DTSTART = '20111225'; + $vevent4->DTSTART['VALUE'] = 'DATE'; + $tests[] = array($vevent4, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true); + $tests[] = array($vevent4, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false); + // Event with no end date should be treated as lasting the entire day. + $tests[] = array($vevent4, new \DateTime('2011-12-25 16:00:00'), new \DateTime('2011-12-25 17:00:00'), true); + + + $vevent5 = clone $vevent; + $vevent5->DURATION = 'P1D'; + $vevent5->RRULE = 'FREQ=YEARLY'; + $tests[] = array($vevent5, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true); + $tests[] = array($vevent5, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false); + $tests[] = array($vevent5, new \DateTime('2013-12-01'), new \DateTime('2013-12-31'), true); + + $vevent6 = clone $vevent; + $vevent6->DTSTART = '20111225'; + $vevent6->DTSTART['VALUE'] = 'DATE'; + $vevent6->DTEND = '20111225'; + $vevent6->DTEND['VALUE'] = 'DATE'; + + $tests[] = array($vevent6, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true); + $tests[] = array($vevent6, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false); + + // Added this test to ensure that recurrence rules with no DTEND also + // get checked for the entire day. + $vevent7 = clone $vevent; + $vevent7->DTSTART = '20120101'; + $vevent7->DTSTART['VALUE'] = 'DATE'; + $vevent7->RRULE = 'FREQ=MONTHLY'; + $tests[] = array($vevent7, new \DateTime('2012-02-01 15:00:00'), new \DateTime('2012-02-02'), true); + return $tests; + + } + +} + diff --git a/dav/sabre-vobject/tests/Sabre/VObject/Component/VJournalTest.php b/dav/sabre-vobject/tests/Sabre/VObject/Component/VJournalTest.php new file mode 100644 index 000000000..46ecb992b --- /dev/null +++ b/dav/sabre-vobject/tests/Sabre/VObject/Component/VJournalTest.php @@ -0,0 +1,41 @@ +assertEquals($outcome, $vtodo->isInTimeRange($start, $end)); + + } + + public function timeRangeTestData() { + + $tests = array(); + + $vjournal = Component::create('VJOURNAL'); + $vjournal->DTSTART = '20111223T120000Z'; + $tests[] = array($vjournal, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true); + $tests[] = array($vjournal, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false); + + $vjournal2 = Component::create('VJOURNAL'); + $vjournal2->DTSTART = '20111223'; + $vjournal2->DTSTART['VALUE'] = 'DATE'; + $tests[] = array($vjournal2, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true); + $tests[] = array($vjournal2, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false); + + $vjournal3 = Component::create('VJOURNAL'); + $tests[] = array($vjournal3, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), false); + $tests[] = array($vjournal3, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false); + + return $tests; + } + +} + diff --git a/dav/sabre-vobject/tests/Sabre/VObject/Component/VTodoTest.php b/dav/sabre-vobject/tests/Sabre/VObject/Component/VTodoTest.php new file mode 100644 index 000000000..a84da5cdf --- /dev/null +++ b/dav/sabre-vobject/tests/Sabre/VObject/Component/VTodoTest.php @@ -0,0 +1,67 @@ +assertEquals($outcome, $vtodo->isInTimeRange($start, $end)); + + } + + public function timeRangeTestData() { + + $tests = array(); + + $vtodo = Component::create('VTODO'); + $vtodo->DTSTART = '20111223T120000Z'; + $tests[] = array($vtodo, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true); + $tests[] = array($vtodo, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false); + + $vtodo2 = clone $vtodo; + $vtodo2->DURATION = 'P1D'; + $tests[] = array($vtodo2, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true); + $tests[] = array($vtodo2, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false); + + $vtodo3 = clone $vtodo; + $vtodo3->DUE = '20111225'; + $tests[] = array($vtodo3, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true); + $tests[] = array($vtodo3, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false); + + $vtodo4 = Component::create('VTODO'); + $vtodo4->DUE = '20111225'; + $tests[] = array($vtodo4, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true); + $tests[] = array($vtodo4, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false); + + $vtodo5 = Component::create('VTODO'); + $vtodo5->COMPLETED = '20111225'; + $tests[] = array($vtodo5, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true); + $tests[] = array($vtodo5, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false); + + $vtodo6 = Component::create('VTODO'); + $vtodo6->CREATED = '20111225'; + $tests[] = array($vtodo6, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true); + $tests[] = array($vtodo6, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false); + + $vtodo7 = Component::create('VTODO'); + $vtodo7->CREATED = '20111225'; + $vtodo7->COMPLETED = '20111226'; + $tests[] = array($vtodo7, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true); + $tests[] = array($vtodo7, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), false); + + $vtodo7 = Component::create('VTODO'); + $tests[] = array($vtodo7, new \DateTime('2011-01-01'), new \DateTime('2012-01-01'), true); + $tests[] = array($vtodo7, new \DateTime('2011-01-01'), new \DateTime('2011-11-01'), true); + + return $tests; + + } + +} + diff --git a/dav/SabreDAV/tests/Sabre/VObject/ComponentTest.php b/dav/sabre-vobject/tests/Sabre/VObject/ComponentTest.php similarity index 65% rename from dav/SabreDAV/tests/Sabre/VObject/ComponentTest.php rename to dav/sabre-vobject/tests/Sabre/VObject/ComponentTest.php index 42f836dbd..07000bda0 100644 --- a/dav/SabreDAV/tests/Sabre/VObject/ComponentTest.php +++ b/dav/sabre-vobject/tests/Sabre/VObject/ComponentTest.php @@ -1,22 +1,24 @@ children[] = $sub; - $sub = new Sabre_VObject_Component('VTODO'); + $sub = new Component('VTODO'); $comp->children[] = $sub; $count = 0; foreach($comp->children() as $key=>$subcomponent) { $count++; - $this->assertInstanceOf('Sabre_VObject_Component',$subcomponent); + $this->assertInstanceOf('Sabre\\VObject\\Component',$subcomponent); } $this->assertEquals(2,$count); @@ -26,16 +28,16 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase { function testMagicGet() { - $comp = new Sabre_VObject_Component('VCALENDAR'); + $comp = new Component('VCALENDAR'); - $sub = new Sabre_VObject_Component('VEVENT'); + $sub = new Component('VEVENT'); $comp->children[] = $sub; - $sub = new Sabre_VObject_Component('VTODO'); + $sub = new Component('VTODO'); $comp->children[] = $sub; $event = $comp->vevent; - $this->assertInstanceOf('Sabre_VObject_Component', $event); + $this->assertInstanceOf('Sabre\\VObject\\Component', $event); $this->assertEquals('VEVENT', $event->name); $this->assertInternalType('null', $comp->vjournal); @@ -44,15 +46,15 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase { function testMagicGetGroups() { - $comp = new Sabre_VObject_Component('VCARD'); + $comp = new Component('VCARD'); - $sub = new Sabre_VObject_Property('GROUP1.EMAIL','1@1.com'); + $sub = new Property('GROUP1.EMAIL','1@1.com'); $comp->children[] = $sub; - $sub = new Sabre_VObject_Property('GROUP2.EMAIL','2@2.com'); + $sub = new Property('GROUP2.EMAIL','2@2.com'); $comp->children[] = $sub; - $sub = new Sabre_VObject_Property('EMAIL','3@3.com'); + $sub = new Property('EMAIL','3@3.com'); $comp->children[] = $sub; $emails = $comp->email; @@ -70,12 +72,12 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase { function testMagicIsset() { - $comp = new Sabre_VObject_Component('VCALENDAR'); + $comp = new Component('VCALENDAR'); - $sub = new Sabre_VObject_Component('VEVENT'); + $sub = new Component('VEVENT'); $comp->children[] = $sub; - $sub = new Sabre_VObject_Component('VTODO'); + $sub = new Component('VTODO'); $comp->children[] = $sub; $this->assertTrue(isset($comp->vevent)); @@ -86,10 +88,10 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase { function testMagicSetScalar() { - $comp = new Sabre_VObject_Component('VCALENDAR'); + $comp = new Component('VCALENDAR'); $comp->myProp = 'myValue'; - $this->assertInstanceOf('Sabre_VObject_Property',$comp->MYPROP); + $this->assertInstanceOf('Sabre\\VObject\\Property',$comp->MYPROP); $this->assertEquals('myValue',$comp->MYPROP->value); @@ -97,22 +99,22 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase { function testMagicSetScalarTwice() { - $comp = new Sabre_VObject_Component('VCALENDAR'); + $comp = new Component('VCALENDAR'); $comp->myProp = 'myValue'; $comp->myProp = 'myValue'; $this->assertEquals(1,count($comp->children)); - $this->assertInstanceOf('Sabre_VObject_Property',$comp->MYPROP); + $this->assertInstanceOf('Sabre\\VObject\\Property',$comp->MYPROP); $this->assertEquals('myValue',$comp->MYPROP->value); } function testMagicSetComponent() { - $comp = new Sabre_VObject_Component('VCALENDAR'); + $comp = new Component('VCALENDAR'); // Note that 'myProp' is ignored here. - $comp->myProp = new Sabre_VObject_Component('VEVENT'); + $comp->myProp = new Component('VEVENT'); $this->assertEquals(1, count($comp->children)); @@ -122,10 +124,10 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase { function testMagicSetTwice() { - $comp = new Sabre_VObject_Component('VCALENDAR'); + $comp = new Component('VCALENDAR'); - $comp->VEVENT = new Sabre_VObject_Component('VEVENT'); - $comp->VEVENT = new Sabre_VObject_Component('VEVENT'); + $comp->VEVENT = new Component('VEVENT'); + $comp->VEVENT = new Component('VEVENT'); $this->assertEquals(1, count($comp->children)); @@ -135,9 +137,9 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase { function testArrayAccessGet() { - $comp = new Sabre_VObject_Component('VCALENDAR'); + $comp = new Component('VCALENDAR'); - $event = new Sabre_VObject_Component('VEVENT'); + $event = new Component('VEVENT'); $event->summary = 'Event 1'; $comp->add($event); @@ -148,16 +150,16 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase { $comp->add($event2); $this->assertEquals(2,count($comp->children())); - $this->assertTrue($comp->vevent[1] instanceof Sabre_VObject_Component); + $this->assertTrue($comp->vevent[1] instanceof Component); $this->assertEquals('Event 2', (string)$comp->vevent[1]->summary); } function testArrayAccessExists() { - $comp = new Sabre_VObject_Component('VCALENDAR'); + $comp = new Component('VCALENDAR'); - $event = new Sabre_VObject_Component('VEVENT'); + $event = new Component('VEVENT'); $event->summary = 'Event 1'; $comp->add($event); @@ -177,7 +179,7 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase { */ function testArrayAccessSet() { - $comp = new Sabre_VObject_Component('VCALENDAR'); + $comp = new Component('VCALENDAR'); $comp['hey'] = 'hi there'; } @@ -186,30 +188,51 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase { */ function testArrayAccessUnset() { - $comp = new Sabre_VObject_Component('VCALENDAR'); + $comp = new Component('VCALENDAR'); unset($comp[0]); } function testAddScalar() { - $comp = new Sabre_VObject_Component('VCALENDAR'); + $comp = new Component('VCALENDAR'); $comp->add('myprop','value'); $this->assertEquals(1, count($comp->children)); - $this->assertTrue($comp->children[0] instanceof Sabre_VObject_Property); + $this->assertTrue($comp->children[0] instanceof Property); $this->assertEquals('MYPROP',$comp->children[0]->name); $this->assertEquals('value',$comp->children[0]->value); } + function testAddScalarParams() { + + $comp = Component::create('VCALENDAR'); + + $comp->add('myprop','value',array('param1'=>'value1')); + + $this->assertEquals(1, count($comp->children)); + + $this->assertTrue($comp->children[0] instanceof Property); + $this->assertEquals('MYPROP',$comp->children[0]->name); + $this->assertEquals('value',$comp->children[0]->value); + + $this->assertEquals(1, count($comp->children[0]->parameters)); + + $this->assertTrue($comp->children[0]->parameters[0] instanceof Parameter); + $this->assertEquals('PARAM1',$comp->children[0]->parameters[0]->name); + $this->assertEquals('value1',$comp->children[0]->parameters[0]->value); + + } + + function testAddComponent() { - $comp = new Sabre_VObject_Component('VCALENDAR'); + $comp = new Component('VCALENDAR'); - $comp->add(new Sabre_VObject_Component('VEVENT')); + $comp->add(new Component('VEVENT')); $this->assertEquals(1, count($comp->children)); @@ -219,10 +242,10 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase { function testAddComponentTwice() { - $comp = new Sabre_VObject_Component('VCALENDAR'); + $comp = new Component('VCALENDAR'); - $comp->add(new Sabre_VObject_Component('VEVENT')); - $comp->add(new Sabre_VObject_Component('VEVENT')); + $comp->add(new Component('VEVENT')); + $comp->add(new Component('VEVENT')); $this->assertEquals(2, count($comp->children)); @@ -235,8 +258,8 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase { */ function testAddArgFail() { - $comp = new Sabre_VObject_Component('VCALENDAR'); - $comp->add(new Sabre_VObject_Component('VEVENT'),'hello'); + $comp = new Component('VCALENDAR'); + $comp->add(new Component('VEVENT'),'hello'); } @@ -245,7 +268,7 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase { */ function testAddArgFail2() { - $comp = new Sabre_VObject_Component('VCALENDAR'); + $comp = new Component('VCALENDAR'); $comp->add(array()); } @@ -255,7 +278,7 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase { */ function testAddArgFail3() { - $comp = new Sabre_VObject_Component('VCALENDAR'); + $comp = new Component('VCALENDAR'); $comp->add('hello',array()); } @@ -265,10 +288,10 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase { */ function testMagicSetInvalid() { - $comp = new Sabre_VObject_Component('VCALENDAR'); + $comp = new Component('VCALENDAR'); // Note that 'myProp' is ignored here. - $comp->myProp = new StdClass(); + $comp->myProp = new \StdClass(); $this->assertEquals(1, count($comp->children)); @@ -278,8 +301,8 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase { function testMagicUnset() { - $comp = new Sabre_VObject_Component('VCALENDAR'); - $comp->add(new Sabre_VObject_Component('VEVENT')); + $comp = new Component('VCALENDAR'); + $comp->add(new Component('VEVENT')); unset($comp->vevent); @@ -290,34 +313,34 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase { function testCount() { - $comp = new Sabre_VObject_Component('VCALENDAR'); + $comp = new Component('VCALENDAR'); $this->assertEquals(1,$comp->count()); } function testChildren() { - $comp = new Sabre_VObject_Component('VCALENDAR'); + $comp = new Component('VCALENDAR'); // Note that 'myProp' is ignored here. $comp->children = array( - new Sabre_VObject_Component('VEVENT'), - new Sabre_VObject_Component('VTODO') + new Component('VEVENT'), + new Component('VTODO') ); $r = $comp->children(); - $this->assertTrue($r instanceof Sabre_VObject_ElementList); + $this->assertTrue($r instanceof ElementList); $this->assertEquals(2,count($r)); } function testGetComponents() { - $comp = new Sabre_VObject_Component('VCALENDAR'); + $comp = new Component('VCALENDAR'); // Note that 'myProp' is ignored here. $comp->children = array( - new Sabre_VObject_Property('FOO','BAR'), - new Sabre_VObject_Component('VTODO') + new Property('FOO','BAR'), + new Component('VTODO') ); $r = $comp->getComponents(); @@ -328,17 +351,17 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase { function testSerialize() { - $comp = new Sabre_VObject_Component('VCALENDAR'); + $comp = new Component('VCALENDAR'); $this->assertEquals("BEGIN:VCALENDAR\r\nEND:VCALENDAR\r\n", $comp->serialize()); } function testSerializeChildren() { - $comp = new Sabre_VObject_Component('VCALENDAR'); + $comp = new Component('VCALENDAR'); $comp->children = array( - new Sabre_VObject_Component('VEVENT'), - new Sabre_VObject_Component('VTODO') + new Component('VEVENT'), + new Component('VTODO') ); $str = $comp->serialize(); @@ -349,11 +372,11 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase { function testSerializeOrderCompAndProp() { - $comp = new Sabre_VObject_Component('VCALENDAR'); - $comp->add(new Sabre_VObject_Component('VEVENT')); + $comp = new Component('VCALENDAR'); + $comp->add(new Component('VEVENT')); $comp->add('PROP1','BLABLA'); $comp->add('VERSION','2.0'); - $comp->add(new Sabre_VObject_Component('VTIMEZONE')); + $comp->add(new Component('VTIMEZONE')); $str = $comp->serialize(); @@ -365,7 +388,7 @@ class Sabre_VObject_ComponentTest extends PHPUnit_Framework_TestCase { $prop4s=array('1', '2', '3', '4', '5', '6', '7', '8', '9', '10'); - $comp = new Sabre_VObject_Component('VCARD'); + $comp = new Component('VCARD'); $comp->__set('SOMEPROP','FOO'); $comp->__set('ANOTHERPROP','FOO'); $comp->__set('THIRDPROP','FOO'); diff --git a/dav/sabre-vobject/tests/Sabre/VObject/DateTimeParserTest.php b/dav/sabre-vobject/tests/Sabre/VObject/DateTimeParserTest.php new file mode 100644 index 000000000..463e7bcc2 --- /dev/null +++ b/dav/sabre-vobject/tests/Sabre/VObject/DateTimeParserTest.php @@ -0,0 +1,121 @@ +assertEquals('+1 weeks', DateTimeParser::parseDuration('P1W',true)); + $this->assertEquals('+5 days', DateTimeParser::parseDuration('P5D',true)); + $this->assertEquals('+5 days 3 hours 50 minutes 12 seconds', DateTimeParser::parseDuration('P5DT3H50M12S',true)); + $this->assertEquals('-1 weeks 50 minutes', DateTimeParser::parseDuration('-P1WT50M',true)); + $this->assertEquals('+50 days 3 hours 2 seconds', DateTimeParser::parseDuration('+P50DT3H2S',true)); + $this->assertEquals(new DateInterval('PT0S'), DateTimeParser::parseDuration('PT0S')); + + } + + function testParseICalendarDurationDateInterval() { + + $expected = new DateInterval('P7D'); + $this->assertEquals($expected, DateTimeParser::parseDuration('P1W')); + $this->assertEquals($expected, DateTimeParser::parse('P1W')); + + $expected = new DateInterval('PT3M'); + $expected->invert = true; + $this->assertEquals($expected, DateTimeParser::parseDuration('-PT3M')); + + } + + /** + * @expectedException LogicException + */ + function testParseICalendarDurationFail() { + + DateTimeParser::parseDuration('P1X',true); + + } + + function testParseICalendarDateTime() { + + $dateTime = DateTimeParser::parseDateTime('20100316T141405'); + + $compare = new DateTime('2010-03-16 14:14:05',new DateTimeZone('UTC')); + + $this->assertEquals($compare, $dateTime); + + } + + /** + * @depends testParseICalendarDateTime + * @expectedException LogicException + */ + function testParseICalendarDateTimeBadFormat() { + + $dateTime = DateTimeParser::parseDateTime('20100316T141405 '); + + } + + /** + * @depends testParseICalendarDateTime + */ + function testParseICalendarDateTimeUTC() { + + $dateTime = DateTimeParser::parseDateTime('20100316T141405Z'); + + $compare = new DateTime('2010-03-16 14:14:05',new DateTimeZone('UTC')); + $this->assertEquals($compare, $dateTime); + + } + + /** + * @depends testParseICalendarDateTime + */ + function testParseICalendarDateTimeUTC2() { + + $dateTime = DateTimeParser::parseDateTime('20101211T160000Z'); + + $compare = new DateTime('2010-12-11 16:00:00',new DateTimeZone('UTC')); + $this->assertEquals($compare, $dateTime); + + } + + /** + * @depends testParseICalendarDateTime + */ + function testParseICalendarDateTimeCustomTimeZone() { + + $dateTime = DateTimeParser::parseDateTime('20100316T141405', new DateTimeZone('Europe/Amsterdam')); + + $compare = new DateTime('2010-03-16 13:14:05',new DateTimeZone('UTC')); + $this->assertEquals($compare, $dateTime); + + } + + function testParseICalendarDate() { + + $dateTime = DateTimeParser::parseDate('20100316'); + + $expected = new DateTime('2010-03-16 00:00:00',new DateTimeZone('UTC')); + + $this->assertEquals($expected, $dateTime); + + $dateTime = DateTimeParser::parse('20100316'); + $this->assertEquals($expected, $dateTime); + + } + + /** + * @depends testParseICalendarDate + * @expectedException LogicException + */ + function testParseICalendarDateBadFormat() { + + $dateTime = DateTimeParser::parseDate('20100316T141405'); + + } +} diff --git a/dav/SabreDAV/tests/Sabre/VObject/ElementListTest.php b/dav/sabre-vobject/tests/Sabre/VObject/ElementListTest.php similarity index 55% rename from dav/SabreDAV/tests/Sabre/VObject/ElementListTest.php rename to dav/sabre-vobject/tests/Sabre/VObject/ElementListTest.php index 5bc8b43c5..84e1bcbe9 100644 --- a/dav/SabreDAV/tests/Sabre/VObject/ElementListTest.php +++ b/dav/sabre-vobject/tests/Sabre/VObject/ElementListTest.php @@ -1,10 +1,12 @@ $subcomponent) { $count++; - $this->assertInstanceOf('Sabre_VObject_Component',$subcomponent); + $this->assertInstanceOf('Sabre\\VObject\\Component',$subcomponent); } $this->assertEquals(3,$count); diff --git a/dav/SabreDAV/tests/Sabre/VObject/EmClientTest.php b/dav/sabre-vobject/tests/Sabre/VObject/EmClientTest.php similarity index 81% rename from dav/SabreDAV/tests/Sabre/VObject/EmClientTest.php rename to dav/sabre-vobject/tests/Sabre/VObject/EmClientTest.php index 69330230f..69d410fe7 100644 --- a/dav/SabreDAV/tests/Sabre/VObject/EmClientTest.php +++ b/dav/sabre-vobject/tests/Sabre/VObject/EmClientTest.php @@ -1,6 +1,8 @@ VEVENT->DTSTART->getDateTime(); - $this->assertEquals(new DateTime('2011-10-08 19:30:00', new DateTimeZone('America/Chicago')), $dt); + $this->assertEquals(new \DateTime('2011-10-08 19:30:00', new \DateTimeZone('America/Chicago')), $dt); } diff --git a/dav/SabreDAV/tests/Sabre/VObject/FreeBusyGeneratorTest.php b/dav/sabre-vobject/tests/Sabre/VObject/FreeBusyGeneratorTest.php similarity index 81% rename from dav/SabreDAV/tests/Sabre/VObject/FreeBusyGeneratorTest.php rename to dav/sabre-vobject/tests/Sabre/VObject/FreeBusyGeneratorTest.php index d84f5a489..1f79e0a47 100644 --- a/dav/SabreDAV/tests/Sabre/VObject/FreeBusyGeneratorTest.php +++ b/dav/sabre-vobject/tests/Sabre/VObject/FreeBusyGeneratorTest.php @@ -1,6 +1,8 @@ setObjects($this->getInput()); - $gen->setTimeRange( - new DateTime('20110101T110000Z'), - new DateTime('20110103T110000Z') + $gen = new FreeBusyGenerator( + new \DateTime('20110101T110000Z', new \DateTimeZone('UTC')), + new \DateTime('20110103T110000Z', new \DateTimeZone('UTC')), + $this->getInput() ); $result = $gen->getResult(); @@ -216,10 +217,10 @@ ICS; function testGeneratorBaseObject() { - $obj = new Sabre_VObject_Component('VCALENDAR'); + $obj = new Component('VCALENDAR'); $obj->METHOD = 'PUBLISH'; - $gen = new Sabre_VObject_FreeBusyGenerator(); + $gen = new FreeBusyGenerator(); $gen->setObjects(array()); $gen->setBaseObject($obj); @@ -227,20 +228,6 @@ ICS; $this->assertEquals('PUBLISH', $result->METHOD->value); - } - function testGeneratorNoVersion() { - - $v = Sabre_DAV_Server::$exposeVersion; - Sabre_DAV_Server::$exposeVersion = false; - - $gen = new Sabre_VObject_FreeBusyGenerator(); - $gen->setObjects(array()); - - $result = $gen->getResult(); - Sabre_DAV_Server::$exposeVersion = $v; - - $this->assertFalse(strpos($result->PRODID->value, Sabre_VObject_Version::VERSION)); - } /** @@ -248,8 +235,11 @@ ICS; */ function testInvalidArg() { - $gen = new Sabre_VObject_FreeBusyGenerator(); - $gen->setObjects(array(new StdClass())); + $gen = new FreeBusyGenerator( + new \DateTime('2012-01-01'), + new \DateTime('2012-12-31'), + new \StdClass() + ); } diff --git a/dav/sabre-vobject/tests/Sabre/VObject/Issue153Test.php b/dav/sabre-vobject/tests/Sabre/VObject/Issue153Test.php new file mode 100644 index 000000000..1cc14c161 --- /dev/null +++ b/dav/sabre-vobject/tests/Sabre/VObject/Issue153Test.php @@ -0,0 +1,14 @@ +assertEquals('Test Benutzer', (string)$obj->fn); + + } + +} diff --git a/dav/SabreDAV/tests/Sabre/VObject/Issue154Test.php b/dav/sabre-vobject/tests/Sabre/VObject/Issue154Test.php similarity index 81% rename from dav/SabreDAV/tests/Sabre/VObject/Issue154Test.php rename to dav/sabre-vobject/tests/Sabre/VObject/Issue154Test.php index f5136be12..ed9c7c3f4 100644 --- a/dav/SabreDAV/tests/Sabre/VObject/Issue154Test.php +++ b/dav/sabre-vobject/tests/Sabre/VObject/Issue154Test.php @@ -1,10 +1,12 @@ VERSION = '3.0'; $vcard->PHOTO = base64_encode('random_stuff'); $vcard->PHOTO->add('BASE64',null); diff --git a/dav/SabreDAV/tests/Sabre/VObject/ParameterTest.php b/dav/sabre-vobject/tests/Sabre/VObject/ParameterTest.php similarity index 60% rename from dav/SabreDAV/tests/Sabre/VObject/ParameterTest.php rename to dav/sabre-vobject/tests/Sabre/VObject/ParameterTest.php index ea3099718..150830459 100644 --- a/dav/SabreDAV/tests/Sabre/VObject/ParameterTest.php +++ b/dav/sabre-vobject/tests/Sabre/VObject/ParameterTest.php @@ -1,10 +1,12 @@ assertEquals('NAME',$param->name); $this->assertEquals('value',$param->value); @@ -12,7 +14,7 @@ class Sabre_VObject_ParameterTest extends PHPUnit_Framework_TestCase { function testCastToString() { - $param = new Sabre_VObject_Parameter('name','value'); + $param = new Parameter('name','value'); $this->assertEquals('value',$param->__toString()); $this->assertEquals('value',(string)$param); diff --git a/dav/SabreDAV/tests/Sabre/VObject/Property/DateTimeTest.php b/dav/sabre-vobject/tests/Sabre/VObject/Property/DateTimeTest.php similarity index 58% rename from dav/SabreDAV/tests/Sabre/VObject/Property/DateTimeTest.php rename to dav/sabre-vobject/tests/Sabre/VObject/Property/DateTimeTest.php index d6a9830d3..9dc7e8610 100644 --- a/dav/SabreDAV/tests/Sabre/VObject/Property/DateTimeTest.php +++ b/dav/sabre-vobject/tests/Sabre/VObject/Property/DateTimeTest.php @@ -1,14 +1,17 @@ setTimeZone($tz); - $elem = new Sabre_VObject_Property_DateTime('DTSTART'); + $elem = new DateTime('DTSTART'); $elem->setDateTime($dt); $this->assertEquals('19850704T013000', $elem->value); @@ -19,12 +22,12 @@ class Sabre_VObject_Property_DateTimeTest extends PHPUnit_Framework_TestCase { function testSetDateTimeLOCAL() { - $tz = new DateTimeZone('Europe/Amsterdam'); - $dt = new DateTime('1985-07-04 01:30:00', $tz); + $tz = new \DateTimeZone('Europe/Amsterdam'); + $dt = new \DateTime('1985-07-04 01:30:00', $tz); $dt->setTimeZone($tz); - $elem = new Sabre_VObject_Property_DateTime('DTSTART'); - $elem->setDateTime($dt, Sabre_VObject_Property_DateTime::LOCAL); + $elem = new DateTime('DTSTART'); + $elem->setDateTime($dt, DateTime::LOCAL); $this->assertEquals('19850704T013000', $elem->value); $this->assertNull($elem['TZID']); @@ -34,12 +37,12 @@ class Sabre_VObject_Property_DateTimeTest extends PHPUnit_Framework_TestCase { function testSetDateTimeUTC() { - $tz = new DateTimeZone('GMT'); - $dt = new DateTime('1985-07-04 01:30:00', $tz); + $tz = new \DateTimeZone('GMT'); + $dt = new \DateTime('1985-07-04 01:30:00', $tz); $dt->setTimeZone($tz); - $elem = new Sabre_VObject_Property_DateTime('DTSTART'); - $elem->setDateTime($dt, Sabre_VObject_Property_DateTime::UTC); + $elem = new DateTime('DTSTART'); + $elem->setDateTime($dt, DateTime::UTC); $this->assertEquals('19850704T013000Z', $elem->value); $this->assertNull($elem['TZID']); @@ -49,12 +52,12 @@ class Sabre_VObject_Property_DateTimeTest extends PHPUnit_Framework_TestCase { function testSetDateTimeLOCALTZ() { - $tz = new DateTimeZone('Europe/Amsterdam'); - $dt = new DateTime('1985-07-04 01:30:00', $tz); + $tz = new \DateTimeZone('Europe/Amsterdam'); + $dt = new \DateTime('1985-07-04 01:30:00', $tz); $dt->setTimeZone($tz); - $elem = new Sabre_VObject_Property_DateTime('DTSTART'); - $elem->setDateTime($dt, Sabre_VObject_Property_DateTime::LOCALTZ); + $elem = new DateTime('DTSTART'); + $elem->setDateTime($dt, DateTime::LOCALTZ); $this->assertEquals('19850704T013000', $elem->value); $this->assertEquals('Europe/Amsterdam', (string)$elem['TZID']); @@ -64,12 +67,12 @@ class Sabre_VObject_Property_DateTimeTest extends PHPUnit_Framework_TestCase { function testSetDateTimeDATE() { - $tz = new DateTimeZone('Europe/Amsterdam'); - $dt = new DateTime('1985-07-04 01:30:00', $tz); + $tz = new \DateTimeZone('Europe/Amsterdam'); + $dt = new \DateTime('1985-07-04 01:30:00', $tz); $dt->setTimeZone($tz); - $elem = new Sabre_VObject_Property_DateTime('DTSTART'); - $elem->setDateTime($dt, Sabre_VObject_Property_DateTime::DATE); + $elem = new DateTime('DTSTART'); + $elem->setDateTime($dt, DateTime::DATE); $this->assertEquals('19850704', $elem->value); $this->assertNull($elem['TZID']); @@ -82,22 +85,22 @@ class Sabre_VObject_Property_DateTimeTest extends PHPUnit_Framework_TestCase { */ function testSetDateTimeInvalid() { - $tz = new DateTimeZone('Europe/Amsterdam'); - $dt = new DateTime('1985-07-04 01:30:00', $tz); + $tz = new \DateTimeZone('Europe/Amsterdam'); + $dt = new \DateTime('1985-07-04 01:30:00', $tz); $dt->setTimeZone($tz); - $elem = new Sabre_VObject_Property_DateTime('DTSTART'); + $elem = new DateTime('DTSTART'); $elem->setDateTime($dt, 7); } function testGetDateTimeCached() { - $tz = new DateTimeZone('Europe/Amsterdam'); - $dt = new DateTime('1985-07-04 01:30:00', $tz); + $tz = new \DateTimeZone('Europe/Amsterdam'); + $dt = new \DateTime('1985-07-04 01:30:00', $tz); $dt->setTimeZone($tz); - $elem = new Sabre_VObject_Property_DateTime('DTSTART'); + $elem = new DateTime('DTSTART'); $elem->setDateTime($dt); $this->assertEquals($elem->getDateTime(), $dt); @@ -106,7 +109,7 @@ class Sabre_VObject_Property_DateTimeTest extends PHPUnit_Framework_TestCase { function testGetDateTimeDateNULL() { - $elem = new Sabre_VObject_Property_DateTime('DTSTART'); + $elem = new DateTime('DTSTART'); $dt = $elem->getDateTime(); $this->assertNull($dt); @@ -116,42 +119,42 @@ class Sabre_VObject_Property_DateTimeTest extends PHPUnit_Framework_TestCase { function testGetDateTimeDateDATE() { - $elem = new Sabre_VObject_Property_DateTime('DTSTART','19850704'); + $elem = new DateTime('DTSTART','19850704'); $dt = $elem->getDateTime(); $this->assertInstanceOf('DateTime', $dt); $this->assertEquals('1985-07-04 00:00:00', $dt->format('Y-m-d H:i:s')); - $this->assertEquals(Sabre_VObject_Property_DateTime::DATE, $elem->getDateType()); + $this->assertEquals(DateTime::DATE, $elem->getDateType()); } function testGetDateTimeDateLOCAL() { - $elem = new Sabre_VObject_Property_DateTime('DTSTART','19850704T013000'); + $elem = new DateTime('DTSTART','19850704T013000'); $dt = $elem->getDateTime(); $this->assertInstanceOf('DateTime', $dt); $this->assertEquals('1985-07-04 01:30:00', $dt->format('Y-m-d H:i:s')); - $this->assertEquals(Sabre_VObject_Property_DateTime::LOCAL, $elem->getDateType()); + $this->assertEquals(DateTime::LOCAL, $elem->getDateType()); } function testGetDateTimeDateUTC() { - $elem = new Sabre_VObject_Property_DateTime('DTSTART','19850704T013000Z'); + $elem = new DateTime('DTSTART','19850704T013000Z'); $dt = $elem->getDateTime(); $this->assertInstanceOf('DateTime', $dt); $this->assertEquals('1985-07-04 01:30:00', $dt->format('Y-m-d H:i:s')); $this->assertEquals('UTC', $dt->getTimeZone()->getName()); - $this->assertEquals(Sabre_VObject_Property_DateTime::UTC, $elem->getDateType()); + $this->assertEquals(DateTime::UTC, $elem->getDateType()); } function testGetDateTimeDateLOCALTZ() { - $elem = new Sabre_VObject_Property_DateTime('DTSTART','19850704T013000'); + $elem = new DateTime('DTSTART','19850704T013000'); $elem['TZID'] = 'Europe/Amsterdam'; $dt = $elem->getDateTime(); @@ -159,7 +162,7 @@ class Sabre_VObject_Property_DateTimeTest extends PHPUnit_Framework_TestCase { $this->assertInstanceOf('DateTime', $dt); $this->assertEquals('1985-07-04 01:30:00', $dt->format('Y-m-d H:i:s')); $this->assertEquals('Europe/Amsterdam', $dt->getTimeZone()->getName()); - $this->assertEquals(Sabre_VObject_Property_DateTime::LOCALTZ, $elem->getDateType()); + $this->assertEquals(DateTime::LOCALTZ, $elem->getDateType()); } @@ -168,25 +171,25 @@ class Sabre_VObject_Property_DateTimeTest extends PHPUnit_Framework_TestCase { */ function testGetDateTimeDateInvalid() { - $elem = new Sabre_VObject_Property_DateTime('DTSTART','bla'); + $elem = new DateTime('DTSTART','bla'); $dt = $elem->getDateTime(); } function testGetDateTimeWeirdTZ() { - $elem = new Sabre_VObject_Property_DateTime('DTSTART','19850704T013000'); + $elem = new DateTime('DTSTART','19850704T013000'); $elem['TZID'] = '/freeassociation.sourceforge.net/Tzfile/Europe/Amsterdam'; - $event = new Sabre_VObject_Component('VEVENT'); + $event = new Component('VEVENT'); $event->add($elem); - $timezone = new Sabre_VObject_Component('VTIMEZONE'); + $timezone = new Component('VTIMEZONE'); $timezone->TZID = '/freeassociation.sourceforge.net/Tzfile/Europe/Amsterdam'; $timezone->{'X-LIC-LOCATION'} = 'Europe/Amsterdam'; - $calendar = new Sabre_VObject_Component('VCALENDAR'); + $calendar = new Component('VCALENDAR'); $calendar->add($event); $calendar->add($timezone); @@ -195,7 +198,7 @@ class Sabre_VObject_Property_DateTimeTest extends PHPUnit_Framework_TestCase { $this->assertInstanceOf('DateTime', $dt); $this->assertEquals('1985-07-04 01:30:00', $dt->format('Y-m-d H:i:s')); $this->assertEquals('Europe/Amsterdam', $dt->getTimeZone()->getName()); - $this->assertEquals(Sabre_VObject_Property_DateTime::LOCALTZ, $elem->getDateType()); + $this->assertEquals(DateTime::LOCALTZ, $elem->getDateType()); } @@ -204,18 +207,18 @@ class Sabre_VObject_Property_DateTimeTest extends PHPUnit_Framework_TestCase { $default = date_default_timezone_get(); date_default_timezone_set('Canada/Eastern'); - $elem = new Sabre_VObject_Property_DateTime('DTSTART','19850704T013000'); + $elem = new DateTime('DTSTART','19850704T013000'); $elem['TZID'] = 'Moon'; - $event = new Sabre_VObject_Component('VEVENT'); + $event = new Component('VEVENT'); $event->add($elem); - $timezone = new Sabre_VObject_Component('VTIMEZONE'); + $timezone = new Component('VTIMEZONE'); $timezone->TZID = 'Moon'; $timezone->{'X-LIC-LOCATION'} = 'Moon'; - $calendar = new Sabre_VObject_Component('VCALENDAR'); + $calendar = new Component('VCALENDAR'); $calendar->add($event); $calendar->add($timezone); @@ -224,7 +227,7 @@ class Sabre_VObject_Property_DateTimeTest extends PHPUnit_Framework_TestCase { $this->assertInstanceOf('DateTime', $dt); $this->assertEquals('1985-07-04 01:30:00', $dt->format('Y-m-d H:i:s')); $this->assertEquals('Canada/Eastern', $dt->getTimeZone()->getName()); - $this->assertEquals(Sabre_VObject_Property_DateTime::LOCALTZ, $elem->getDateType()); + $this->assertEquals(DateTime::LOCALTZ, $elem->getDateType()); date_default_timezone_set($default); } diff --git a/dav/SabreDAV/tests/Sabre/VObject/Property/MultiDateTimeTest.php b/dav/sabre-vobject/tests/Sabre/VObject/Property/MultiDateTimeTest.php similarity index 55% rename from dav/SabreDAV/tests/Sabre/VObject/Property/MultiDateTimeTest.php rename to dav/sabre-vobject/tests/Sabre/VObject/Property/MultiDateTimeTest.php index 4d70ed3d7..eae3e2bb2 100644 --- a/dav/SabreDAV/tests/Sabre/VObject/Property/MultiDateTimeTest.php +++ b/dav/sabre-vobject/tests/Sabre/VObject/Property/MultiDateTimeTest.php @@ -1,16 +1,18 @@ setTimeZone($tz); $dt2->setTimeZone($tz); - $elem = new Sabre_VObject_Property_MultiDateTime('DTSTART'); + $elem = new MultiDateTime('DTSTART'); $elem->setDateTimes(array($dt1,$dt2)); $this->assertEquals('19850704T013000,19860704T013000', $elem->value); @@ -21,14 +23,14 @@ class Sabre_VObject_Property_MultiDateTimeTest extends PHPUnit_Framework_TestCas function testSetDateTimeLOCAL() { - $tz = new DateTimeZone('Europe/Amsterdam'); - $dt1 = new DateTime('1985-07-04 01:30:00', $tz); - $dt2 = new DateTime('1986-07-04 01:30:00', $tz); + $tz = new \DateTimeZone('Europe/Amsterdam'); + $dt1 = new \DateTime('1985-07-04 01:30:00', $tz); + $dt2 = new \DateTime('1986-07-04 01:30:00', $tz); $dt1->setTimeZone($tz); $dt2->setTimeZone($tz); - $elem = new Sabre_VObject_Property_MultiDateTime('DTSTART'); - $elem->setDateTimes(array($dt1,$dt2), Sabre_VObject_Property_DateTime::LOCAL); + $elem = new MultiDateTime('DTSTART'); + $elem->setDateTimes(array($dt1,$dt2), DateTime::LOCAL); $this->assertEquals('19850704T013000,19860704T013000', $elem->value); $this->assertNull($elem['TZID']); @@ -38,14 +40,14 @@ class Sabre_VObject_Property_MultiDateTimeTest extends PHPUnit_Framework_TestCas function testSetDateTimeUTC() { - $tz = new DateTimeZone('GMT'); - $dt1 = new DateTime('1985-07-04 01:30:00', $tz); - $dt2 = new DateTime('1986-07-04 01:30:00', $tz); + $tz = new \DateTimeZone('GMT'); + $dt1 = new \DateTime('1985-07-04 01:30:00', $tz); + $dt2 = new \DateTime('1986-07-04 01:30:00', $tz); $dt1->setTimeZone($tz); $dt2->setTimeZone($tz); - $elem = new Sabre_VObject_Property_MultiDateTime('DTSTART'); - $elem->setDateTimes(array($dt1,$dt2), Sabre_VObject_Property_DateTime::UTC); + $elem = new MultiDateTime('DTSTART'); + $elem->setDateTimes(array($dt1,$dt2), DateTime::UTC); $this->assertEquals('19850704T013000Z,19860704T013000Z', $elem->value); $this->assertNull($elem['TZID']); @@ -55,14 +57,14 @@ class Sabre_VObject_Property_MultiDateTimeTest extends PHPUnit_Framework_TestCas function testSetDateTimeLOCALTZ() { - $tz = new DateTimeZone('Europe/Amsterdam'); - $dt1 = new DateTime('1985-07-04 01:30:00', $tz); - $dt2 = new DateTime('1986-07-04 01:30:00', $tz); + $tz = new \DateTimeZone('Europe/Amsterdam'); + $dt1 = new \DateTime('1985-07-04 01:30:00', $tz); + $dt2 = new \DateTime('1986-07-04 01:30:00', $tz); $dt1->setTimeZone($tz); $dt2->setTimeZone($tz); - $elem = new Sabre_VObject_Property_MultiDateTime('DTSTART'); - $elem->setDateTimes(array($dt1,$dt2), Sabre_VObject_Property_DateTime::LOCALTZ); + $elem = new MultiDateTime('DTSTART'); + $elem->setDateTimes(array($dt1,$dt2), DateTime::LOCALTZ); $this->assertEquals('19850704T013000,19860704T013000', $elem->value); $this->assertEquals('Europe/Amsterdam', (string)$elem['TZID']); @@ -72,14 +74,14 @@ class Sabre_VObject_Property_MultiDateTimeTest extends PHPUnit_Framework_TestCas function testSetDateTimeDATE() { - $tz = new DateTimeZone('Europe/Amsterdam'); - $dt1 = new datetime('1985-07-04 01:30:00', $tz); - $dt2 = new datetime('1986-07-04 01:30:00', $tz); + $tz = new \DateTimeZone('Europe/Amsterdam'); + $dt1 = new \DateTime('1985-07-04 01:30:00', $tz); + $dt2 = new \DateTime('1986-07-04 01:30:00', $tz); $dt1->settimezone($tz); $dt2->settimezone($tz); - $elem = new Sabre_VObject_Property_MultiDateTime('DTSTART'); - $elem->setDateTimes(array($dt1,$dt2), Sabre_VObject_Property_DateTime::DATE); + $elem = new MultiDateTime('DTSTART'); + $elem->setDateTimes(array($dt1,$dt2), DateTime::DATE); $this->assertEquals('19850704,19860704', $elem->value); $this->assertNull($elem['TZID']); @@ -92,24 +94,24 @@ class Sabre_VObject_Property_MultiDateTimeTest extends PHPUnit_Framework_TestCas */ function testSetDateTimeInvalid() { - $tz = new DateTimeZone('Europe/Amsterdam'); - $dt = new DateTime('1985-07-04 01:30:00', $tz); + $tz = new \DateTimeZone('Europe/Amsterdam'); + $dt = new \DateTime('1985-07-04 01:30:00', $tz); $dt->setTimeZone($tz); - $elem = new Sabre_VObject_Property_MultiDateTime('DTSTART'); + $elem = new MultiDateTime('DTSTART'); $elem->setDateTimes(array($dt), 7); } function testGetDateTimeCached() { - $tz = new DateTimeZone('Europe/Amsterdam'); - $dt1 = new datetime('1985-07-04 01:30:00', $tz); - $dt2 = new datetime('1986-07-04 01:30:00', $tz); + $tz = new \DateTimeZone('Europe/Amsterdam'); + $dt1 = new \DateTime('1985-07-04 01:30:00', $tz); + $dt2 = new \DateTime('1986-07-04 01:30:00', $tz); $dt1->settimezone($tz); $dt2->settimezone($tz); - $elem = new Sabre_VObject_Property_MultiDateTime('DTSTART'); + $elem = new MultiDateTime('DTSTART'); $elem->setDateTimes(array($dt1,$dt2)); $this->assertEquals($elem->getDateTimes(), array($dt1,$dt2)); @@ -118,7 +120,7 @@ class Sabre_VObject_Property_MultiDateTimeTest extends PHPUnit_Framework_TestCas function testGetDateTimeDateNULL() { - $elem = new Sabre_VObject_Property_MultiDateTime('DTSTART'); + $elem = new MultiDateTime('DTSTART'); $dt = $elem->getDateTimes(); $this->assertNull($dt); @@ -128,20 +130,20 @@ class Sabre_VObject_Property_MultiDateTimeTest extends PHPUnit_Framework_TestCas function testGetDateTimeDateDATE() { - $elem = new Sabre_VObject_Property_MultiDateTime('DTSTART','19850704,19860704'); + $elem = new MultiDateTime('DTSTART','19850704,19860704'); $dt = $elem->getDateTimes(); $this->assertEquals('1985-07-04 00:00:00', $dt[0]->format('Y-m-d H:i:s')); $this->assertEquals('1986-07-04 00:00:00', $dt[1]->format('Y-m-d H:i:s')); - $this->assertEquals(Sabre_VObject_Property_DateTime::DATE, $elem->getDateType()); + $this->assertEquals(DateTime::DATE, $elem->getDateType()); } function testGetDateTimeDateDATEReverse() { - $elem = new Sabre_VObject_Property_MultiDateTime('DTSTART','19850704,19860704'); + $elem = new MultiDateTime('DTSTART','19850704,19860704'); - $this->assertEquals(Sabre_VObject_Property_DateTime::DATE, $elem->getDateType()); + $this->assertEquals(DateTime::DATE, $elem->getDateType()); $dt = $elem->getDateTimes(); $this->assertEquals('1985-07-04 00:00:00', $dt[0]->format('Y-m-d H:i:s')); @@ -152,30 +154,30 @@ class Sabre_VObject_Property_MultiDateTimeTest extends PHPUnit_Framework_TestCas function testGetDateTimeDateLOCAL() { - $elem = new Sabre_VObject_Property_DateTime('DTSTART','19850704T013000'); + $elem = new DateTime('DTSTART','19850704T013000'); $dt = $elem->getDateTime(); $this->assertInstanceOf('DateTime', $dt); $this->assertEquals('1985-07-04 01:30:00', $dt->format('Y-m-d H:i:s')); - $this->assertEquals(Sabre_VObject_Property_DateTime::LOCAL, $elem->getDateType()); + $this->assertEquals(DateTime::LOCAL, $elem->getDateType()); } function testGetDateTimeDateUTC() { - $elem = new Sabre_VObject_Property_DateTime('DTSTART','19850704T013000Z'); + $elem = new DateTime('DTSTART','19850704T013000Z'); $dt = $elem->getDateTime(); $this->assertInstanceOf('DateTime', $dt); $this->assertEquals('1985-07-04 01:30:00', $dt->format('Y-m-d H:i:s')); $this->assertEquals('UTC', $dt->getTimeZone()->getName()); - $this->assertEquals(Sabre_VObject_Property_DateTime::UTC, $elem->getDateType()); + $this->assertEquals(DateTime::UTC, $elem->getDateType()); } function testGetDateTimeDateLOCALTZ() { - $elem = new Sabre_VObject_Property_DateTime('DTSTART','19850704T013000'); + $elem = new DateTime('DTSTART','19850704T013000'); $elem['TZID'] = 'Europe/Amsterdam'; $dt = $elem->getDateTime(); @@ -183,7 +185,7 @@ class Sabre_VObject_Property_MultiDateTimeTest extends PHPUnit_Framework_TestCas $this->assertInstanceOf('DateTime', $dt); $this->assertEquals('1985-07-04 01:30:00', $dt->format('Y-m-d H:i:s')); $this->assertEquals('Europe/Amsterdam', $dt->getTimeZone()->getName()); - $this->assertEquals(Sabre_VObject_Property_DateTime::LOCALTZ, $elem->getDateType()); + $this->assertEquals(DateTime::LOCALTZ, $elem->getDateType()); } @@ -192,7 +194,7 @@ class Sabre_VObject_Property_MultiDateTimeTest extends PHPUnit_Framework_TestCas */ function testGetDateTimeDateInvalid() { - $elem = new Sabre_VObject_Property_DateTime('DTSTART','bla'); + $elem = new DateTime('DTSTART','bla'); $dt = $elem->getDateTime(); } diff --git a/dav/SabreDAV/tests/Sabre/VObject/PropertyTest.php b/dav/sabre-vobject/tests/Sabre/VObject/PropertyTest.php similarity index 57% rename from dav/SabreDAV/tests/Sabre/VObject/PropertyTest.php rename to dav/sabre-vobject/tests/Sabre/VObject/PropertyTest.php index 40fb1468a..201646bb9 100644 --- a/dav/SabreDAV/tests/Sabre/VObject/PropertyTest.php +++ b/dav/sabre-vobject/tests/Sabre/VObject/PropertyTest.php @@ -1,10 +1,12 @@ assertEquals('PROPNAME', $property->name); $this->assertEquals('propvalue', $property->value); $this->assertEquals('propvalue', $property->__toString()); @@ -14,8 +16,8 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase { public function testParameterExists() { - $property = new Sabre_VObject_Property('propname','propvalue'); - $property->parameters[] = new Sabre_VObject_Parameter('paramname','paramvalue'); + $property = new Property('propname','propvalue'); + $property->parameters[] = new Parameter('paramname','paramvalue'); $this->assertTrue(isset($property['PARAMNAME'])); $this->assertTrue(isset($property['paramname'])); @@ -25,17 +27,17 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase { public function testParameterGet() { - $property = new Sabre_VObject_Property('propname','propvalue'); - $property->parameters[] = new Sabre_VObject_Parameter('paramname','paramvalue'); + $property = new Property('propname','propvalue'); + $property->parameters[] = new Parameter('paramname','paramvalue'); - $this->assertInstanceOf('Sabre_VObject_Parameter',$property['paramname']); + $this->assertInstanceOf('Sabre\\VObject\\Parameter',$property['paramname']); } public function testParameterNotExists() { - $property = new Sabre_VObject_Property('propname','propvalue'); - $property->parameters[] = new Sabre_VObject_Parameter('paramname','paramvalue'); + $property = new Property('propname','propvalue'); + $property->parameters[] = new Parameter('paramname','paramvalue'); $this->assertInternalType('null',$property['foo']); @@ -43,22 +45,22 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase { public function testParameterMultiple() { - $property = new Sabre_VObject_Property('propname','propvalue'); - $property->parameters[] = new Sabre_VObject_Parameter('paramname','paramvalue'); - $property->parameters[] = new Sabre_VObject_Parameter('paramname','paramvalue'); + $property = new Property('propname','propvalue'); + $property->parameters[] = new Parameter('paramname','paramvalue'); + $property->parameters[] = new Parameter('paramname','paramvalue'); - $this->assertInstanceOf('Sabre_VObject_Parameter',$property['paramname']); + $this->assertInstanceOf('Sabre\\VObject\\Parameter',$property['paramname']); $this->assertEquals(2,count($property['paramname'])); } public function testSetParameterAsString() { - $property = new Sabre_VObject_Property('propname','propvalue'); + $property = new Property('propname','propvalue'); $property['paramname'] = 'paramvalue'; $this->assertEquals(1,count($property->parameters)); - $this->assertInstanceOf('Sabre_VObject_Parameter', $property->parameters[0]); + $this->assertInstanceOf('Sabre\\VObject\\Parameter', $property->parameters[0]); $this->assertEquals('PARAMNAME',$property->parameters[0]->name); $this->assertEquals('paramvalue',$property->parameters[0]->value); @@ -69,15 +71,15 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase { */ public function testSetParameterAsStringNoKey() { - $property = new Sabre_VObject_Property('propname','propvalue'); + $property = new Property('propname','propvalue'); $property[] = 'paramvalue'; } public function testSetParameterObject() { - $property = new Sabre_VObject_Property('propname','propvalue'); - $param = new Sabre_VObject_Parameter('paramname','paramvalue'); + $property = new Property('propname','propvalue'); + $param = new Parameter('paramname','paramvalue'); $property[] = $param; @@ -91,8 +93,8 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase { */ public function testSetParameterObjectWithKey() { - $property = new Sabre_VObject_Property('propname','propvalue'); - $param = new Sabre_VObject_Parameter('paramname','paramvalue'); + $property = new Property('propname','propvalue'); + $param = new Parameter('paramname','paramvalue'); $property['key'] = $param; @@ -104,15 +106,15 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase { */ public function testSetParameterObjectRandomObject() { - $property = new Sabre_VObject_Property('propname','propvalue'); - $property[] = new StdClass(); + $property = new Property('propname','propvalue'); + $property[] = new \StdClass(); } public function testUnsetParameter() { - $property = new Sabre_VObject_Property('propname','propvalue'); - $param = new Sabre_VObject_Parameter('paramname','paramvalue'); + $property = new Property('propname','propvalue'); + $param = new Parameter('paramname','paramvalue'); $property->parameters[] = $param; unset($property['PARAMNAME']); @@ -122,8 +124,8 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase { public function testParamCount() { - $property = new Sabre_VObject_Property('propname','propvalue'); - $param = new Sabre_VObject_Parameter('paramname','paramvalue'); + $property = new Property('propname','propvalue'); + $param = new Parameter('paramname','paramvalue'); $property->parameters[] = $param; $property->parameters[] = clone $param; @@ -133,7 +135,7 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase { public function testSerialize() { - $property = new Sabre_VObject_Property('propname','propvalue'); + $property = new Property('propname','propvalue'); $this->assertEquals("PROPNAME:propvalue\r\n",$property->serialize()); @@ -141,9 +143,9 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase { public function testSerializeParam() { - $property = new Sabre_VObject_Property('propname','propvalue'); - $property->parameters[] = new Sabre_VObject_Parameter('paramname','paramvalue'); - $property->parameters[] = new Sabre_VObject_Parameter('paramname2','paramvalue2'); + $property = new Property('propname','propvalue'); + $property->parameters[] = new Parameter('paramname','paramvalue'); + $property->parameters[] = new Parameter('paramname2','paramvalue2'); $this->assertEquals("PROPNAME;PARAMNAME=paramvalue;PARAMNAME2=paramvalue2:propvalue\r\n",$property->serialize()); @@ -151,7 +153,7 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase { public function testSerializeNewLine() { - $property = new Sabre_VObject_Property('propname',"line1\nline2"); + $property = new Property('propname',"line1\nline2"); $this->assertEquals("PROPNAME:line1\\nline2\r\n",$property->serialize()); @@ -160,7 +162,7 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase { public function testSerializeLongLine() { $value = str_repeat('!',200); - $property = new Sabre_VObject_Property('propname',$value); + $property = new Property('propname',$value); $expected = "PROPNAME:" . str_repeat('!',66) . "\r\n " . str_repeat('!',74) . "\r\n " . str_repeat('!',60) . "\r\n"; @@ -171,7 +173,7 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase { public function testSerializeUTF8LineFold() { $value = str_repeat('!',65) . "\xc3\xa4bla"; // inserted umlaut-a - $property = new Sabre_VObject_Property('propname', $value); + $property = new Property('propname', $value); $expected = "PROPNAME:" . str_repeat('!',65) . "\r\n \xc3\xa4bla\r\n"; $this->assertEquals($expected, $property->serialize()); @@ -179,8 +181,9 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase { public function testGetIterator() { - $it = new Sabre_VObject_ElementList(array()); - $property = new Sabre_VObject_Property('propname','propvalue', $it); + $it = new ElementList(array()); + $property = new Property('propname','propvalue'); + $property->setIterator($it); $this->assertEquals($it,$property->getIterator()); } @@ -188,22 +191,22 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase { public function testGetIteratorDefault() { - $property = new Sabre_VObject_Property('propname','propvalue'); + $property = new Property('propname','propvalue'); $it = $property->getIterator(); - $this->assertTrue($it instanceof Sabre_VObject_ElementList); + $this->assertTrue($it instanceof ElementList); $this->assertEquals(1,count($it)); } function testAddScalar() { - $property = new Sabre_VObject_Property('EMAIL'); + $property = new Property('EMAIL'); $property->add('myparam','value'); $this->assertEquals(1, count($property->parameters)); - $this->assertTrue($property->parameters[0] instanceof Sabre_VObject_Parameter); + $this->assertTrue($property->parameters[0] instanceof Parameter); $this->assertEquals('MYPARAM',$property->parameters[0]->name); $this->assertEquals('value',$property->parameters[0]->value); @@ -211,9 +214,9 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase { function testAddParameter() { - $prop = new Sabre_VObject_Property('EMAIL'); + $prop = new Property('EMAIL'); - $prop->add(new Sabre_VObject_Parameter('MYPARAM','value')); + $prop->add(new Parameter('MYPARAM','value')); $this->assertEquals(1, count($prop->parameters)); $this->assertEquals('MYPARAM',$prop['myparam']->name); @@ -222,10 +225,10 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase { function testAddParameterTwice() { - $prop = new Sabre_VObject_Property('EMAIL'); + $prop = new Property('EMAIL'); - $prop->add(new Sabre_VObject_Parameter('MYPARAM', 'value1')); - $prop->add(new Sabre_VObject_Parameter('MYPARAM', 'value2')); + $prop->add(new Parameter('MYPARAM', 'value1')); + $prop->add(new Parameter('MYPARAM', 'value2')); $this->assertEquals(2, count($prop->parameters)); @@ -238,8 +241,8 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase { */ function testAddArgFail() { - $prop = new Sabre_VObject_Property('EMAIL'); - $prop->add(new Sabre_VObject_Parameter('MPARAM'),'hello'); + $prop = new Property('EMAIL'); + $prop->add(new Parameter('MPARAM'),'hello'); } @@ -248,7 +251,7 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase { */ function testAddArgFail2() { - $property = new Sabre_VObject_Property('EMAIL','value'); + $property = new Property('EMAIL','value'); $property->add(array()); } @@ -258,14 +261,14 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase { */ function testAddArgFail3() { - $property = new Sabre_VObject_Property('EMAIL','value'); + $property = new Property('EMAIL','value'); $property->add('hello',array()); } function testClone() { - $property = new Sabre_VObject_Property('EMAIL','value'); + $property = new Property('EMAIL','value'); $property['FOO'] = 'BAR'; $property2 = clone $property; @@ -275,4 +278,16 @@ class Sabre_VObject_PropertyTest extends PHPUnit_Framework_TestCase { } + function testCreateParams() { + + $property = Property::create('X-PROP', 'value', array( + 'param1' => 'value1', + 'param2' => array('value2', 'value3') + )); + + $this->assertEquals(1, count($property['PARAM1'])); + $this->assertEquals(2, count($property['PARAM2'])); + + } + } diff --git a/dav/SabreDAV/tests/Sabre/VObject/ReaderTest.php b/dav/sabre-vobject/tests/Sabre/VObject/ReaderTest.php similarity index 70% rename from dav/SabreDAV/tests/Sabre/VObject/ReaderTest.php rename to dav/sabre-vobject/tests/Sabre/VObject/ReaderTest.php index a87651cdc..998ff6204 100644 --- a/dav/SabreDAV/tests/Sabre/VObject/ReaderTest.php +++ b/dav/sabre-vobject/tests/Sabre/VObject/ReaderTest.php @@ -1,14 +1,16 @@ assertInstanceOf('Sabre_VObject_Component', $result); + $this->assertInstanceOf('Sabre\\VObject\\Component', $result); $this->assertEquals('VCALENDAR', $result->name); $this->assertEquals(0, count($result->children)); @@ -18,9 +20,9 @@ class Sabre_VObject_ReaderTest extends PHPUnit_Framework_TestCase { $data = "BEGIN:VCALENDAR\nEND:VCALENDAR"; - $result = Sabre_VObject_Reader::read($data); + $result = Reader::read($data); - $this->assertInstanceOf('Sabre_VObject_Component', $result); + $this->assertInstanceOf('Sabre\\VObject\\Component', $result); $this->assertEquals('VCALENDAR', $result->name); $this->assertEquals(0, count($result->children)); @@ -30,9 +32,9 @@ class Sabre_VObject_ReaderTest extends PHPUnit_Framework_TestCase { $data = "BEGIN:VCALENDAR\rEND:VCALENDAR"; - $result = Sabre_VObject_Reader::read($data); + $result = Reader::read($data); - $this->assertInstanceOf('Sabre_VObject_Component', $result); + $this->assertInstanceOf('Sabre\\VObject\\Component', $result); $this->assertEquals('VCALENDAR', $result->name); $this->assertEquals(0, count($result->children)); @@ -42,31 +44,31 @@ class Sabre_VObject_ReaderTest extends PHPUnit_Framework_TestCase { $data = "BEGIN:\r\n\tVCALENDAR\r\nE\r\n ND:VCALENDAR"; - $result = Sabre_VObject_Reader::read($data); + $result = Reader::read($data); - $this->assertInstanceOf('Sabre_VObject_Component', $result); + $this->assertInstanceOf('Sabre\\VObject\\Component', $result); $this->assertEquals('VCALENDAR', $result->name); $this->assertEquals(0, count($result->children)); } /** - * @expectedException Sabre_VObject_ParseException + * @expectedException Sabre\VObject\ParseException */ function testReadCorruptComponent() { $data = "BEGIN:VCALENDAR\r\nEND:FOO"; - $result = Sabre_VObject_Reader::read($data); + $result = Reader::read($data); } function testReadProperty() { $data = "PROPNAME:propValue"; - $result = Sabre_VObject_Reader::read($data); + $result = Reader::read($data); - $this->assertInstanceOf('Sabre_VObject_Property', $result); + $this->assertInstanceOf('Sabre\\VObject\\Property', $result); $this->assertEquals('PROPNAME', $result->name); $this->assertEquals('propValue', $result->value); @@ -75,9 +77,9 @@ class Sabre_VObject_ReaderTest extends PHPUnit_Framework_TestCase { function testReadPropertyWithNewLine() { $data = 'PROPNAME:Line1\\nLine2\\NLine3\\\\Not the 4th line!'; - $result = Sabre_VObject_Reader::read($data); + $result = Reader::read($data); - $this->assertInstanceOf('Sabre_VObject_Property', $result); + $this->assertInstanceOf('Sabre\\VObject\\Property', $result); $this->assertEquals('PROPNAME', $result->name); $this->assertEquals("Line1\nLine2\nLine3\\Not the 4th line!", $result->value); @@ -86,9 +88,9 @@ class Sabre_VObject_ReaderTest extends PHPUnit_Framework_TestCase { function testReadMappedProperty() { $data = "DTSTART:20110529"; - $result = Sabre_VObject_Reader::read($data); + $result = Reader::read($data); - $this->assertInstanceOf('Sabre_VObject_Property_DateTime', $result); + $this->assertInstanceOf('Sabre\\VObject\\Property\\DateTime', $result); $this->assertEquals('DTSTART', $result->name); $this->assertEquals('20110529', $result->value); @@ -97,9 +99,9 @@ class Sabre_VObject_ReaderTest extends PHPUnit_Framework_TestCase { function testReadMappedPropertyGrouped() { $data = "foo.DTSTART:20110529"; - $result = Sabre_VObject_Reader::read($data); + $result = Reader::read($data); - $this->assertInstanceOf('Sabre_VObject_Property_DateTime', $result); + $this->assertInstanceOf('Sabre\\VObject\\Property\\DateTime', $result); $this->assertEquals('DTSTART', $result->name); $this->assertEquals('20110529', $result->value); @@ -107,12 +109,12 @@ class Sabre_VObject_ReaderTest extends PHPUnit_Framework_TestCase { /** - * @expectedException Sabre_VObject_ParseException + * @expectedException Sabre\VObject\ParseException */ function testReadBrokenLine() { $data = "PROPNAME;propValue"; - $result = Sabre_VObject_Reader::read($data); + $result = Reader::read($data); } @@ -124,12 +126,12 @@ class Sabre_VObject_ReaderTest extends PHPUnit_Framework_TestCase { "END:VCALENDAR" ); - $result = Sabre_VObject_Reader::read(implode("\r\n",$data)); + $result = Reader::read(implode("\r\n",$data)); - $this->assertInstanceOf('Sabre_VObject_Component', $result); + $this->assertInstanceOf('Sabre\\VObject\\Component', $result); $this->assertEquals('VCALENDAR', $result->name); $this->assertEquals(1, count($result->children)); - $this->assertInstanceOf('Sabre_VObject_Property', $result->children[0]); + $this->assertInstanceOf('Sabre\\VObject\\Property', $result->children[0]); $this->assertEquals('PROPNAME', $result->children[0]->name); $this->assertEquals('propValue', $result->children[0]->value); @@ -146,15 +148,15 @@ class Sabre_VObject_ReaderTest extends PHPUnit_Framework_TestCase { "END:VCALENDAR" ); - $result = Sabre_VObject_Reader::read(implode("\r\n",$data)); + $result = Reader::read(implode("\r\n",$data)); - $this->assertInstanceOf('Sabre_VObject_Component', $result); + $this->assertInstanceOf('Sabre\\VObject\\Component', $result); $this->assertEquals('VCALENDAR', $result->name); $this->assertEquals(1, count($result->children)); - $this->assertInstanceOf('Sabre_VObject_Component', $result->children[0]); + $this->assertInstanceOf('Sabre\\VObject\\Component', $result->children[0]); $this->assertEquals('VTIMEZONE', $result->children[0]->name); $this->assertEquals(1, count($result->children[0]->children)); - $this->assertInstanceOf('Sabre_VObject_Component', $result->children[0]->children[0]); + $this->assertInstanceOf('Sabre\\VObject\\Component', $result->children[0]->children[0]); $this->assertEquals('DAYLIGHT', $result->children[0]->children[0]->name); @@ -163,9 +165,9 @@ class Sabre_VObject_ReaderTest extends PHPUnit_Framework_TestCase { function testReadPropertyParameter() { $data = "PROPNAME;PARAMNAME=paramvalue:propValue"; - $result = Sabre_VObject_Reader::read($data); + $result = Reader::read($data); - $this->assertInstanceOf('Sabre_VObject_Property', $result); + $this->assertInstanceOf('Sabre\\VObject\\Property', $result); $this->assertEquals('PROPNAME', $result->name); $this->assertEquals('propValue', $result->value); $this->assertEquals(1, count($result->parameters)); @@ -177,9 +179,9 @@ class Sabre_VObject_ReaderTest extends PHPUnit_Framework_TestCase { function testReadPropertyNoValue() { $data = "PROPNAME;PARAMNAME:propValue"; - $result = Sabre_VObject_Reader::read($data); + $result = Reader::read($data); - $this->assertInstanceOf('Sabre_VObject_Property', $result); + $this->assertInstanceOf('Sabre\\VObject\\Property', $result); $this->assertEquals('PROPNAME', $result->name); $this->assertEquals('propValue', $result->value); $this->assertEquals(1, count($result->parameters)); @@ -191,9 +193,9 @@ class Sabre_VObject_ReaderTest extends PHPUnit_Framework_TestCase { function testReadPropertyParameterExtraColon() { $data = "PROPNAME;PARAMNAME=paramvalue:propValue:anotherrandomstring"; - $result = Sabre_VObject_Reader::read($data); + $result = Reader::read($data); - $this->assertInstanceOf('Sabre_VObject_Property', $result); + $this->assertInstanceOf('Sabre\\VObject\\Property', $result); $this->assertEquals('PROPNAME', $result->name); $this->assertEquals('propValue:anotherrandomstring', $result->value); $this->assertEquals(1, count($result->parameters)); @@ -205,9 +207,9 @@ class Sabre_VObject_ReaderTest extends PHPUnit_Framework_TestCase { function testReadProperty2Parameters() { $data = "PROPNAME;PARAMNAME=paramvalue;PARAMNAME2=paramvalue2:propValue"; - $result = Sabre_VObject_Reader::read($data); + $result = Reader::read($data); - $this->assertInstanceOf('Sabre_VObject_Property', $result); + $this->assertInstanceOf('Sabre\\VObject\\Property', $result); $this->assertEquals('PROPNAME', $result->name); $this->assertEquals('propValue', $result->value); $this->assertEquals(2, count($result->parameters)); @@ -221,9 +223,9 @@ class Sabre_VObject_ReaderTest extends PHPUnit_Framework_TestCase { function testReadPropertyParameterQuoted() { $data = "PROPNAME;PARAMNAME=\"paramvalue\":propValue"; - $result = Sabre_VObject_Reader::read($data); + $result = Reader::read($data); - $this->assertInstanceOf('Sabre_VObject_Property', $result); + $this->assertInstanceOf('Sabre\\VObject\\Property', $result); $this->assertEquals('PROPNAME', $result->name); $this->assertEquals('propValue', $result->value); $this->assertEquals(1, count($result->parameters)); @@ -234,9 +236,9 @@ class Sabre_VObject_ReaderTest extends PHPUnit_Framework_TestCase { function testReadPropertyParameterNewLines() { $data = "PROPNAME;PARAMNAME=paramvalue1\\nvalue2\\\\nvalue3:propValue"; - $result = Sabre_VObject_Reader::read($data); + $result = Reader::read($data); - $this->assertInstanceOf('Sabre_VObject_Property', $result); + $this->assertInstanceOf('Sabre\\VObject\\Property', $result); $this->assertEquals('PROPNAME', $result->name); $this->assertEquals('propValue', $result->value); @@ -249,9 +251,9 @@ class Sabre_VObject_ReaderTest extends PHPUnit_Framework_TestCase { function testReadPropertyParameterQuotedColon() { $data = "PROPNAME;PARAMNAME=\"param:value\":propValue"; - $result = Sabre_VObject_Reader::read($data); + $result = Reader::read($data); - $this->assertInstanceOf('Sabre_VObject_Property', $result); + $this->assertInstanceOf('Sabre\\VObject\\Property', $result); $this->assertEquals('PROPNAME', $result->name); $this->assertEquals('propValue', $result->value); $this->assertEquals(1, count($result->parameters)); diff --git a/dav/SabreDAV/tests/Sabre/VObject/RecurrenceIteratorFifthTuesdayProblemTest.php b/dav/sabre-vobject/tests/Sabre/VObject/RecurrenceIteratorFifthTuesdayProblemTest.php similarity index 75% rename from dav/SabreDAV/tests/Sabre/VObject/RecurrenceIteratorFifthTuesdayProblemTest.php rename to dav/sabre-vobject/tests/Sabre/VObject/RecurrenceIteratorFifthTuesdayProblemTest.php index 75972c2a0..ffcb6ee71 100644 --- a/dav/SabreDAV/tests/Sabre/VObject/RecurrenceIteratorFifthTuesdayProblemTest.php +++ b/dav/sabre-vobject/tests/Sabre/VObject/RecurrenceIteratorFifthTuesdayProblemTest.php @@ -1,6 +1,8 @@ VEVENT->UID); + $vObject = Reader::read($ics); + $it = new RecurrenceIterator($vObject, (string)$vObject->VEVENT->UID); while($it->valid()) { $it->next(); diff --git a/dav/SabreDAV/tests/Sabre/VObject/RecurrenceIteratorInfiniteLoopProblemTest.php b/dav/sabre-vobject/tests/Sabre/VObject/RecurrenceIteratorInfiniteLoopProblemTest.php similarity index 83% rename from dav/SabreDAV/tests/Sabre/VObject/RecurrenceIteratorInfiniteLoopProblemTest.php rename to dav/sabre-vobject/tests/Sabre/VObject/RecurrenceIteratorInfiniteLoopProblemTest.php index 150625095..3976388be 100644 --- a/dav/SabreDAV/tests/Sabre/VObject/RecurrenceIteratorInfiniteLoopProblemTest.php +++ b/dav/sabre-vobject/tests/Sabre/VObject/RecurrenceIteratorInfiniteLoopProblemTest.php @@ -1,6 +1,11 @@ DTSTART = '20090420T180000Z'; $ev->RRULE = 'FREQ=WEEKLY;BYDAY=MO;UNTIL=20090704T205959Z;INTERVAL=1'; @@ -21,7 +26,7 @@ class Sabre_VObject_RecurrenceIteratorInfiniteLoopProblemTest extends PHPUnit_Fr */ function testYearlyByMonthLoop() { - $ev = Sabre_VObject_Component::create('VEVENT'); + $ev = Component::create('VEVENT'); $ev->UID = 'uuid'; $ev->DTSTART = '20120101T154500'; $ev->DTSTART['TZID'] = 'Europe/Berlin'; @@ -35,10 +40,10 @@ class Sabre_VObject_RecurrenceIteratorInfiniteLoopProblemTest extends PHPUnit_Fr // The BYDAY part expands this to every day of the month, but the // BYSETPOS limits this to only the 1st day of the month. Very crazy // way to specify this, and could have certainly been a lot easier. - $cal = Sabre_VObject_Component::create('VCALENDAR'); + $cal = Component::create('VCALENDAR'); $cal->add($ev); - $it = new Sabre_VObject_RecurrenceIterator($cal,'uuid'); + $it = new RecurrenceIterator($cal,'uuid'); $it->fastForward(new DateTime('2012-01-29 23:00:00', new DateTimeZone('UTC'))); $collect = array(); diff --git a/dav/SabreDAV/tests/Sabre/VObject/RecurrenceIteratorTest.php b/dav/sabre-vobject/tests/Sabre/VObject/RecurrenceIteratorTest.php similarity index 75% rename from dav/SabreDAV/tests/Sabre/VObject/RecurrenceIteratorTest.php rename to dav/sabre-vobject/tests/Sabre/VObject/RecurrenceIteratorTest.php index 0bb42bb87..c79ac689c 100644 --- a/dav/SabreDAV/tests/Sabre/VObject/RecurrenceIteratorTest.php +++ b/dav/sabre-vobject/tests/Sabre/VObject/RecurrenceIteratorTest.php @@ -1,21 +1,26 @@ UID = 'bla'; $ev->RRULE = 'FREQ=DAILY;BYHOUR=10;BYMINUTE=5;BYSECOND=16;BYWEEKNO=32;BYYEARDAY=100,200'; - $dtStart = new Sabre_VObject_Property_DateTime('DTSTART'); - $dtStart->setDateTime(new DateTime('2011-10-07'),Sabre_VObject_Property_DateTime::UTC); + $dtStart = new Property\DateTime('DTSTART'); + $dtStart->setDateTime(new DateTime('2011-10-07'),Property\DateTime::UTC); $ev->add($dtStart); - $vcal = Sabre_VObject_Component::create('VCALENDAR'); + $vcal = Component::create('VCALENDAR'); $vcal->add($ev); - $it = new Sabre_VObject_RecurrenceIterator($vcal,(string)$ev->uid); + $it = new RecurrenceIterator($vcal,(string)$ev->uid); $this->assertEquals(array(10), $it->byHour); $this->assertEquals(array(5), $it->byMinute); @@ -31,17 +36,17 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase { */ function testInvalidFreq() { - $ev = new Sabre_VObject_Component('VEVENT'); + $ev = new Component('VEVENT'); $ev->RRULE = 'FREQ=SMONTHLY;INTERVAL=3;UNTIL=20111025T000000Z'; - $dtStart = new Sabre_VObject_Property_DateTime('DTSTART'); - $dtStart->setDateTime(new DateTime('2011-10-07'),Sabre_VObject_Property_DateTime::UTC); + $dtStart = new Property\DateTime('DTSTART'); + $dtStart->setDateTime(new DateTime('2011-10-07'),Property\DateTime::UTC); $ev->add($dtStart); - $vcal = Sabre_VObject_Component::create('VCALENDAR'); + $vcal = Component::create('VCALENDAR'); $vcal->add($ev); - $it = new Sabre_VObject_RecurrenceIterator($vcal,(string)$ev->uid); + $it = new RecurrenceIterator($vcal,(string)$ev->uid); } @@ -50,8 +55,8 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase { */ function testVCalendarNoUID() { - $vcal = new Sabre_VObject_Component('VCALENDAR'); - $it = new Sabre_VObject_RecurrenceIterator($vcal); + $vcal = new Component('VCALENDAR'); + $it = new RecurrenceIterator($vcal); } @@ -60,8 +65,8 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase { */ function testVCalendarInvalidUID() { - $vcal = new Sabre_VObject_Component('VCALENDAR'); - $it = new Sabre_VObject_RecurrenceIterator($vcal,'foo'); + $vcal = new Component('VCALENDAR'); + $it = new RecurrenceIterator($vcal,'foo'); } @@ -70,18 +75,18 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase { */ function testDaily() { - $ev = new Sabre_VObject_Component('VEVENT'); + $ev = new Component('VEVENT'); $ev->UID = 'bla'; $ev->RRULE = 'FREQ=DAILY;INTERVAL=3;UNTIL=20111025T000000Z'; - $dtStart = new Sabre_VObject_Property_DateTime('DTSTART'); - $dtStart->setDateTime(new DateTime('2011-10-07'),Sabre_VObject_Property_DateTime::UTC); + $dtStart = new Property\DateTime('DTSTART'); + $dtStart->setDateTime(new DateTime('2011-10-07', new DateTimeZone('UTC')),Property\DateTime::UTC); $ev->add($dtStart); - $vcal = Sabre_VObject_Component::create('VCALENDAR'); + $vcal = Component::create('VCALENDAR'); $vcal->add($ev); - $it = new Sabre_VObject_RecurrenceIterator($vcal,$ev->uid); + $it = new RecurrenceIterator($vcal,$ev->uid); $this->assertEquals('daily', $it->frequency); $this->assertEquals(3, $it->interval); @@ -121,17 +126,17 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase { */ function testNoRRULE() { - $ev = new Sabre_VObject_Component('VEVENT'); + $ev = new Component('VEVENT'); $ev->UID = 'bla'; - $dtStart = new Sabre_VObject_Property_DateTime('DTSTART'); - $dtStart->setDateTime(new DateTime('2011-10-07'),Sabre_VObject_Property_DateTime::UTC); + $dtStart = new Property\DateTime('DTSTART'); + $dtStart->setDateTime(new DateTime('2011-10-07', new DateTimeZone('UTC')),Property\DateTime::UTC); $ev->add($dtStart); - $vcal = Sabre_VObject_Component::create('VCALENDAR'); + $vcal = Component::create('VCALENDAR'); $vcal->add($ev); - $it = new Sabre_VObject_RecurrenceIterator($vcal,$ev->uid); + $it = new RecurrenceIterator($vcal,$ev->uid); $this->assertEquals('daily', $it->frequency); $this->assertEquals(1, $it->interval); @@ -164,18 +169,18 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase { */ function testDailyByDay() { - $ev = new Sabre_VObject_Component('VEVENT'); + $ev = new Component('VEVENT'); $ev->UID = 'bla'; $ev->RRULE = 'FREQ=DAILY;INTERVAL=2;BYDAY=TU,WE,FR'; - $dtStart = new Sabre_VObject_Property_DateTime('DTSTART'); - $dtStart->setDateTime(new DateTime('2011-10-07'),Sabre_VObject_Property_DateTime::UTC); + $dtStart = new Property\DateTime('DTSTART'); + $dtStart->setDateTime(new DateTime('2011-10-07', new DateTimeZone('UTC')),Property\DateTime::UTC); $ev->add($dtStart); - $vcal = Sabre_VObject_Component::create('VCALENDAR'); + $vcal = Component::create('VCALENDAR'); $vcal->add($ev); - $it = new Sabre_VObject_RecurrenceIterator($vcal,(string)$ev->uid); + $it = new RecurrenceIterator($vcal,(string)$ev->uid); $this->assertEquals('daily', $it->frequency); $this->assertEquals(2, $it->interval); @@ -220,18 +225,18 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase { */ function testWeekly() { - $ev = new Sabre_VObject_Component('VEVENT'); + $ev = new Component('VEVENT'); $ev->UID = 'bla'; $ev->RRULE = 'FREQ=WEEKLY;INTERVAL=2;COUNT=10'; - $dtStart = new Sabre_VObject_Property_DateTime('DTSTART'); - $dtStart->setDateTime(new DateTime('2011-10-07'),Sabre_VObject_Property_DateTime::UTC); + $dtStart = new Property\DateTime('DTSTART'); + $dtStart->setDateTime(new DateTime('2011-10-07', new DateTimeZone('UTC')),Property\DateTime::UTC); $ev->add($dtStart); - $vcal = Sabre_VObject_Component::create('VCALENDAR'); + $vcal = Component::create('VCALENDAR'); $vcal->add($ev); - $it = new Sabre_VObject_RecurrenceIterator($vcal,(string)$ev->uid); + $it = new RecurrenceIterator($vcal,(string)$ev->uid); $this->assertEquals('weekly', $it->frequency); $this->assertEquals(2, $it->interval); @@ -274,18 +279,18 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase { */ function testWeeklyByDay() { - $ev = new Sabre_VObject_Component('VEVENT'); + $ev = new Component('VEVENT'); $ev->UID = 'bla'; $ev->RRULE = 'FREQ=WEEKLY;INTERVAL=2;BYDAY=TU,WE,FR;WKST=SU'; - $dtStart = new Sabre_VObject_Property_DateTime('DTSTART'); - $dtStart->setDateTime(new DateTime('2011-10-07'),Sabre_VObject_Property_DateTime::UTC); + $dtStart = new Property\DateTime('DTSTART'); + $dtStart->setDateTime(new DateTime('2011-10-07', new DateTimeZone('UTC')),Property\DateTime::UTC); $ev->add($dtStart); - $vcal = Sabre_VObject_Component::create('VCALENDAR'); + $vcal = Component::create('VCALENDAR'); $vcal->add($ev); - $it = new Sabre_VObject_RecurrenceIterator($vcal,(string)$ev->uid); + $it = new RecurrenceIterator($vcal,(string)$ev->uid); $this->assertEquals('weekly', $it->frequency); $this->assertEquals(2, $it->interval); @@ -331,18 +336,18 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase { */ function testMonthly() { - $ev = new Sabre_VObject_Component('VEVENT'); + $ev = new Component('VEVENT'); $ev->UID = 'bla'; $ev->RRULE = 'FREQ=MONTHLY;INTERVAL=3;COUNT=5'; - $dtStart = new Sabre_VObject_Property_DateTime('DTSTART'); - $dtStart->setDateTime(new DateTime('2011-12-05'),Sabre_VObject_Property_DateTime::UTC); + $dtStart = new Property\DateTime('DTSTART'); + $dtStart->setDateTime(new DateTime('2011-12-05', new DateTimeZone('UTC')),Property\DateTime::UTC); $ev->add($dtStart); - $vcal = Sabre_VObject_Component::create('VCALENDAR'); + $vcal = Component::create('VCALENDAR'); $vcal->add($ev); - $it = new Sabre_VObject_RecurrenceIterator($vcal,(string)$ev->uid); + $it = new RecurrenceIterator($vcal,(string)$ev->uid); $this->assertEquals('monthly', $it->frequency); $this->assertEquals(3, $it->interval); @@ -380,18 +385,18 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase { */ function testMonthlyEndOfMonth() { - $ev = new Sabre_VObject_Component('VEVENT'); + $ev = new Component('VEVENT'); $ev->UID = 'bla'; $ev->RRULE = 'FREQ=MONTHLY;INTERVAL=2;COUNT=12'; - $dtStart = new Sabre_VObject_Property_DateTime('DTSTART'); - $dtStart->setDateTime(new DateTime('2011-12-31'),Sabre_VObject_Property_DateTime::UTC); + $dtStart = new Property\DateTime('DTSTART'); + $dtStart->setDateTime(new DateTime('2011-12-31', new DateTimeZone('UTC')),Property\DateTime::UTC); $ev->add($dtStart); - $vcal = Sabre_VObject_Component::create('VCALENDAR'); + $vcal = Component::create('VCALENDAR'); $vcal->add($ev); - $it = new Sabre_VObject_RecurrenceIterator($vcal,(string)$ev->uid); + $it = new RecurrenceIterator($vcal,(string)$ev->uid); $this->assertEquals('monthly', $it->frequency); $this->assertEquals(2, $it->interval); @@ -436,18 +441,18 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase { */ function testMonthlyByMonthDay() { - $ev = new Sabre_VObject_Component('VEVENT'); + $ev = new Component('VEVENT'); $ev->UID = 'bla'; $ev->RRULE = 'FREQ=MONTHLY;INTERVAL=5;COUNT=9;BYMONTHDAY=1,31,-7'; - $dtStart = new Sabre_VObject_Property_DateTime('DTSTART'); - $dtStart->setDateTime(new DateTime('2011-01-01'),Sabre_VObject_Property_DateTime::UTC); + $dtStart = new Property\DateTime('DTSTART'); + $dtStart->setDateTime(new DateTime('2011-01-01', new DateTimeZone('UTC')),Property\DateTime::UTC); $ev->add($dtStart); - $vcal = Sabre_VObject_Component::create('VCALENDAR'); + $vcal = Component::create('VCALENDAR'); $vcal->add($ev); - $it = new Sabre_VObject_RecurrenceIterator($vcal,(string)$ev->uid); + $it = new RecurrenceIterator($vcal,(string)$ev->uid); $this->assertEquals('monthly', $it->frequency); $this->assertEquals(5, $it->interval); @@ -489,18 +494,18 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase { */ function testMonthlyByDay() { - $ev = new Sabre_VObject_Component('VEVENT'); + $ev = new Component('VEVENT'); $ev->UID = 'bla'; $ev->RRULE = 'FREQ=MONTHLY;INTERVAL=2;COUNT=16;BYDAY=MO,-2TU,+1WE,3TH'; - $dtStart = new Sabre_VObject_Property_DateTime('DTSTART'); - $dtStart->setDateTime(new DateTime('2011-01-03'),Sabre_VObject_Property_DateTime::UTC); + $dtStart = new Property\DateTime('DTSTART'); + $dtStart->setDateTime(new DateTime('2011-01-03', new DateTimeZone('UTC')),Property\DateTime::UTC); $ev->add($dtStart); - $vcal = Sabre_VObject_Component::create('VCALENDAR'); + $vcal = Component::create('VCALENDAR'); $vcal->add($ev); - $it = new Sabre_VObject_RecurrenceIterator($vcal,(string)$ev->uid); + $it = new RecurrenceIterator($vcal,(string)$ev->uid); $this->assertEquals('monthly', $it->frequency); $this->assertEquals(2, $it->interval); @@ -549,18 +554,18 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase { */ function testMonthlyByDayByMonthDay() { - $ev = new Sabre_VObject_Component('VEVENT'); + $ev = new Component('VEVENT'); $ev->UID = 'bla'; $ev->RRULE = 'FREQ=MONTHLY;COUNT=10;BYDAY=MO;BYMONTHDAY=1'; - $dtStart = new Sabre_VObject_Property_DateTime('DTSTART'); - $dtStart->setDateTime(new DateTime('2011-08-01'),Sabre_VObject_Property_DateTime::UTC); + $dtStart = new Property\DateTime('DTSTART'); + $dtStart->setDateTime(new DateTime('2011-08-01', new DateTimeZone('UTC')),Property\DateTime::UTC); $ev->add($dtStart); - $vcal = Sabre_VObject_Component::create('VCALENDAR'); + $vcal = Component::create('VCALENDAR'); $vcal->add($ev); - $it = new Sabre_VObject_RecurrenceIterator($vcal,(string)$ev->uid); + $it = new RecurrenceIterator($vcal,(string)$ev->uid); $this->assertEquals('monthly', $it->frequency); $this->assertEquals(1, $it->interval); @@ -604,18 +609,18 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase { */ function testMonthlyByDayBySetPos() { - $ev = new Sabre_VObject_Component('VEVENT'); + $ev = new Component('VEVENT'); $ev->UID = 'bla'; $ev->RRULE = 'FREQ=MONTHLY;COUNT=10;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=1,-1'; - $dtStart = new Sabre_VObject_Property_DateTime('DTSTART'); - $dtStart->setDateTime(new DateTime('2011-01-03'),Sabre_VObject_Property_DateTime::UTC); + $dtStart = new Property\DateTime('DTSTART'); + $dtStart->setDateTime(new DateTime('2011-01-03', new DateTimeZone('UTC')),Property\DateTime::UTC); $ev->add($dtStart); - $vcal = Sabre_VObject_Component::create('VCALENDAR'); + $vcal = Component::create('VCALENDAR'); $vcal->add($ev); - $it = new Sabre_VObject_RecurrenceIterator($vcal,(string)$ev->uid); + $it = new RecurrenceIterator($vcal,(string)$ev->uid); $this->assertEquals('monthly', $it->frequency); $this->assertEquals(1, $it->interval); @@ -659,18 +664,18 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase { */ function testYearly() { - $ev = new Sabre_VObject_Component('VEVENT'); + $ev = new Component('VEVENT'); $ev->UID = 'bla'; $ev->RRULE = 'FREQ=YEARLY;COUNT=10;INTERVAL=3'; - $dtStart = new Sabre_VObject_Property_DateTime('DTSTART'); - $dtStart->setDateTime(new DateTime('2011-01-01'),Sabre_VObject_Property_DateTime::UTC); + $dtStart = new Property\DateTime('DTSTART'); + $dtStart->setDateTime(new DateTime('2011-01-01', new DateTimeZone('UTC')),Property\DateTime::UTC); $ev->add($dtStart); - $vcal = Sabre_VObject_Component::create('VCALENDAR'); + $vcal = Component::create('VCALENDAR'); $vcal->add($ev); - $it = new Sabre_VObject_RecurrenceIterator($vcal,(string)$ev->uid); + $it = new RecurrenceIterator($vcal,(string)$ev->uid); $this->assertEquals('yearly', $it->frequency); $this->assertEquals(3, $it->interval); @@ -712,18 +717,18 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase { */ function testYearlyLeapYear() { - $ev = new Sabre_VObject_Component('VEVENT'); + $ev = new Component('VEVENT'); $ev->UID = 'bla'; $ev->RRULE = 'FREQ=YEARLY;COUNT=3'; - $dtStart = new Sabre_VObject_Property_DateTime('DTSTART'); - $dtStart->setDateTime(new DateTime('2012-02-29'),Sabre_VObject_Property_DateTime::UTC); + $dtStart = new Property\DateTime('DTSTART'); + $dtStart->setDateTime(new DateTime('2012-02-29', new DateTimeZone('UTC')),Property\DateTime::UTC); $ev->add($dtStart); - $vcal = Sabre_VObject_Component::create('VCALENDAR'); + $vcal = Component::create('VCALENDAR'); $vcal->add($ev); - $it = new Sabre_VObject_RecurrenceIterator($vcal,(string)$ev->uid); + $it = new RecurrenceIterator($vcal,(string)$ev->uid); $this->assertEquals('yearly', $it->frequency); $this->assertEquals(3, $it->count); @@ -757,18 +762,18 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase { */ function testYearlyByMonth() { - $ev = new Sabre_VObject_Component('VEVENT'); + $ev = new Component('VEVENT'); $ev->UID = 'bla'; $ev->RRULE = 'FREQ=YEARLY;COUNT=8;INTERVAL=4;BYMONTH=4,10'; - $dtStart = new Sabre_VObject_Property_DateTime('DTSTART'); - $dtStart->setDateTime(new DateTime('2011-04-07'),Sabre_VObject_Property_DateTime::UTC); + $dtStart = new Property\DateTime('DTSTART'); + $dtStart->setDateTime(new DateTime('2011-04-07', new DateTimeZone('UTC')),Property\DateTime::UTC); $ev->add($dtStart); - $vcal = Sabre_VObject_Component::create('VCALENDAR'); + $vcal = Component::create('VCALENDAR'); $vcal->add($ev); - $it = new Sabre_VObject_RecurrenceIterator($vcal,(string)$ev->uid); + $it = new RecurrenceIterator($vcal,(string)$ev->uid); $this->assertEquals('yearly', $it->frequency); $this->assertEquals(4, $it->interval); @@ -809,18 +814,18 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase { */ function testYearlyByMonthByDay() { - $ev = new Sabre_VObject_Component('VEVENT'); + $ev = new Component('VEVENT'); $ev->UID = 'bla'; $ev->RRULE = 'FREQ=YEARLY;COUNT=8;INTERVAL=5;BYMONTH=4,10;BYDAY=1MO,-1SU'; - $dtStart = new Sabre_VObject_Property_DateTime('DTSTART'); - $dtStart->setDateTime(new DateTime('2011-04-04'),Sabre_VObject_Property_DateTime::UTC); + $dtStart = new Property\DateTime('DTSTART'); + $dtStart->setDateTime(new DateTime('2011-04-04', new DateTimeZone('UTC')),Property\DateTime::UTC); $ev->add($dtStart); - $vcal = Sabre_VObject_Component::create('VCALENDAR'); + $vcal = Component::create('VCALENDAR'); $vcal->add($ev); - $it = new Sabre_VObject_RecurrenceIterator($vcal,(string)$ev->uid); + $it = new RecurrenceIterator($vcal,(string)$ev->uid); $this->assertEquals('yearly', $it->frequency); $this->assertEquals(5, $it->interval); @@ -862,22 +867,22 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase { */ function testFastForward() { - $ev = new Sabre_VObject_Component('VEVENT'); + $ev = new Component('VEVENT'); $ev->UID = 'bla'; $ev->RRULE = 'FREQ=YEARLY;COUNT=8;INTERVAL=5;BYMONTH=4,10;BYDAY=1MO,-1SU'; - $dtStart = new Sabre_VObject_Property_DateTime('DTSTART'); - $dtStart->setDateTime(new DateTime('2011-04-04'),Sabre_VObject_Property_DateTime::UTC); + $dtStart = new Property\DateTime('DTSTART'); + $dtStart->setDateTime(new DateTime('2011-04-04', new DateTimeZone('UTC')),Property\DateTime::UTC); $ev->add($dtStart); - $vcal = Sabre_VObject_Component::create('VCALENDAR'); + $vcal = Component::create('VCALENDAR'); $vcal->add($ev); - $it = new Sabre_VObject_RecurrenceIterator($vcal,(string)$ev->uid); + $it = new RecurrenceIterator($vcal,(string)$ev->uid); // The idea is that we're fast-forwarding too far in the future, so // there will be no results left. - $it->fastForward(new DateTime('2020-05-05')); + $it->fastForward(new DateTime('2020-05-05', new DateTimeZone('UTC'))); $max = 20; $result = array(); @@ -901,27 +906,27 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase { */ function testComplexExclusions() { - $ev = new Sabre_VObject_Component('VEVENT'); + $ev = new Component('VEVENT'); $ev->UID = 'bla'; $ev->RRULE = 'FREQ=YEARLY;COUNT=10'; - $dtStart = new Sabre_VObject_Property_DateTime('DTSTART'); + $dtStart = new Property\DateTime('DTSTART'); $tz = new DateTimeZone('Canada/Eastern'); - $dtStart->setDateTime(new DateTime('2011-01-01 13:50:20', $tz),Sabre_VObject_Property_DateTime::LOCALTZ); + $dtStart->setDateTime(new DateTime('2011-01-01 13:50:20', $tz),Property\DateTime::LOCALTZ); - $exDate1 = new Sabre_VObject_Property_MultiDateTime('EXDATE'); - $exDate1->setDateTimes(array(new DateTime('2012-01-01 13:50:20', $tz), new DateTime('2014-01-01 13:50:20', $tz)), Sabre_VObject_Property_DateTime::LOCALTZ); - $exDate2 = new Sabre_VObject_Property_MultiDateTime('EXDATE'); - $exDate2->setDateTimes(array(new DateTime('2016-01-01 13:50:20', $tz)), Sabre_VObject_Property_DateTime::LOCALTZ); + $exDate1 = new Property\MultiDateTime('EXDATE'); + $exDate1->setDateTimes(array(new DateTime('2012-01-01 13:50:20', $tz), new DateTime('2014-01-01 13:50:20', $tz)), Property\DateTime::LOCALTZ); + $exDate2 = new Property\MultiDateTime('EXDATE'); + $exDate2->setDateTimes(array(new DateTime('2016-01-01 13:50:20', $tz)), Property\DateTime::LOCALTZ); $ev->add($dtStart); $ev->add($exDate1); $ev->add($exDate2); - $vcal = Sabre_VObject_Component::create('VCALENDAR'); + $vcal = Component::create('VCALENDAR'); $vcal->add($ev); - $it = new Sabre_VObject_RecurrenceIterator($vcal,(string)$ev->uid); + $it = new RecurrenceIterator($vcal,(string)$ev->uid); $this->assertEquals('yearly', $it->frequency); $this->assertEquals(1, $it->interval); @@ -958,9 +963,9 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase { */ function testOverridenEvent() { - $vcal = Sabre_VObject_Component::create('VCALENDAR'); + $vcal = Component::create('VCALENDAR'); - $ev1 = Sabre_VObject_Component::create('VEVENT'); + $ev1 = Component::create('VEVENT'); $ev1->UID = 'overridden'; $ev1->RRULE = 'FREQ=DAILY;COUNT=10'; $ev1->DTSTART = '20120107T120000Z'; @@ -969,7 +974,7 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase { $vcal->add($ev1); // ev2 overrides an event, and puts it on 2pm instead. - $ev2 = Sabre_VObject_Component::create('VEVENT'); + $ev2 = Component::create('VEVENT'); $ev2->UID = 'overridden'; $ev2->{'RECURRENCE-ID'} = '20120110T120000Z'; $ev2->DTSTART = '20120110T140000Z'; @@ -978,7 +983,7 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase { $vcal->add($ev2); // ev3 overrides an event, and puts it 2 days and 2 hours later - $ev3 = Sabre_VObject_Component::create('VEVENT'); + $ev3 = Component::create('VEVENT'); $ev3->UID = 'overridden'; $ev3->{'RECURRENCE-ID'} = '20120113T120000Z'; $ev3->DTSTART = '20120115T140000Z'; @@ -986,7 +991,7 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase { $vcal->add($ev3); - $it = new Sabre_VObject_RecurrenceIterator($vcal,'overridden'); + $it = new RecurrenceIterator($vcal,'overridden'); $dates = array(); $summaries = array(); @@ -1032,9 +1037,9 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase { */ function testOverridenEvent2() { - $vcal = Sabre_VObject_Component::create('VCALENDAR'); + $vcal = Component::create('VCALENDAR'); - $ev1 = Sabre_VObject_Component::create('VEVENT'); + $ev1 = Component::create('VEVENT'); $ev1->UID = 'overridden'; $ev1->RRULE = 'FREQ=WEEKLY;COUNT=3'; $ev1->DTSTART = '20120112T120000Z'; @@ -1043,7 +1048,7 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase { $vcal->add($ev1); // ev2 overrides an event, and puts it 6 days earlier instead. - $ev2 = Sabre_VObject_Component::create('VEVENT'); + $ev2 = Component::create('VEVENT'); $ev2->UID = 'overridden'; $ev2->{'RECURRENCE-ID'} = '20120119T120000Z'; $ev2->DTSTART = '20120113T120000Z'; @@ -1051,7 +1056,7 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase { $vcal->add($ev2); - $it = new Sabre_VObject_RecurrenceIterator($vcal,'overridden'); + $it = new RecurrenceIterator($vcal,'overridden'); $dates = array(); $summaries = array(); @@ -1084,9 +1089,9 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase { */ function testOverridenEventNoValuesExpected() { - $vcal = Sabre_VObject_Component::create('VCALENDAR'); + $vcal = Component::create('VCALENDAR'); - $ev1 = Sabre_VObject_Component::create('VEVENT'); + $ev1 = Component::create('VEVENT'); $ev1->UID = 'overridden'; $ev1->RRULE = 'FREQ=WEEKLY;COUNT=3'; $ev1->DTSTART = '20120124T120000Z'; @@ -1095,7 +1100,7 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase { $vcal->add($ev1); // ev2 overrides an event, and puts it 6 days earlier instead. - $ev2 = Sabre_VObject_Component::create('VEVENT'); + $ev2 = Component::create('VEVENT'); $ev2->UID = 'overridden'; $ev2->{'RECURRENCE-ID'} = '20120131T120000Z'; $ev2->DTSTART = '20120125T120000Z'; @@ -1103,7 +1108,7 @@ class Sabre_VObject_RecurrenceIteratorTest extends PHPUnit_Framework_TestCase { $vcal->add($ev2); - $it = new Sabre_VObject_RecurrenceIterator($vcal,'overridden'); + $it = new RecurrenceIterator($vcal,'overridden'); $dates = array(); $summaries = array(); diff --git a/dav/SabreDAV/tests/Sabre/VObject/TimeZoneUtilTest.php b/dav/sabre-vobject/tests/Sabre/VObject/TimeZoneUtilTest.php similarity index 76% rename from dav/SabreDAV/tests/Sabre/VObject/TimeZoneUtilTest.php rename to dav/sabre-vobject/tests/Sabre/VObject/TimeZoneUtilTest.php index be8cd49c3..1f13ccbc3 100644 --- a/dav/SabreDAV/tests/Sabre/VObject/TimeZoneUtilTest.php +++ b/dav/sabre-vobject/tests/Sabre/VObject/TimeZoneUtilTest.php @@ -1,13 +1,15 @@ assertEquals(new DateTimeZone('Europe/Sarajevo'), $tz); + $this->assertEquals(new \DateTimeZone('Europe/Sarajevo'), $tz); } @@ -99,16 +101,16 @@ END:VEVENT END:VCALENDAR HI; - $tz = Sabre_VObject_TimeZoneUtil::getTimeZone('foo', Sabre_VObject_Reader::read($vobj)); + $tz = TimeZoneUtil::getTimeZone('foo', Reader::read($vobj)); - $this->assertEquals(new DateTimeZone(date_default_timezone_get()), $tz); + $this->assertEquals(new \DateTimeZone(date_default_timezone_get()), $tz); } function testWindowsTimeZone() { - $tz = Sabre_VObject_TimeZoneUtil::getTimeZone('Eastern Standard Time'); - $this->assertEquals(new DateTimeZone('America/New_York'), $tz); + $tz = TimeZoneUtil::getTimeZone('Eastern Standard Time'); + $this->assertEquals(new \DateTimeZone('America/New_York'), $tz); } @@ -144,9 +146,9 @@ UID:040000008200E00074C5B7101A82E0080000000010DA091DC31BCD01000000000000000 END:VEVENT END:VCALENDAR HI; - $tz = Sabre_VObject_TimeZoneUtil::getTimeZone('foo', Sabre_VObject_Reader::read($vobj)); + $tz = TimeZoneUtil::getTimeZone('foo', Reader::read($vobj)); - $this->assertEquals(new DateTimeZone(date_default_timezone_get()), $tz); + $this->assertEquals(new \DateTimeZone(date_default_timezone_get()), $tz); } diff --git a/dav/SabreDAV/tests/Sabre/VObject/VersionTest.php b/dav/sabre-vobject/tests/Sabre/VObject/VersionTest.php similarity index 53% rename from dav/SabreDAV/tests/Sabre/VObject/VersionTest.php rename to dav/sabre-vobject/tests/Sabre/VObject/VersionTest.php index ea2a4b284..ae6855e85 100644 --- a/dav/SabreDAV/tests/Sabre/VObject/VersionTest.php +++ b/dav/sabre-vobject/tests/Sabre/VObject/VersionTest.php @@ -1,13 +1,15 @@ assertEquals(-1, version_compare('0.9.0',$v)); - $s = Sabre_VObject_Version::STABILITY; + $s = Version::STABILITY; $this->assertTrue($s == 'alpha' || $s == 'beta' || $s =='stable'); } diff --git a/dav/SabreDAV/tests/Sabre/VObject/issue153.vcf b/dav/sabre-vobject/tests/Sabre/VObject/issue153.vcf similarity index 100% rename from dav/SabreDAV/tests/Sabre/VObject/issue153.vcf rename to dav/sabre-vobject/tests/Sabre/VObject/issue153.vcf diff --git a/dav/sabre-vobject/tests/bootstrap.php b/dav/sabre-vobject/tests/bootstrap.php new file mode 100644 index 000000000..ee071ea75 --- /dev/null +++ b/dav/sabre-vobject/tests/bootstrap.php @@ -0,0 +1,4 @@ + + + Sabre/ + + + + + ../lib/ + + +