[Pkg-owncloud-commits] [php-sabre-vobject] 68/106: Fixed unittests.

David Prévot taffit at moszumanska.debian.org
Fri Aug 22 15:11:05 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 4b6c2bb79ccbf30bf7d3304c8eba54052e6e59fa
Author: Evert Pot <evert at rooftopsolutions.nl>
Date:   Thu Aug 7 01:34:33 2014 -0400

    Fixed unittests.
---
 lib/Recur/RDateIterator.php                                   | 11 +++++++----
 lib/Recur/RRuleIterator.php                                   |  1 +
 .../Recur/{RRuleIterator.php => RRuleIteratorTest.php}        |  4 ++--
 tests/phpunit.xml                                             |  2 +-
 4 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/lib/Recur/RDateIterator.php b/lib/Recur/RDateIterator.php
index 4462bf7..3e16481 100644
--- a/lib/Recur/RDateIterator.php
+++ b/lib/Recur/RDateIterator.php
@@ -58,14 +58,14 @@ class RDateIterator implements Iterator {
     }
 
     /**
-     * Returns whether the current item is a valid item for the recurrence
+     * Returns whether the current item is a valid item for the recurrence;
      * iterator.
      *
      * @return bool
      */
     public function valid() {
 
-        return ($this->counter < count($this->dates)); 
+        return ($this->counter <= count($this->dates));
 
     }
 
@@ -88,12 +88,15 @@ class RDateIterator implements Iterator {
      */
     public function next() {
 
+        $this->counter++;
+        if (!$this->valid()) return;
+
         $this->currentDate->modify(
             DateTimeParser::parse(
-                $this->dates[$this->counter]
+                $this->dates[$this->counter-1]
             )->format('Y-m-d H:i:s')
         );
-        $this->counter++;
+
 
     }
 
diff --git a/lib/Recur/RRuleIterator.php b/lib/Recur/RRuleIterator.php
index 9df4b48..ba882d7 100644
--- a/lib/Recur/RRuleIterator.php
+++ b/lib/Recur/RRuleIterator.php
@@ -6,6 +6,7 @@ use DateTime;
 use InvalidArgumentException;
 use Iterator;
 use Sabre\VObject\DateTimeParser;
+use Sabre\VObject\Property;
 
 
 /**
diff --git a/tests/VObject/Recur/RRuleIterator.php b/tests/VObject/Recur/RRuleIteratorTest.php
similarity index 99%
rename from tests/VObject/Recur/RRuleIterator.php
rename to tests/VObject/Recur/RRuleIteratorTest.php
index 0f1236b..8299002 100644
--- a/tests/VObject/Recur/RRuleIterator.php
+++ b/tests/VObject/Recur/RRuleIteratorTest.php
@@ -642,7 +642,7 @@ class RRuleIteratorTest extends \PHPUnit_Framework_TestCase {
 
     function testIteratorFunctions() {
 
-        $parser = new RRuleParser('FREQ=DAILY', new DateTime('2014-08-02 00:00:13'));
+        $parser = new RRuleIterator('FREQ=DAILY', new DateTime('2014-08-02 00:00:13'));
         $parser->next();
         $this->assertEquals(
             new DateTime('2014-08-03 00:00:13'),
@@ -669,7 +669,7 @@ class RRuleIteratorTest extends \PHPUnit_Framework_TestCase {
     function parse($rule, $start, $expected, $fastForward = null, $tz = 'UTC') {
 
         $dt = new DateTime($start, new DateTimeZone($tz));
-        $parser = new RRuleParser($rule, $dt);
+        $parser = new RRuleIterator($rule, $dt);
 
         if ($fastForward) {
             $parser->fastForward(new DateTime($fastForward));
diff --git a/tests/phpunit.xml b/tests/phpunit.xml
index 6c1febd..2288151 100644
--- a/tests/phpunit.xml
+++ b/tests/phpunit.xml
@@ -7,7 +7,7 @@
   strict="true"
   >
   <testsuite name="Sabre\VObject">
-    <directory>unit/</directory>
+    <directory>VObject/</directory>
   </testsuite>
 
   <filter>

-- 
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