array( '{DAV:}displayname' => 'my file', ), 404 => array( '{DAV:}owner' => null, ) ); $property = new 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 Response('uri',$innerProps); $doc = new \DOMDocument(); $root = $doc->createElement('d:root'); $root->setAttribute('xmlns:d','DAV:'); $doc->appendChild($root); $server = new DAV\Server(); $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 Response('uri',$innerProps); $doc = new \DOMDocument(); $root = $doc->createElement('d:root'); $root->setAttribute('xmlns:d','DAV:'); $doc->appendChild($root); $server = new DAV\Server(); $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 Response('uri',$innerProps); $doc = new \DOMDocument(); $root = $doc->createElement('d:root'); $root->setAttribute('xmlns:d','DAV:'); $doc->appendChild($root); $server = new DAV\Server(); $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 Href('http://sabredav.org/', false) ), ); $property = new Response('uri',$innerProps); $doc = new \DOMDocument(); $root = $doc->createElement('d:root'); $root->setAttribute('xmlns:d','DAV:'); $doc->appendChild($root); $server = new DAV\Server(); $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 Response('uri',$innerProps); $doc = new \DOMDocument(); $root = $doc->createElement('d:root'); $root->setAttribute('xmlns:d','DAV:'); $doc->appendChild($root); $server = new DAV\Server(); $property->serialize($server, $root); } }