'mailto:user1@example.org', 'status' => CalDAV\SharingPlugin::STATUS_ACCEPTED, 'readOnly' => false, ), array( 'href' => 'mailto:user2@example.org', 'commonName' => 'John Doe', 'status' => CalDAV\SharingPlugin::STATUS_DECLINED, 'readOnly' => true, ), array( 'href' => 'mailto:user3@example.org', 'commonName' => 'Joe Shmoe', 'status' => CalDAV\SharingPlugin::STATUS_NORESPONSE, 'readOnly' => true, 'summary' => 'Something, something', ), array( 'href' => 'mailto:user4@example.org', 'commonName' => 'Hoe Boe', 'status' => CalDAV\SharingPlugin::STATUS_INVALID, 'readOnly' => true, ), ), array( 'href' => 'mailto:thedoctor@example.org', 'commonName' => 'The Doctor', 'firstName' => 'The', 'lastName' => 'Doctor', )); $doc = new \DOMDocument(); $doc->formatOutput = true; $root = $doc->createElement('d:root'); $root->setAttribute('xmlns:d','DAV:'); $root->setAttribute('xmlns:cal',CalDAV\Plugin::NS_CALDAV); $root->setAttribute('xmlns:cs',CalDAV\Plugin::NS_CALENDARSERVER); $doc->appendChild($root); $server = new DAV\Server(); $property->serialize($server, $root); $xml = $doc->saveXML(); $this->assertEquals( ' mailto:thedoctor@example.org The Doctor The Doctor mailto:user1@example.org mailto:user2@example.org John Doe mailto:user3@example.org Joe Shmoe Something, something mailto:user4@example.org Hoe Boe ', $xml); } /** * @depends testSerialize */ public function testUnserialize() { $input = array( array( 'href' => 'mailto:user1@example.org', 'status' => CalDAV\SharingPlugin::STATUS_ACCEPTED, 'readOnly' => false, 'commonName' => '', 'summary' => '', ), array( 'href' => 'mailto:user2@example.org', 'commonName' => 'John Doe', 'status' => CalDAV\SharingPlugin::STATUS_DECLINED, 'readOnly' => true, 'summary' => '', ), array( 'href' => 'mailto:user3@example.org', 'commonName' => 'Joe Shmoe', 'status' => CalDAV\SharingPlugin::STATUS_NORESPONSE, 'readOnly' => true, 'summary' => 'Something, something', ), array( 'href' => 'mailto:user4@example.org', 'commonName' => 'Hoe Boe', 'status' => CalDAV\SharingPlugin::STATUS_INVALID, 'readOnly' => true, 'summary' => '', ), ); // Creating the xml $doc = new \DOMDocument(); $doc->formatOutput = true; $root = $doc->createElement('d:root'); $root->setAttribute('xmlns:d','DAV:'); $root->setAttribute('xmlns:cal',CalDAV\Plugin::NS_CALDAV); $root->setAttribute('xmlns:cs',CalDAV\Plugin::NS_CALENDARSERVER); $doc->appendChild($root); $server = new DAV\Server(); $inputProperty = new Invite($input); $inputProperty->serialize($server, $root); $xml = $doc->saveXML(); // Parsing it again $doc2 = DAV\XMLUtil::loadDOMDocument($xml); $outputProperty = Invite::unserialize($doc2->firstChild); $this->assertEquals($input, $outputProperty->getValue()); } /** * @expectedException Sabre\DAV\Exception */ function testUnserializeNoStatus() { $xml = ' mailto:user1@example.org '; $doc2 = DAV\XMLUtil::loadDOMDocument($xml); $outputProperty = Invite::unserialize($doc2->firstChild); } }