Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F1821043
InviteTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Size
4 KB
Subscribers
None
InviteTest.php
View Options
<?php
namespace
Sabre\CalDAV\Xml\Property
;
use
Sabre\CalDAV
;
use
Sabre\DAV
;
class
InviteTest
extends
DAV\Xml\XmlTest
{
function
setUp
()
{
$this
->
namespaceMap
[
CalDAV\Plugin
::
NS_CALDAV
]
=
'cal'
;
$this
->
namespaceMap
[
CalDAV\Plugin
::
NS_CALENDARSERVER
]
=
'cs'
;
}
function
testSimple
()
{
$sccs
=
new
Invite
([]);
$this
->
assertInstanceOf
(
'Sabre
\C
alDAV
\X
ml
\P
roperty
\I
nvite'
,
$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
(
'<?xml version="1.0"?>
<d:root xmlns:d="DAV:" xmlns:cal="'
.
CalDAV\Plugin
::
NS_CALDAV
.
'" xmlns:cs="'
.
CalDAV\Plugin
::
NS_CALENDARSERVER
.
'">
<cs:organizer>
<d:href>mailto:thedoctor@example.org</d:href>
<cs:common-name>The Doctor</cs:common-name>
<cs:first-name>The</cs:first-name>
<cs:last-name>Doctor</cs:last-name>
</cs:organizer>
<cs:user>
<d:href>mailto:user1@example.org</d:href>
<cs:invite-accepted/>
<cs:access>
<cs:read-write/>
</cs:access>
</cs:user>
<cs:user>
<d:href>mailto:user2@example.org</d:href>
<cs:common-name>John Doe</cs:common-name>
<cs:invite-declined/>
<cs:access>
<cs:read/>
</cs:access>
</cs:user>
<cs:user>
<d:href>mailto:user3@example.org</d:href>
<cs:common-name>Joe Shmoe</cs:common-name>
<cs:invite-noresponse/>
<cs:access>
<cs:read/>
</cs:access>
<cs:summary>Something, something</cs:summary>
</cs:user>
<cs:user>
<d:href>mailto:user4@example.org</d:href>
<cs:common-name>Hoe Boe</cs:common-name>
<cs:invite-invalid/>
<cs:access>
<cs:read/>
</cs:access>
</cs:user>
</d:root>
'
,
$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
=
'<?xml version="1.0"?>
<d:root xmlns:d="DAV:" xmlns:cal="'
.
CalDAV\Plugin
::
NS_CALDAV
.
'" xmlns:cs="'
.
CalDAV\Plugin
::
NS_CALENDARSERVER
.
'">
<cs:user>
<d:href>mailto:user1@example.org</d:href>
<!-- <cs:invite-accepted/> -->
<cs:access>
<cs:read-write/>
</cs:access>
</cs:user>
</d:root>'
;
$this
->
parse
(
$xml
,
[
'{DAV:}root'
=>
'Sabre
\\
CalDAV
\\
Xml
\\
Property
\\
Invite'
]
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Mon, Dec 23, 1:39 AM (1 d, 17 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
914215
Default Alt Text
InviteTest.php (4 KB)
Attached To
rDAVCAL DokuWiki DAVCal PlugIn
Event Timeline
Log In to Comment