array( '{DAV:}displayname' => 'my file', ), 404 => array( '{DAV:}owner' => null, ) ); $property = new Sabre_DAV_Property_Response('uri',$innerProps); $this->assertEquals('uri',$property->getHref()); $this->assertEquals($innerProps,$property->getResponseProperties()); } /** * @depends testSimple */ function testSerialize() { $innerProps = array( 200 => array( '{DAV:}displayname' => 'my file', ), 404 => array( '{DAV:}owner' => null, ) ); $property = new Sabre_DAV_Property_Response('uri',$innerProps); $doc = new DOMDocument(); $root = $doc->createElement('d:root'); $root->setAttribute('xmlns:d','DAV:'); $doc->appendChild($root); $objectTree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleCollection('rootdir')); $server = new Sabre_DAV_Server($objectTree); $property->serialize($server, $root); $xml = $doc->saveXML(); $this->assertEquals( ' ' . '' . '/uri' . '' . '' . 'my file' . '' . 'HTTP/1.1 200 OK' . '' . '' . '' . '' . '' . 'HTTP/1.1 404 Not Found' . '' . '' . ' ', $xml); } /** * This one is specifically for testing properties with no namespaces, which is legal xml * * @depends testSerialize */ function testSerializeEmptyNamespace() { $innerProps = array( 200 => array( '{}propertyname' => 'value', ), ); $property = new Sabre_DAV_Property_Response('uri',$innerProps); $doc = new DOMDocument(); $root = $doc->createElement('d:root'); $root->setAttribute('xmlns:d','DAV:'); $doc->appendChild($root); $objectTree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleCollection('rootdir')); $server = new Sabre_DAV_Server($objectTree); $property->serialize($server, $root); $xml = $doc->saveXML(); $this->assertEquals( ' ' . '' . '/uri' . '' . '' . 'value' . '' . 'HTTP/1.1 200 OK' . '' . '' . ' ', $xml); } /** * This one is specifically for testing properties with no namespaces, which is legal xml * * @depends testSerialize */ function testSerializeCustomNamespace() { $innerProps = array( 200 => array( '{http://sabredav.org/NS/example}propertyname' => 'value', ), ); $property = new Sabre_DAV_Property_Response('uri',$innerProps); $doc = new DOMDocument(); $root = $doc->createElement('d:root'); $root->setAttribute('xmlns:d','DAV:'); $doc->appendChild($root); $objectTree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleCollection('rootdir')); $server = new Sabre_DAV_Server($objectTree); $property->serialize($server, $root); $xml = $doc->saveXML(); $this->assertEquals( ' ' . '' . '/uri' . '' . '' . 'value' . '' . 'HTTP/1.1 200 OK' . '' . '' . ' ', $xml); } /** * @depends testSerialize */ function testSerializeComplexProperty() { $innerProps = array( 200 => array( '{DAV:}link' => new Sabre_DAV_Property_Href('http://sabredav.org/', false) ), ); $property = new Sabre_DAV_Property_Response('uri',$innerProps); $doc = new DOMDocument(); $root = $doc->createElement('d:root'); $root->setAttribute('xmlns:d','DAV:'); $doc->appendChild($root); $objectTree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleCollection('rootdir')); $server = new Sabre_DAV_Server($objectTree); $property->serialize($server, $root); $xml = $doc->saveXML(); $this->assertEquals( ' ' . '' . '/uri' . '' . '' . 'http://sabredav.org/' . '' . 'HTTP/1.1 200 OK' . '' . '' . ' ', $xml); } /** * @depends testSerialize * @expectedException Sabre_DAV_Exception */ function testSerializeBreak() { $innerProps = array( 200 => array( '{DAV:}link' => new STDClass() ), ); $property = new Sabre_DAV_Property_Response('uri',$innerProps); $doc = new DOMDocument(); $root = $doc->createElement('d:root'); $root->setAttribute('xmlns:d','DAV:'); $doc->appendChild($root); $objectTree = new Sabre_DAV_ObjectTree(new Sabre_DAV_SimpleCollection('rootdir')); $server = new Sabre_DAV_Server($objectTree); $property->serialize($server, $root); } }