mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 17:16:18 +00:00
Added test cases for Xml namespaces
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7096 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
4b1335797c
commit
93864f608a
1 changed files with 18 additions and 10 deletions
|
@ -485,23 +485,31 @@ class XmlTest extends UnitTestCase {
|
|||
}
|
||||
|
||||
function testNamespaceParsing() {
|
||||
return;
|
||||
$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);
|
||||
|
||||
$result = $xml->toString(array('cdata' => false));
|
||||
$this->assertEqual($source, $result);
|
||||
|
||||
$children = $xml->children('container');
|
||||
$this->assertEqual($children[0]->namespace, 'a');
|
||||
|
||||
$ns_a = $xml->namespaces['http://example.com/a'];
|
||||
$children = $xml->children();
|
||||
$child_ns = $children[0]->namespace();
|
||||
$this->assertEqual($ns_a, $child_ns);
|
||||
|
||||
$ns_b = $xml->namespaces['http://example.com/b'];
|
||||
$children = $children[0]->childNodes();
|
||||
$child_ns = $children[0]->namespace();
|
||||
$this->assertEqual($ns_b, $child_ns);
|
||||
$children = $children[0]->children('rule');
|
||||
$this->assertEqual($children[0]->namespace, 'b');
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/*
|
||||
* @todo Add test for default namespaces
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue