assertEquals('path', $href->getHref());
}
function testSerialize() {
$href = new Href('path');
$this->assertEquals('path', $href->getHref());
$this->contextUri = '/bla/';
$xml = $this->write(['{DAV:}anything' => $href]);
$this->assertXmlStringEqualsXmlString(
'
/bla/path
', $xml);
}
function testSerializeNoPrefix() {
$href = new Href('path', false);
$this->assertEquals('path', $href->getHref());
$xml = $this->write(['{DAV:}anything' => $href]);
$this->assertXmlStringEqualsXmlString(
'
path
', $xml);
}
function testUnserialize() {
$xml = '
/bla/path
';
$result = $this->parse($xml, ['{DAV:}anything' => 'Sabre\\DAV\\Xml\\Property\\Href']);
$href = $result['value'];
$this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $href);
$this->assertEquals('/bla/path', $href->getHref());
}
function testUnserializeIncompatible() {
$xml = '
/bla/path
';
$result = $this->parse($xml, ['{DAV:}anything' => 'Sabre\\DAV\\Xml\\Property\\Href']);
$href = $result['value'];
$this->assertNull($href);
}
function testUnserializeEmpty() {
$xml = '
';
$result = $this->parse($xml, ['{DAV:}anything' => 'Sabre\\DAV\\Xml\\Property\\Href']);
$href = $result['value'];
$this->assertNull($href);
}
/**
* This method tests if hrefs containing & are correctly encoded.
*/
function testSerializeEntity() {
$href = new Href('http://example.org/?a&b', false);
$this->assertEquals('http://example.org/?a&b', $href->getHref());
$xml = $this->write(['{DAV:}anything' => $href]);
$this->assertXmlStringEqualsXmlString(
'
http://example.org/?a&b
', $xml);
}
function testToHtml() {
$href = new Href([
'/foo/bar',
'foo/bar',
'http://example.org/bar'
]);
$html = new HtmlOutputHelper(
'/base/',
[]
);
$expected =
'/foo/bar
' .
'/base/foo/bar
' .
'http://example.org/bar';
$this->assertEquals($expected, $href->toHtml($html));
}
}