assertEquals(array('foo','bar'),$href->getHrefs());
}
function testSerialize() {
$href = new Sabre_DAV_Property_HrefList(array('foo','bar'));
$this->assertEquals(array('foo','bar'),$href->getHrefs());
$doc = new DOMDocument();
$root = $doc->createElement('d:anything');
$root->setAttribute('xmlns:d','DAV:');
$doc->appendChild($root);
$server = new Sabre_DAV_Server();
$server->setBaseUri('/bla/');
$href->serialize($server, $root);
$xml = $doc->saveXML();
$this->assertEquals(
'
/bla/foo/bla/bar
', $xml);
}
function testSerializeNoPrefix() {
$href = new Sabre_DAV_Property_HrefList(array('foo','bar'), false);
$this->assertEquals(array('foo','bar'),$href->getHrefs());
$doc = new DOMDocument();
$root = $doc->createElement('d:anything');
$root->setAttribute('xmlns:d','DAV:');
$doc->appendChild($root);
$server = new Sabre_DAV_Server();
$server->setBaseUri('/bla/');
$href->serialize($server, $root);
$xml = $doc->saveXML();
$this->assertEquals(
'
foobar
', $xml);
}
function testUnserialize() {
$xml = '
/bla/foo/bla/bar
';
$dom = new DOMDocument();
$dom->loadXML($xml);
$href = Sabre_DAV_Property_HrefList::unserialize($dom->firstChild);
$this->assertEquals(array('/bla/foo','/bla/bar'),$href->getHrefs());
}
function testUnserializeIncompatible() {
$xml = '
/bla/foo
';
$dom = new DOMDocument();
$dom->loadXML($xml);
$href = Sabre_DAV_Property_HrefList::unserialize($dom->firstChild);
$this->assertEquals(array(), $href->getHrefs());
}
}