assertInstanceOf(__NAMESPACE__ . '\VAvailability', $document->VAVAILABILITY); } function testRFCxxxSection3_1_availabilityprop_required() { // UID and DTSTAMP are present. $this->assertIsValid(Reader::read( <<assertIsNotValid(Reader::read( <<assertIsNotValid(Reader::read( <<assertIsNotValid(Reader::read( <<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(array( $property, $property )))); } } function testRFCxxxSection3_1_availabilityprop_dtend_duration() { // Only DTEND. $this->assertIsValid(Reader::read($this->template(array( 'DTEND:21111005T133225Z' )))); // Only DURATION. $this->assertIsValid(Reader::read($this->template(array( 'DURATION:PT1H' )))); // Both (not allowed). $this->assertIsNotValid(Reader::read($this->template(array( 'DTEND:21111005T133225Z', 'DURATION:PT1H' )))); } function testAvailableSubComponent() { $vcal = <<assertInstanceOf(__NAMESPACE__, $document->VAVAILABILITY->AVAILABLE); } function testRFCxxxSection3_1_availableprop_required() { // UID, DTSTAMP and DTSTART are present. $this->assertIsValid(Reader::read( <<assertIsNotValid(Reader::read( <<assertIsNotValid(Reader::read( <<assertIsNotValid(Reader::read( <<assertIsNotValid(Reader::read( <<assertIsValid(Reader::read($this->templateAvailable(array( 'DTEND:21111005T133225Z' )))); // Only DURATION. $this->assertIsValid(Reader::read($this->templateAvailable(array( 'DURATION:PT1H' )))); // Both (not allowed). $this->assertIsNotValid(Reader::read($this->templateAvailable(array( 'DTEND:21111005T133225Z', 'DURATION:PT1H' )))); } function testRFCxxxSection3_1_available_optional_once() { $properties = array( 'CREATED:20111005T135125Z', 'DESCRIPTION:Long bla bla', 'LAST-MODIFIED:20111005T135325Z', 'RECURRENCE-ID;RANGE=THISANDFUTURE:19980401T133000Z', 'RRULE:FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR', 'SUMMARY:Bla bla' ); // They are all present, only once. $this->assertIsValid(Reader::read($this->templateAvailable($properties))); // We duplicate each one to see if it fails. foreach ($properties as $property) { $this->assertIsNotValid(Reader::read($this->templateAvailable(array( $property, $property )))); } } function testRFCxxxSection3_2() { $this->assertEquals( 'BUSY', Reader::read($this->templateAvailable(array( 'BUSYTYPE:BUSY' ))) ->VAVAILABILITY ->AVAILABLE ->BUSYTYPE ->getValue() ); $this->assertEquals( 'BUSY-UNAVAILABLE', Reader::read($this->templateAvailable(array( 'BUSYTYPE:BUSY-UNAVAILABLE' ))) ->VAVAILABILITY ->AVAILABLE ->BUSYTYPE ->getValue() ); $this->assertEquals( 'BUSY-TENTATIVE', Reader::read($this->templateAvailable(array( 'BUSYTYPE:BUSY-TENTATIVE' ))) ->VAVAILABILITY ->AVAILABLE ->BUSYTYPE ->getValue() ); } 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) { return $this->_template( <<_template( <<