loadXML('Testdoc'); $this->assertEquals( '{http://www.example.org/}test1', XMLUtil::toClarkNotation($dom->firstChild) ); } function testToClarkNotation2() { $dom = new \DOMDocument(); $dom->loadXML('Testdoc'); $this->assertEquals( '{http://www.example.org/}test1', XMLUtil::toClarkNotation($dom->firstChild) ); } function testToClarkNotationDAVNamespace() { $dom = new \DOMDocument(); $dom->loadXML('Testdoc'); $this->assertEquals( '{DAV:}test1', XMLUtil::toClarkNotation($dom->firstChild) ); } function testToClarkNotationNoElem() { $dom = new \DOMDocument(); $dom->loadXML('Testdoc'); $this->assertNull( XMLUtil::toClarkNotation($dom->firstChild->firstChild) ); } function testConvertDAVNamespace() { $xml='blablabla'; $this->assertEquals( 'blablabla', XMLUtil::convertDAVNamespace($xml) ); } function testConvertDAVNamespace2() { $xml='blablabla'; $this->assertEquals( 'blablabla', XMLUtil::convertDAVNamespace($xml) ); } function testConvertDAVNamespace3() { $xml='blablabla'; $this->assertEquals( 'blablabla', XMLUtil::convertDAVNamespace($xml) ); } function testConvertDAVNamespace4() { $xml='blablabla'; $this->assertEquals( 'blablabla', XMLUtil::convertDAVNamespace($xml) ); } function testConvertDAVNamespaceMixedQuotes() { $xml=''; $dom = XMLUtil::loadDOMDocument($xml); $this->assertTrue($dom instanceof \DOMDocument); } /** * @depends testLoadDOMDocument * @expectedException Sabre\DAV\Exception\BadRequest */ function testLoadDOMDocumentEmpty() { XMLUtil::loadDOMDocument(''); } /** * @expectedException Sabre\DAV\Exception\BadRequest * @depends testConvertDAVNamespace */ function testLoadDOMDocumentInvalid() { $xml='assertEquals('blabla',$dom->firstChild->nodeValue); } function testParseProperties() { $xml=' Calendars '; $dom = XMLUtil::loadDOMDocument($xml); $properties = XMLUtil::parseProperties($dom->firstChild); $this->assertEquals(array( '{DAV:}displayname' => 'Calendars', ), $properties); } /** * @depends testParseProperties */ function testParsePropertiesEmpty() { $xml=' Calendars '; $dom = XMLUtil::loadDOMDocument($xml); $properties = 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 = XMLUtil::loadDOMDocument($xml); $properties = XMLUtil::parseProperties($dom->firstChild); $this->assertEquals(array( '{DAV:}displayname' => 'Calendars', '{DAV:}someprop' => 'Complex value right here', ), $properties); } /** * @depends testParseProperties */ function testParsePropertiesNoProperties() { $xml=' '; $dom = XMLUtil::loadDOMDocument($xml); $properties = XMLUtil::parseProperties($dom->firstChild); $this->assertEquals(array(), $properties); } function testParsePropertiesMapHref() { $xml=' Calendars http://sabredav.org/ '; $dom = XMLUtil::loadDOMDocument($xml); $properties = XMLUtil::parseProperties($dom->firstChild,array('{DAV:}someprop'=>'Sabre\\DAV\\Property\\Href')); $this->assertEquals(array( '{DAV:}displayname' => 'Calendars', '{DAV:}someprop' => new Property\Href('http://sabredav.org/',false), ), $properties); } function testParseClarkNotation() { $this->assertEquals(array( 'DAV:', 'foo', ), XMLUtil::parseClarkNotation('{DAV:}foo')); $this->assertEquals(array( 'http://example.org/ns/bla', 'bar-soap', ), XMLUtil::parseClarkNotation('{http://example.org/ns/bla}bar-soap')); } /** * @expectedException InvalidArgumentException */ function testParseClarkNotationFail() { XMLUtil::parseClarkNotation('}foo'); } }