/** * testNamespacing method * * @access public * @return void */ function testNamespacing() { $node = new Xml('<xml></xml>'); $node->addNamespace('cake', 'http://cakephp.org'); $this->assertEqual($node->toString(), '<xml xmlns:cake="http://cakephp.org" />'); $this->assertTrue($node->removeNamespace('cake')); $this->assertEqual($node->toString(), '<xml />'); $node = new Xml('<xml xmlns:cake="http://cakephp.org" />'); $this->assertTrue($node->removeNamespace('cake')); $this->assertEqual($node->toString(), '<xml />'); $node->addNamespace('cake', 'http://cakephp.org'); $this->assertEqual($node->toString(), '<xml xmlns:cake="http://cakephp.org" />'); }
/** * testNamespaces method * * @access public * @return void */ function testNamespaces() { $source = '<a:container xmlns:a="http://example.com/a" xmlns:b="http://example.com/b" xmlns:c="http://example.com/c" xmlns:d="http://example.com/d" xmlns:e="http://example.com/e"><b:rule test=""><c:result>value</c:result></b:rule><d:rule test=""><e:result>value</e:result></d:rule></a:container>'; $xml = new Xml($source); $expects = '<a:container xmlns:a="http://example.com/a" xmlns:b="http://example.com/b" xmlns:c="http://example.com/c" xmlns:d="http://example.com/d" xmlns:e="http://example.com/e" xmlns:f="http://example.com/f"><b:rule test=""><c:result>value</c:result></b:rule><d:rule test=""><e:result>value</e:result></d:rule></a:container>'; $_xml = XmlManager::getInstance(); $xml->addNamespace('f', 'http://example.com/f'); $result = $xml->toString(array('cdata' => false)); $this->assertEqual($expects, $result); }