namespaceMap[CalDAV\Plugin::NS_CALDAV] = 'cal';
$this->namespaceMap[CalDAV\Plugin::NS_CALENDARSERVER] = 'cs';
}
function testSimple() {
$sccs = new Invite([]);
$this->assertInstanceOf('Sabre\CalDAV\Xml\Property\Invite', $sccs);
}
/**
* @depends testSimple
*/
function testSerialize() {
$property = new Invite([
[
'href' => 'mailto:user1@example.org',
'status' => CalDAV\SharingPlugin::STATUS_ACCEPTED,
'readOnly' => false,
],
[
'href' => 'mailto:user2@example.org',
'commonName' => 'John Doe',
'status' => CalDAV\SharingPlugin::STATUS_DECLINED,
'readOnly' => true,
],
[
'href' => 'mailto:user3@example.org',
'commonName' => 'Joe Shmoe',
'status' => CalDAV\SharingPlugin::STATUS_NORESPONSE,
'readOnly' => true,
'summary' => 'Something, something',
],
[
'href' => 'mailto:user4@example.org',
'commonName' => 'Hoe Boe',
'status' => CalDAV\SharingPlugin::STATUS_INVALID,
'readOnly' => true,
],
], [
'href' => 'mailto:thedoctor@example.org',
'commonName' => 'The Doctor',
'firstName' => 'The',
'lastName' => 'Doctor',
]);
$xml = $this->write(['{DAV:}root' => $property]);
$this->assertXmlStringEqualsXmlString(
'
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
*/
function testUnserialize() {
$input = [
[
'href' => 'mailto:user1@example.org',
'status' => CalDAV\SharingPlugin::STATUS_ACCEPTED,
'readOnly' => false,
'commonName' => '',
'summary' => '',
],
[
'href' => 'mailto:user2@example.org',
'commonName' => 'John Doe',
'status' => CalDAV\SharingPlugin::STATUS_DECLINED,
'readOnly' => true,
'summary' => '',
],
[
'href' => 'mailto:user3@example.org',
'commonName' => 'Joe Shmoe',
'status' => CalDAV\SharingPlugin::STATUS_NORESPONSE,
'readOnly' => true,
'summary' => 'Something, something',
],
[
'href' => 'mailto:user4@example.org',
'commonName' => 'Hoe Boe',
'status' => CalDAV\SharingPlugin::STATUS_INVALID,
'readOnly' => true,
'summary' => '',
],
];
// Creating the xml
$inputProperty = new Invite($input);
$xml = $this->write(['{DAV:}root' => $inputProperty]);
// Parsing it again
$doc2 = $this->parse(
$xml,
['{DAV:}root' => 'Sabre\\CalDAV\\Xml\\Property\\Invite']
);
$outputProperty = $doc2['value'];
$this->assertEquals($input, $outputProperty->getValue());
}
/**
* @expectedException InvalidArgumentException
*/
function testUnserializeNoStatus() {
$xml = '
mailto:user1@example.org
';
$this->parse(
$xml,
['{DAV:}root' => 'Sabre\\CalDAV\\Xml\\Property\\Invite']
);
}
}