[Pkg-owncloud-commits] [php-sabre-vobject] 27/65: Add tests for Section 3.1: `availabilityprop`.
David Prévot
taffit at moszumanska.debian.org
Tue Feb 24 23:57:15 UTC 2015
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 9baa9017320172d642c378558bc635fe5bec674f
Author: Ivan Enderlin <ivan.enderlin at hoa-project.net>
Date: Fri Jan 30 14:37:50 2015 +0100
Add tests for Section 3.1: `availabilityprop`.
---
tests/VObject/Component/VAvailabilityTest.php | 140 ++++++++++++++++++++++++++
1 file changed, 140 insertions(+)
diff --git a/tests/VObject/Component/VAvailabilityTest.php b/tests/VObject/Component/VAvailabilityTest.php
index ec5bd03..4f6101b 100644
--- a/tests/VObject/Component/VAvailabilityTest.php
+++ b/tests/VObject/Component/VAvailabilityTest.php
@@ -6,6 +6,12 @@ use Sabre\VObject;
use Sabre\VObject\Reader;
use Sabre\VObject\Component\VAvailability;
+const CRLF = "\r\n";
+
+/**
+ * We use `RFCxxx` has a placeholder for the
+ * https://tools.ietf.org/html/draft-daboo-calendar-availability-05 name.
+ */
class VAvailabilityTest extends \PHPUnit_Framework_TestCase {
function testVAvailabilityComponent() {
@@ -22,4 +28,138 @@ VCAL;
}
+ function testRFCxxxSection3_1_availabilityprop_required() {
+
+ // UID and DTSTAMP are present.
+ $this->assertIsValid(Reader::read(
+<<<VCAL
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//id
+BEGIN:VAVAILABILITY
+UID:foo at test
+DTSTAMP:20111005T133225Z
+END:VAVAILABILITY
+END:VCALENDAR
+VCAL
+ ));
+
+ // UID and DTSTAMP are missing.
+ $this->assertIsNotValid(Reader::read(
+<<<VCAL
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//id
+BEGIN:VAVAILABILITY
+END:VAVAILABILITY
+END:VCALENDAR
+VCAL
+ ));
+
+ // DTSTAMP is missing.
+ $this->assertIsNotValid(Reader::read(
+<<<VCAL
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//id
+BEGIN:VAVAILABILITY
+UID:foo at test
+END:VAVAILABILITY
+END:VCALENDAR
+VCAL
+ ));
+
+ // UID is missing.
+ $this->assertIsNotValid(Reader::read(
+<<<VCAL
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//id
+BEGIN:VAVAILABILITY
+DTSTAMP:20111005T133225Z
+END:VAVAILABILITY
+END:VCALENDAR
+VCAL
+ ));
+
+ }
+
+ function testRFCxxxSection3_1_availabilityprop_optional_once() {
+
+ $properties = [
+ 'BUSYTYPE:BUSY',
+ 'CLASS:PUBLIC',
+ 'CREATED:20111005T135125Z',
+ 'DESCRIPTION:Long bla bla',
+ 'DTSTART:20111005T020000',
+ 'LAST-MODIFIED:20111005T135325Z',
+ 'ORGANIZER:mailto:foo at example.com',
+ 'PRIORITY:1',
+ 'SEQUENCE:0',
+ 'SUMMARY:Bla bla',
+ 'URL:http://exampLe.org/'
+ ];
+
+ // They are all present, only once.
+ $this->assertIsValid(Reader::read($this->template($properties)));
+
+ // We duplicate each one to see if it fails.
+ foreach ($properties as $property) {
+ $this->assertIsNotValid(Reader::read($this->template([
+ $property,
+ $property
+ ])));
+ }
+
+ }
+
+ function testRFCxxxSection3_1_availabilityprop_dtend_duration() {
+
+ // Only DTEND.
+ $this->assertIsValid(Reader::read($this->template([
+ 'DTEND:21111005T133225Z'
+ ])));
+
+ // Only DURATION.
+ $this->assertIsValid(Reader::read($this->template([
+ 'DURATION:PT1H'
+ ])));
+
+ // Both (not allowed).
+ $this->assertIsNotValid(Reader::read($this->template([
+ 'DTEND:21111005T133225Z',
+ 'DURATION:PT1H'
+ ])));
+ }
+
+ protected function assertIsValid(VObject\Document $document) {
+
+ $this->assertEmpty($document->validate());
+
+ }
+
+ protected function assertIsNotValid(VObject\Document $document) {
+
+ $this->assertNotEmpty($document->validate());
+
+ }
+
+ protected function template(array $properties) {
+
+ $template = <<<VCAL
+BEGIN:VCALENDAR
+VERSION:2.0
+PRODID:-//id
+BEGIN:VAVAILABILITY
+UID:foo at test
+DTSTAMP:20111005T133225Z
+…
+END:VAVAILABILITY
+END:VCALENDAR
+VCAL;
+
+ return str_replace('…', implode(CRLF, $properties), $template);
+
+ }
+
}
--
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