[Pkg-owncloud-commits] [php-sabre-vobject] 16/30: Use number instead of string for COUNT property in RRULE

David Prévot taffit at moszumanska.debian.org
Sun Mar 13 00:53:02 UTC 2016


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 0a8f3a6da29716b64a86a260f16d4486450bed18
Author: Luc DUZAN <lduzan at linagora.com>
Date:   Thu Mar 3 14:28:32 2016 +0100

    Use number instead of string for COUNT property in RRULE
---
 lib/Property/ICalendar/Recur.php               |  5 +++--
 tests/VObject/Property/ICalendar/RecurTest.php | 28 ++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/lib/Property/ICalendar/Recur.php b/lib/Property/ICalendar/Recur.php
index 1b8e86c..b157d48 100644
--- a/lib/Property/ICalendar/Recur.php
+++ b/lib/Property/ICalendar/Recur.php
@@ -54,7 +54,7 @@ class Recur extends Property {
                     if (strcmp($k, 'until') === 0) {
                         $v = strtr($v, [':' => '', '-' => '']);
                     }
-                } else {
+                } elseif (is_array($v)) {
                     $v = array_map('strtoupper', $v);
                 }
 
@@ -171,6 +171,8 @@ class Recur extends Property {
             if (strcmp($k, 'UNTIL') === 0) {
                 $date = new DateTime($this->root, null, $v);
                 $values[strtolower($k)] = $date->getJsonValue()[0];
+            } elseif (strcmp($k, 'COUNT') === 0) {
+                $values[strtolower($k)] = intval($v);
             } else {
                 $values[strtolower($k)] = $v;
             }
@@ -225,7 +227,6 @@ class Recur extends Property {
         }
 
         return $newValue;
-
     }
 
 }
diff --git a/tests/VObject/Property/ICalendar/RecurTest.php b/tests/VObject/Property/ICalendar/RecurTest.php
index 6bde8e2..0c59d46 100644
--- a/tests/VObject/Property/ICalendar/RecurTest.php
+++ b/tests/VObject/Property/ICalendar/RecurTest.php
@@ -32,6 +32,34 @@ class RecurTest extends \PHPUnit_Framework_TestCase {
 
     }
 
+    function testSetValueWithCount() {
+        $vcal = new VCalendar();
+        $recur = $vcal->add('RRULE', 'FREQ=Daily');
+        $recur->setValue(['COUNT' => 3]);
+        $this->assertEquals($recur->getParts()['COUNT'], 3);
+    }
+
+    function testGetJSONWithCount() {
+        $input = 'BEGIN:VCALENDAR
+BEGIN:VEVENT
+UID:908d53c0-e1a3-4883-b69f-530954d6bd62
+TRANSP:OPAQUE
+DTSTART;TZID=Europe/Berlin:20160301T150000
+DTEND;TZID=Europe/Berlin:20160301T170000
+SUMMARY:test
+RRULE:FREQ=DAILY;COUNT=3
+ORGANIZER;CN=robert pipo:mailto:robert at pipo.com
+END:VEVENT
+END:VCALENDAR
+';
+
+        $vcal = Reader::read($input);
+        $rrule = $vcal->VEVENT->RRULE;
+        $count = $rrule->getJsonValue()[0]['count'];
+        $this->assertTrue(is_int($count));
+        $this->assertEquals(3, $count);
+    }
+
     function testSetSubParts() {
 
         $vcal = new VCalendar();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-php/php-sabre-vobject.git



More information about the Pkg-owncloud-commits mailing list