Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F1726527
CurrentUserPrivilegeSetTest.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Size
1 KB
Subscribers
None
CurrentUserPrivilegeSetTest.php
View Options
<?php
namespace
Sabre\DAVACL\Xml\Property
;
use
Sabre\DAV
;
use
Sabre\DAV\Browser\HtmlOutputHelper
;
use
Sabre\HTTP
;
use
Sabre\Xml\Reader
;
class
CurrentUserPrivilegeSetTest
extends
\PHPUnit_Framework_TestCase
{
function
testSerialize
()
{
$privileges
=
[
'{DAV:}read'
,
'{DAV:}write'
,
];
$prop
=
new
CurrentUserPrivilegeSet
(
$privileges
);
$xml
=
(
new
DAV\Server
())->
xml
->
write
(
'{DAV:}root'
,
$prop
);
$expected
=
<<<XML
<d:root xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns">
<d:privilege>
<d:read />
</d:privilege>
<d:privilege>
<d:write />
</d:privilege>
</d:root>
XML;
$this
->
assertXmlStringEqualsXmlString
(
$expected
,
$xml
);
}
function
testUnserialize
()
{
$source
=
'<?xml version="1.0"?>
<d:root xmlns:d="DAV:">
<d:privilege>
<d:write-properties />
</d:privilege>
<d:ignoreme />
<d:privilege>
<d:read />
</d:privilege>
</d:root>
'
;
$result
=
$this
->
parse
(
$source
);
$this
->
assertTrue
(
$result
->
has
(
'{DAV:}read'
));
$this
->
assertTrue
(
$result
->
has
(
'{DAV:}write-properties'
));
$this
->
assertFalse
(
$result
->
has
(
'{DAV:}bind'
));
}
function
parse
(
$xml
)
{
$reader
=
new
Reader
();
$reader
->
elementMap
[
'{DAV:}root'
]
=
'Sabre
\\
DAVACL
\\
Xml
\\
Property
\\
CurrentUserPrivilegeSet'
;
$reader
->
xml
(
$xml
);
$result
=
$reader
->
parse
();
return
$result
[
'value'
];
}
function
testToHtml
()
{
$privileges
=
[
'{DAV:}read'
,
'{DAV:}write'
];
$prop
=
new
CurrentUserPrivilegeSet
(
$privileges
);
$html
=
new
HtmlOutputHelper
(
'/base/'
,
[
'DAV:'
=>
'd'
]
);
$expected
=
'<span title="{DAV:}read">d:read</span>, '
.
'<span title="{DAV:}write">d:write</span>'
;
$this
->
assertEquals
(
$expected
,
$prop
->
toHtml
(
$html
));
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Wed, Dec 4, 6:09 PM (8 h, 58 m ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
913513
Default Alt Text
CurrentUserPrivilegeSetTest.php (1 KB)
Attached To
rDAVCAL DokuWiki DAVCal PlugIn
Event Timeline
Log In to Comment