loadXML('Testdoc');
$this->assertEquals(
'{http://www.example.org/}test1',
Sabre_DAV_XMLUtil::toClarkNotation($dom->firstChild)
);
}
function testToClarkNotation2() {
$dom = new DOMDocument();
$dom->loadXML('Testdoc');
$this->assertEquals(
'{http://www.example.org/}test1',
Sabre_DAV_XMLUtil::toClarkNotation($dom->firstChild)
);
}
function testToClarkNotationDAVNamespace() {
$dom = new DOMDocument();
$dom->loadXML('Testdoc');
$this->assertEquals(
'{DAV:}test1',
Sabre_DAV_XMLUtil::toClarkNotation($dom->firstChild)
);
}
function testToClarkNotationNoElem() {
$dom = new DOMDocument();
$dom->loadXML('Testdoc');
$this->assertNull(
Sabre_DAV_XMLUtil::toClarkNotation($dom->firstChild->firstChild)
);
}
function testLoadDOMDocument() {
$xml='';
$dom = Sabre_DAV_XMLUtil::loadDOMDocument($xml);
$this->assertTrue($dom instanceof DOMDocument);
}
/**
* @depends testLoadDOMDocument
* @expectedException Sabre_DAV_Exception_BadRequest
*/
function testLoadDOMDocumentEmpty() {
Sabre_DAV_XMLUtil::loadDOMDocument('');
}
/**
* @expectedException Sabre_DAV_Exception_BadRequest
*/
function testLoadDOMDocumentInvalid() {
$xml='blabla';
$xml = iconv('UTF-8','UTF-16LE',$xml);
$dom = Sabre_DAV_XMLUtil::loadDOMDocument($xml);
$this->assertEquals('blabla',$dom->firstChild->nodeValue);
}
function testParseProperties() {
$xml='
Calendars
';
$dom = Sabre_DAV_XMLUtil::loadDOMDocument($xml);
$properties = Sabre_DAV_XMLUtil::parseProperties($dom->firstChild);
$this->assertEquals(array(
'{DAV:}displayname' => 'Calendars',
), $properties);
}
/**
* @depends testParseProperties
*/
function testParsePropertiesEmpty() {
$xml='
Calendars
';
$dom = Sabre_DAV_XMLUtil::loadDOMDocument($xml);
$properties = Sabre_DAV_XMLUtil::parseProperties($dom->firstChild);
$this->assertEquals(array(
'{DAV:}displayname' => 'Calendars',
'{http://www.rooftopsolutions.nl/example}example' => null
), $properties);
}
/**
* @depends testParseProperties
*/
function testParsePropertiesComplex() {
$xml='
Calendars
Complex value right here
';
$dom = Sabre_DAV_XMLUtil::loadDOMDocument($xml);
$properties = Sabre_DAV_XMLUtil::parseProperties($dom->firstChild);
$this->assertEquals(array(
'{DAV:}displayname' => 'Calendars',
'{DAV:}someprop' => 'Complex value right here',
), $properties);
}
/**
* @depends testParseProperties
*/
function testParsePropertiesNoProperties() {
$xml='
';
$dom = Sabre_DAV_XMLUtil::loadDOMDocument($xml);
$properties = Sabre_DAV_XMLUtil::parseProperties($dom->firstChild);
$this->assertEquals(array(), $properties);
}
function testParsePropertiesMapHref() {
$xml='
Calendars
http://sabredav.org/
';
$dom = Sabre_DAV_XMLUtil::loadDOMDocument($xml);
$properties = Sabre_DAV_XMLUtil::parseProperties($dom->firstChild,array('{DAV:}someprop'=>'Sabre_DAV_Property_Href'));
$this->assertEquals(array(
'{DAV:}displayname' => 'Calendars',
'{DAV:}someprop' => new Sabre_DAV_Property_Href('http://sabredav.org/',false),
), $properties);
}
function testParseClarkNotation() {
$this->assertEquals(array(
'DAV:',
'foo',
), Sabre_DAV_XMLUtil::parseClarkNotation('{DAV:}foo'));
$this->assertEquals(array(
'http://example.org/ns/bla',
'bar-soap',
), Sabre_DAV_XMLUtil::parseClarkNotation('{http://example.org/ns/bla}bar-soap'));
}
/**
* @expectedException InvalidArgumentException
*/
function testParseClarkNotationFail() {
Sabre_DAV_XMLUtil::parseClarkNotation('}foo');
}
}