[Pkg-owncloud-commits] [php-sabre-vobject] 81/106: 99.68% code coverage is good enough for now.
David Prévot
taffit at moszumanska.debian.org
Fri Aug 22 15:11:06 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 29cd405666ec56c931ca74481801bc1f8d1aab3a
Author: Evert Pot <evert at rooftopsolutions.nl>
Date: Thu Aug 7 13:28:56 2014 -0400
99.68% code coverage is good enough for now.
---
lib/Recur/EventIterator.php | 9 ++-
lib/StringUtil.php | 3 +
tests/VObject/Component/VCalendarTest.php | 57 ++++++++++++++++
tests/VObject/DateTimeParserTest.php | 1 +
tests/VObject/Recur/EventIterator/MainTest.php | 29 ++++++++
tests/VObject/VCardConverterTest.php | 92 ++++++++++++++++++++++++++
6 files changed, 188 insertions(+), 3 deletions(-)
diff --git a/lib/Recur/EventIterator.php b/lib/Recur/EventIterator.php
index 28c1889..4fa96ce 100644
--- a/lib/Recur/EventIterator.php
+++ b/lib/Recur/EventIterator.php
@@ -238,12 +238,18 @@ class EventIterator implements \Iterator {
}
$event = clone $this->masterEvent;
+
+ // Ignoring the following block, because PHPUnit's code coverage
+ // ignores most of these lines, and this messes with our stats.
+ //
+ // @codeCoverageIgnoreStart
unset(
$event->RRULE,
$event->EXDATE,
$event->RDATE,
$event->EXRULE
);
+ // @codeCoverageIgnoreEnd
$event->DTSTART->setDateTime($this->getDtStart());
if (isset($event->DTEND)) {
@@ -329,9 +335,6 @@ class EventIterator implements \Iterator {
break;
}
$nextDate = $this->recurIterator->current();
- if (!$nextDate) {
- break;
- }
$this->recurIterator->next();
} while(isset($this->exceptions[$nextDate->getTimeStamp()]));
diff --git a/lib/StringUtil.php b/lib/StringUtil.php
index 5e0dce6..456cd43 100644
--- a/lib/StringUtil.php
+++ b/lib/StringUtil.php
@@ -50,9 +50,12 @@ class StringUtil {
case 'ISO-8859-1' :
$newStr = utf8_encode($str);
break;
+ /* Unreachable code. Not sure yet how we can improve this
+ * situation.
case 'WINDOWS-1252' :
$newStr = iconv('cp1252', 'UTF-8', $str);
break;
+ */
default :
$newStr = $str;
diff --git a/tests/VObject/Component/VCalendarTest.php b/tests/VObject/Component/VCalendarTest.php
index 0e123cb..0b28124 100644
--- a/tests/VObject/Component/VCalendarTest.php
+++ b/tests/VObject/Component/VCalendarTest.php
@@ -414,4 +414,61 @@ END:VCALENDAR
$this->assertEquals(0, count($vcal->validate()));
}
+
+ function testGetBaseComponent() {
+
+ $input = 'BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:foo
+METHOD:REQUEST
+BEGIN:VEVENT
+SUMMARY:test
+DTSTART;VALUE=DATE:20111202
+UID:foo
+DTSTAMP:20140122T234434Z
+END:VEVENT
+BEGIN:VEVENT
+DTSTART;VALUE=DATE:20111202
+UID:foo
+DTSTAMP:20140122T234434Z
+RECURRENCE-ID;VALUE=DATE:20111202
+END:VEVENT
+END:VCALENDAR
+';
+
+ $vcal = VObject\Reader::read($input);
+
+ $result = $vcal->getBaseComponent();
+ $this->assertEquals('test', $result->SUMMARY->getValue());
+
+ }
+
+ function testGetBaseComponentNoResult() {
+
+ $input = 'BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:foo
+METHOD:REQUEST
+BEGIN:VEVENT
+SUMMARY:test
+RECURRENCE-ID;VALUE=DATE:20111202
+DTSTART;VALUE=DATE:20111202
+UID:foo
+DTSTAMP:20140122T234434Z
+END:VEVENT
+BEGIN:VEVENT
+DTSTART;VALUE=DATE:20111202
+UID:foo
+DTSTAMP:20140122T234434Z
+RECURRENCE-ID;VALUE=DATE:20111202
+END:VEVENT
+END:VCALENDAR
+';
+
+ $vcal = VObject\Reader::read($input);
+
+ $result = $vcal->getBaseComponent();
+ $this->assertNull($result);
+
+ }
}
diff --git a/tests/VObject/DateTimeParserTest.php b/tests/VObject/DateTimeParserTest.php
index 8c78d1b..f4ae42d 100644
--- a/tests/VObject/DateTimeParserTest.php
+++ b/tests/VObject/DateTimeParserTest.php
@@ -15,6 +15,7 @@ class DateTimeParserTest extends \PHPUnit_Framework_TestCase {
$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('+0 seconds', DateTimeParser::parseDuration('+PT0S',true));
$this->assertEquals(new DateInterval('PT0S'), DateTimeParser::parseDuration('PT0S'));
}
diff --git a/tests/VObject/Recur/EventIterator/MainTest.php b/tests/VObject/Recur/EventIterator/MainTest.php
index 555abeb..064210c 100644
--- a/tests/VObject/Recur/EventIterator/MainTest.php
+++ b/tests/VObject/Recur/EventIterator/MainTest.php
@@ -1394,5 +1394,34 @@ class MainTest extends \PHPUnit_Framework_TestCase {
);
}
+
+ /**
+ * @depends testValues
+ * @expectedException \InvalidArgumentException
+ */
+ function testNoMasterBadUID() {
+
+ $vcal = new VCalendar();
+ // ev2 overrides an event, and puts it on 2pm instead.
+ $ev2 = $vcal->createComponent('VEVENT');
+ $ev2->UID = 'overridden';
+ $ev2->{'RECURRENCE-ID'} = '20120110T120000Z';
+ $ev2->DTSTART = '20120110T140000Z';
+ $ev2->SUMMARY = 'Event 2';
+
+ $vcal->add($ev2);
+
+ // ev3 overrides an event, and puts it 2 days and 2 hours later
+ $ev3 = $vcal->createComponent('VEVENT');
+ $ev3->UID = 'overridden';
+ $ev3->{'RECURRENCE-ID'} = '20120113T120000Z';
+ $ev3->DTSTART = '20120115T140000Z';
+ $ev3->SUMMARY = 'Event 3';
+
+ $vcal->add($ev3);
+
+ $it = new EventIterator($vcal,'broken');
+
+ }
}
diff --git a/tests/VObject/VCardConverterTest.php b/tests/VObject/VCardConverterTest.php
index 941d36c..b8a9e58 100644
--- a/tests/VObject/VCardConverterTest.php
+++ b/tests/VObject/VCardConverterTest.php
@@ -322,4 +322,96 @@ OUT;
}
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ function testUnknownSourceVCardVersion() {
+
+ $input = <<<IN
+BEGIN:VCARD
+VERSION:4.2
+PRODID:foo
+FN;CHARSET=UTF-8:Steve
+TEL;TYPE=PREF,HOME:+1 555 666 777
+ITEM1.TEL:+1 444 555 666
+ITEM1.X-ABLABEL:CustomLabel
+PHOTO;ENCODING=b;TYPE=JPEG,HOME:Zm9v
+PHOTO;ENCODING=b;TYPE=GIF:Zm9v
+PHOTO;X-PARAM=FOO;ENCODING=b;TYPE=PNG:Zm9v
+PHOTO;VALUE=URI:http://example.org/foo.png
+X-ABShowAs:COMPANY
+END:VCARD
+
+IN;
+
+ $vcard = \Sabre\VObject\Reader::read($input);
+ $vcard->convert(\Sabre\VObject\Document::VCARD40);
+
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ function testUnknownTargetVCardVersion() {
+
+ $input = <<<IN
+BEGIN:VCARD
+VERSION:3.0
+PRODID:foo
+END:VCARD
+
+IN;
+
+ $vcard = \Sabre\VObject\Reader::read($input);
+ $vcard->convert(\Sabre\VObject\Document::VCARD21);
+
+ }
+
+ function testConvertIndividualCard() {
+
+ $version = Version::VERSION;
+
+ $input = <<<IN
+BEGIN:VCARD
+VERSION:4.0
+PRODID:foo
+KIND:INDIVIDUAL
+END:VCARD
+
+IN;
+
+ $output = <<<OUT
+BEGIN:VCARD
+VERSION:3.0
+PRODID:-//Sabre//Sabre VObject {$version}//EN
+END:VCARD
+
+OUT;
+
+ $vcard = \Sabre\VObject\Reader::read($input);
+ $vcard = $vcard->convert(\Sabre\VObject\Document::VCARD30);
+
+ $this->assertEquals(
+ $output,
+ str_replace("\r", "", $vcard->serialize())
+ );
+
+ $input = $output;
+ $output = <<<OUT
+BEGIN:VCARD
+VERSION:4.0
+PRODID:-//Sabre//Sabre VObject {$version}//EN
+END:VCARD
+
+OUT;
+
+ $vcard = \Sabre\VObject\Reader::read($input);
+ $vcard = $vcard->convert(\Sabre\VObject\Document::VCARD40);
+
+ $this->assertEquals(
+ $output,
+ str_replace("\r", "", $vcard->serialize())
+ );
+
+ }
}
--
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