3 class Sabre_DAV_Property_ResponseTest extends PHPUnit_Framework_TestCase {
5 function testSimple() {
9 '{DAV:}displayname' => 'my file',
12 '{DAV:}owner' => null,
16 $property = new Sabre_DAV_Property_Response('uri',$innerProps);
18 $this->assertEquals('uri',$property->getHref());
19 $this->assertEquals($innerProps,$property->getResponseProperties());
27 function testSerialize() {
31 '{DAV:}displayname' => 'my file',
34 '{DAV:}owner' => null,
38 $property = new Sabre_DAV_Property_Response('uri',$innerProps);
40 $doc = new DOMDocument();
41 $root = $doc->createElement('d:root');
42 $root->setAttribute('xmlns:d','DAV:');
44 $doc->appendChild($root);
45 $objectTree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleCollection('rootdir'));
46 $server = new Sabre_DAV_Server($objectTree);
48 $property->serialize($server, $root);
50 $xml = $doc->saveXML();
53 '<?xml version="1.0"?>
54 <d:root xmlns:d="DAV:">' .
56 '<d:href>/uri</d:href>' .
59 '<d:displayname>my file</d:displayname>' .
61 '<d:status>HTTP/1.1 200 OK</d:status>' .
67 '<d:status>HTTP/1.1 404 Not Found</d:status>' .
76 * This one is specifically for testing properties with no namespaces, which is legal xml
78 * @depends testSerialize
80 function testSerializeEmptyNamespace() {
84 '{}propertyname' => 'value',
88 $property = new Sabre_DAV_Property_Response('uri',$innerProps);
90 $doc = new DOMDocument();
91 $root = $doc->createElement('d:root');
92 $root->setAttribute('xmlns:d','DAV:');
94 $doc->appendChild($root);
95 $objectTree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleCollection('rootdir'));
96 $server = new Sabre_DAV_Server($objectTree);
98 $property->serialize($server, $root);
100 $xml = $doc->saveXML();
103 '<?xml version="1.0"?>
104 <d:root xmlns:d="DAV:">' .
106 '<d:href>/uri</d:href>' .
109 '<propertyname xmlns="">value</propertyname>' .
111 '<d:status>HTTP/1.1 200 OK</d:status>' .
120 * This one is specifically for testing properties with no namespaces, which is legal xml
122 * @depends testSerialize
124 function testSerializeCustomNamespace() {
128 '{http://sabredav.org/NS/example}propertyname' => 'value',
132 $property = new Sabre_DAV_Property_Response('uri',$innerProps);
134 $doc = new DOMDocument();
135 $root = $doc->createElement('d:root');
136 $root->setAttribute('xmlns:d','DAV:');
138 $doc->appendChild($root);
139 $objectTree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleCollection('rootdir'));
140 $server = new Sabre_DAV_Server($objectTree);
142 $property->serialize($server, $root);
144 $xml = $doc->saveXML();
147 '<?xml version="1.0"?>
148 <d:root xmlns:d="DAV:">' .
150 '<d:href>/uri</d:href>' .
153 '<x2:propertyname xmlns:x2="http://sabredav.org/NS/example">value</x2:propertyname>' .
155 '<d:status>HTTP/1.1 200 OK</d:status>' .
164 * @depends testSerialize
166 function testSerializeComplexProperty() {
170 '{DAV:}link' => new Sabre_DAV_Property_Href('http://sabredav.org/', false)
174 $property = new Sabre_DAV_Property_Response('uri',$innerProps);
176 $doc = new DOMDocument();
177 $root = $doc->createElement('d:root');
178 $root->setAttribute('xmlns:d','DAV:');
180 $doc->appendChild($root);
181 $objectTree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleCollection('rootdir'));
182 $server = new Sabre_DAV_Server($objectTree);
184 $property->serialize($server, $root);
186 $xml = $doc->saveXML();
189 '<?xml version="1.0"?>
190 <d:root xmlns:d="DAV:">' .
192 '<d:href>/uri</d:href>' .
195 '<d:link><d:href>http://sabredav.org/</d:href></d:link>' .
197 '<d:status>HTTP/1.1 200 OK</d:status>' .
206 * @depends testSerialize
207 * @expectedException Sabre_DAV_Exception
209 function testSerializeBreak() {
213 '{DAV:}link' => new STDClass()
217 $property = new Sabre_DAV_Property_Response('uri',$innerProps);
219 $doc = new DOMDocument();
220 $root = $doc->createElement('d:root');
221 $root->setAttribute('xmlns:d','DAV:');
223 $doc->appendChild($root);
224 $objectTree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleCollection('rootdir'));
225 $server = new Sabre_DAV_Server($objectTree);
227 $property->serialize($server, $root);