[Pkg-owncloud-commits] [php-sabre-vobject] 52/106: Lots more passing tests.
David Prévot
taffit at moszumanska.debian.org
Fri Aug 22 15:11:01 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository php-sabre-vobject.
commit 5b233a39439ff67279f2680132ac05431ab31b02
Author: Evert Pot <me at evertpot.com>
Date: Sat Aug 2 02:46:56 2014 -0400
Lots more passing tests.
---
lib/Sabre/VObject/RecurrenceIterator.php | 58 ++++++++++--
.../RecurrenceIterator/InfiniteLoopProblemTest.php | 1 +
.../Sabre/VObject/RecurrenceIterator/MainTest.php | 101 ---------------------
3 files changed, 53 insertions(+), 107 deletions(-)
diff --git a/lib/Sabre/VObject/RecurrenceIterator.php b/lib/Sabre/VObject/RecurrenceIterator.php
index f3040de..43b8350 100644
--- a/lib/Sabre/VObject/RecurrenceIterator.php
+++ b/lib/Sabre/VObject/RecurrenceIterator.php
@@ -65,10 +65,24 @@ class RecurrenceIterator implements \Iterator {
*/
public function __construct(Component $vcal, $uid = null) {
- $uid = (string)$uid;
$rrule = null;
+ if ($vcal instanceof VEvent) {
+ // Single instance mode.
+ $uid = (string)$vcal->UID;
+ $events = array($vcal);
+ } else {
+ $uid = (string)$uid;
+ if (!$uid) {
+ throw new InvalidArgumentException('The UID argument is required when a VCALENDAR is passed to this constructor');
+ }
+ if (!isset($vcal->VEVENT)) {
+ throw new InvalidArgumentException('No events found in this calendar');
+ }
+ $events = $vcal->VEVENT;
- foreach($vcal->VEVENT as $vevent) {
+ }
+
+ foreach($events as $vevent) {
if (!isset($vevent->UID)) {
throw new InvalidArgumentException('An event MUST have a UID');
@@ -107,6 +121,18 @@ class RecurrenceIterator implements \Iterator {
}
$this->startDate = $this->masterEvent->DTSTART->getDateTime();
+ if (isset($this->masterEvent->EXDATE)) {
+
+ foreacH($this->masterEvent->EXDATE as $exDate) {
+
+ foreach($exDate->getDateTimes() as $dt) {
+ $this->exceptions[$dt->getTimeStamp()] = true;
+ }
+
+ }
+
+ }
+
if (isset($this->masterEvent->DTEND)) {
$this->eventDuration =
$this->masterEvent->DTEND->getDateTime()->getTimeStamp() -
@@ -125,7 +151,9 @@ class RecurrenceIterator implements \Iterator {
*/
public function current() {
- return clone $this->currentDate;
+ if ($this->currentDate) {
+ return clone $this->currentDate;
+ }
}
@@ -137,7 +165,9 @@ class RecurrenceIterator implements \Iterator {
*/
public function getDtStart() {
- return clone $this->currentDate;
+ if ($this->currentDate) {
+ return clone $this->currentDate;
+ }
}
@@ -149,6 +179,9 @@ class RecurrenceIterator implements \Iterator {
*/
public function getDtEnd() {
+ if (!$this->valid()) {
+ return null;
+ }
$end = clone $this->currentDate;
return $end->modify('+' . $this->eventDuration . ' seconds');
@@ -208,7 +241,7 @@ class RecurrenceIterator implements \Iterator {
*/
public function valid() {
- return $this->currentOverriddenEvent || $this->nextDate || $this->rruleParser->valid();
+ return !!$this->currentDate;
}
@@ -292,7 +325,20 @@ class RecurrenceIterator implements \Iterator {
*/
public function fastForward(DateTime $dateTime) {
- $this->rruleParser->fastForward($dateTime);
+ while($this->valid() && $this->currentDate < $dateTime ) {
+ $this->next();
+ }
+
+ }
+
+ /**
+ * Returns true if this recurring event never ends.
+ *
+ * @return bool
+ */
+ public function isInfinite() {
+
+ return $this->rruleParser->isInfinite();
}
diff --git a/tests/Sabre/VObject/RecurrenceIterator/InfiniteLoopProblemTest.php b/tests/Sabre/VObject/RecurrenceIterator/InfiniteLoopProblemTest.php
index 46b3c15..941ac9f 100644
--- a/tests/Sabre/VObject/RecurrenceIterator/InfiniteLoopProblemTest.php
+++ b/tests/Sabre/VObject/RecurrenceIterator/InfiniteLoopProblemTest.php
@@ -22,6 +22,7 @@ class RecurrenceIteratorInfiniteLoopProblemTest extends \PHPUnit_Framework_TestC
function testFastForwardTooFar() {
$ev = $this->vcal->createComponent('VEVENT');
+ $ev->UID = 'foobar';
$ev->DTSTART = '20090420T180000Z';
$ev->RRULE = 'FREQ=WEEKLY;BYDAY=MO;UNTIL=20090704T205959Z;INTERVAL=1';
diff --git a/tests/Sabre/VObject/RecurrenceIterator/MainTest.php b/tests/Sabre/VObject/RecurrenceIterator/MainTest.php
index 7099cb1..9669a2e 100644
--- a/tests/Sabre/VObject/RecurrenceIterator/MainTest.php
+++ b/tests/Sabre/VObject/RecurrenceIterator/MainTest.php
@@ -25,11 +25,6 @@ class RecurrenceIteratorTest extends \PHPUnit_Framework_TestCase {
$it = new RecurrenceIterator($vcal,(string)$ev->uid);
$this->assertTrue($it->isInfinite());
- $this->assertEquals(array(10), $it->byHour);
- $this->assertEquals(array(5), $it->byMinute);
- $this->assertEquals(array(16), $it->bySecond);
- $this->assertEquals(array(32), $it->byWeekNo);
- $this->assertEquals(array(100,200), $it->byYearDay);
}
@@ -91,10 +86,6 @@ class RecurrenceIteratorTest extends \PHPUnit_Framework_TestCase {
$it = new RecurrenceIterator($vcal,$ev->uid);
- $this->assertEquals('hourly', $it->frequency);
- $this->assertEquals(3, $it->interval);
- $this->assertEquals(new DateTime('2011-10-25', new DateTimeZone('UTC')), $it->until);
-
// Max is to prevent overflow
$max = 12;
$result = array();
@@ -148,10 +139,6 @@ class RecurrenceIteratorTest extends \PHPUnit_Framework_TestCase {
$it = new RecurrenceIterator($vcal,$ev->uid);
- $this->assertEquals('daily', $it->frequency);
- $this->assertEquals(3, $it->interval);
- $this->assertEquals(new DateTime('2011-10-25', new DateTimeZone('UTC')), $it->until);
-
// Max is to prevent overflow
$max = 12;
$result = array();
@@ -199,9 +186,6 @@ class RecurrenceIteratorTest extends \PHPUnit_Framework_TestCase {
$it = new RecurrenceIterator($vcal,$ev->uid);
- $this->assertEquals('daily', $it->frequency);
- $this->assertEquals(1, $it->interval);
-
// Max is to prevent overflow
$max = 12;
$result = array();
@@ -244,11 +228,6 @@ class RecurrenceIteratorTest extends \PHPUnit_Framework_TestCase {
$it = new RecurrenceIterator($vcal,(string)$ev->uid);
- $this->assertEquals('daily', $it->frequency);
- $this->assertEquals(1, $it->interval);
- $this->assertEquals(array('6','7'), $it->byHour);
- $this->assertEquals(array('SA','SU'), $it->byDay);
-
// Grabbing the next 12 items
$max = 12;
$result = array();
@@ -302,10 +281,6 @@ class RecurrenceIteratorTest extends \PHPUnit_Framework_TestCase {
$it = new RecurrenceIterator($vcal,(string)$ev->uid);
- $this->assertEquals('daily', $it->frequency);
- $this->assertEquals(2, $it->interval);
- $this->assertEquals(array('10','11','12','13','14','15'), $it->byHour);
-
// Grabbing the next 12 items
$max = 12;
$result = array();
@@ -359,10 +334,6 @@ class RecurrenceIteratorTest extends \PHPUnit_Framework_TestCase {
$it = new RecurrenceIterator($vcal,(string)$ev->uid);
- $this->assertEquals('daily', $it->frequency);
- $this->assertEquals(2, $it->interval);
- $this->assertEquals(array('TU','WE','FR'), $it->byDay);
-
// Grabbing the next 12 items
$max = 12;
$result = array();
@@ -416,10 +387,6 @@ class RecurrenceIteratorTest extends \PHPUnit_Framework_TestCase {
$it = new RecurrenceIterator($vcal,(string)$ev->uid);
- $this->assertEquals('weekly', $it->frequency);
- $this->assertEquals(2, $it->interval);
- $this->assertEquals(10, $it->count);
-
// Max is to prevent overflow
$max = 12;
$result = array();
@@ -471,12 +438,6 @@ class RecurrenceIteratorTest extends \PHPUnit_Framework_TestCase {
$it = new RecurrenceIterator($vcal,(string)$ev->uid);
- $this->assertEquals('weekly', $it->frequency);
- $this->assertEquals(2, $it->interval);
- $this->assertEquals(array('TU','WE','FR'), $it->byDay);
- $this->assertEquals(array('8','9','10'), $it->byHour);
- $this->assertEquals('MO', $it->weekStart);
-
// Grabbing the next 12 items
$max = 15;
$result = array();
@@ -533,11 +494,6 @@ class RecurrenceIteratorTest extends \PHPUnit_Framework_TestCase {
$it = new RecurrenceIterator($vcal,(string)$ev->uid);
- $this->assertEquals('weekly', $it->frequency);
- $this->assertEquals(2, $it->interval);
- $this->assertEquals(array('TU','WE','FR'), $it->byDay);
- $this->assertEquals('SU', $it->weekStart);
-
// Grabbing the next 12 items
$max = 12;
$result = array();
@@ -591,11 +547,6 @@ class RecurrenceIteratorTest extends \PHPUnit_Framework_TestCase {
$it = new RecurrenceIterator($vcal,(string)$ev->uid);
- $this->assertEquals('weekly', $it->frequency);
- $this->assertEquals(2, $it->interval);
- $this->assertEquals(array('TU','WE','FR'), $it->byDay);
- $this->assertEquals('SU', $it->weekStart);
-
// Grabbing the next 12 items
$max = 12;
$result = array();
@@ -649,10 +600,6 @@ class RecurrenceIteratorTest extends \PHPUnit_Framework_TestCase {
$it = new RecurrenceIterator($vcal,(string)$ev->uid);
- $this->assertEquals('monthly', $it->frequency);
- $this->assertEquals(3, $it->interval);
- $this->assertEquals(5, $it->count);
-
$max = 14;
$result = array();
foreach($it as $item) {
@@ -699,10 +646,6 @@ class RecurrenceIteratorTest extends \PHPUnit_Framework_TestCase {
$it = new RecurrenceIterator($vcal,(string)$ev->uid);
- $this->assertEquals('monthly', $it->frequency);
- $this->assertEquals(2, $it->interval);
- $this->assertEquals(12, $it->count);
-
$max = 14;
$result = array();
foreach($it as $item) {
@@ -756,11 +699,6 @@ class RecurrenceIteratorTest extends \PHPUnit_Framework_TestCase {
$it = new RecurrenceIterator($vcal,(string)$ev->uid);
- $this->assertEquals('monthly', $it->frequency);
- $this->assertEquals(5, $it->interval);
- $this->assertEquals(9, $it->count);
- $this->assertEquals(array(1, 31, -7), $it->byMonthDay);
-
$max = 14;
$result = array();
foreach($it as $item) {
@@ -814,11 +752,6 @@ class RecurrenceIteratorTest extends \PHPUnit_Framework_TestCase {
$it = new RecurrenceIterator($vcal,(string)$ev->uid);
- $this->assertEquals('monthly', $it->frequency);
- $this->assertEquals(2, $it->interval);
- $this->assertEquals(16, $it->count);
- $this->assertEquals(array('MO','-2TU','+1WE','3TH'), $it->byDay);
-
$max = 20;
$result = array();
foreach($it as $k=>$item) {
@@ -875,12 +808,6 @@ class RecurrenceIteratorTest extends \PHPUnit_Framework_TestCase {
$it = new RecurrenceIterator($vcal,(string)$ev->uid);
- $this->assertEquals('monthly', $it->frequency);
- $this->assertEquals(1, $it->interval);
- $this->assertEquals(10, $it->count);
- $this->assertEquals(array('MO'), $it->byDay);
- $this->assertEquals(array(1), $it->byMonthDay);
-
$max = 20;
$result = array();
foreach($it as $k=>$item) {
@@ -931,12 +858,6 @@ class RecurrenceIteratorTest extends \PHPUnit_Framework_TestCase {
$it = new RecurrenceIterator($vcal,(string)$ev->uid);
- $this->assertEquals('monthly', $it->frequency);
- $this->assertEquals(1, $it->interval);
- $this->assertEquals(10, $it->count);
- $this->assertEquals(array('MO','TU','WE','TH','FR'), $it->byDay);
- $this->assertEquals(array(1,-1), $it->bySetPos);
-
$max = 20;
$result = array();
foreach($it as $k=>$item) {
@@ -987,10 +908,6 @@ class RecurrenceIteratorTest extends \PHPUnit_Framework_TestCase {
$it = new RecurrenceIterator($vcal,(string)$ev->uid);
- $this->assertEquals('yearly', $it->frequency);
- $this->assertEquals(3, $it->interval);
- $this->assertEquals(10, $it->count);
-
$max = 20;
$result = array();
foreach($it as $k=>$item) {
@@ -1041,9 +958,6 @@ class RecurrenceIteratorTest extends \PHPUnit_Framework_TestCase {
$it = new RecurrenceIterator($vcal,(string)$ev->uid);
- $this->assertEquals('yearly', $it->frequency);
- $this->assertEquals(3, $it->count);
-
$max = 20;
$result = array();
foreach($it as $k=>$item) {
@@ -1087,11 +1001,6 @@ class RecurrenceIteratorTest extends \PHPUnit_Framework_TestCase {
$it = new RecurrenceIterator($vcal,(string)$ev->uid);
- $this->assertEquals('yearly', $it->frequency);
- $this->assertEquals(4, $it->interval);
- $this->assertEquals(8, $it->count);
- $this->assertEquals(array(4,10), $it->byMonth);
-
$max = 20;
$result = array();
foreach($it as $k=>$item) {
@@ -1140,12 +1049,6 @@ class RecurrenceIteratorTest extends \PHPUnit_Framework_TestCase {
$it = new RecurrenceIterator($vcal,(string)$ev->uid);
- $this->assertEquals('yearly', $it->frequency);
- $this->assertEquals(5, $it->interval);
- $this->assertEquals(8, $it->count);
- $this->assertEquals(array(4,10), $it->byMonth);
- $this->assertEquals(array('1MO','-1SU'), $it->byDay);
-
$max = 20;
$result = array();
foreach($it as $k=>$item) {
@@ -1243,10 +1146,6 @@ class RecurrenceIteratorTest extends \PHPUnit_Framework_TestCase {
$it = new RecurrenceIterator($vcal,(string)$ev->uid);
- $this->assertEquals('yearly', $it->frequency);
- $this->assertEquals(1, $it->interval);
- $this->assertEquals(10, $it->count);
-
$max = 20;
$result = array();
foreach($it as $k=>$item) {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabre-vobject.git
More information about the Pkg-owncloud-commits
mailing list