From d59a4921188753dbe4c0161081755a28112c3ef6 Mon Sep 17 00:00:00 2001
From: Nathan Gass
Date: Thu, 22 Mar 2012 18:18:42 +0000
Subject: Branch itools/devel-utf8 created
---
devel-utf8/tests/it_xml.t | 120 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 120 insertions(+)
create mode 100755 devel-utf8/tests/it_xml.t
(limited to 'devel-utf8/tests/it_xml.t')
diff --git a/devel-utf8/tests/it_xml.t b/devel-utf8/tests/it_xml.t
new file mode 100755
index 0000000..f74c54b
--- /dev/null
+++ b/devel-utf8/tests/it_xml.t
@@ -0,0 +1,120 @@
+#!/www/server/bin/php -qC
+$xmldata";
+ $xml = new $classname($xmldata, $p);
+
+ is(
+ preg_replace('/[#\s]+/', " ", print_r($xml->$varname, true)),
+ $expected,
+ "$name (string)"
+ );
+
+ $tmpfile = tmpfile();
+ fwrite($tmpfile, $xmldata);
+ rewind($tmpfile);
+
+ $xml = new $classname($tmpfile, $p);
+ fclose($tmpfile);
+
+ is(
+ preg_replace('/[#\s]+/', " ", print_r($xml->$varname, true)),
+ $expected,
+ "$name (file)"
+ );
+
+}
+
+match(
+ '',
+ 'foo Object ( ) ',
+ 'empty tag'
+);
+
+match(
+ '',
+ 'Array ( [0] => foo Object ( ) [1] => foo Object ( ) ) ',
+ 'multiple empty tags converted to array'
+);
+
+match(
+ 'Stüssihofstadt',
+ 'foo Object ( [attr] => Array ( [title] => Zürich ) [val] => Stüssihofstadt ) ',
+ 'simple tag with latin1 content and attribute'
+);
+
+match(
+ '',
+ 'foo Object ( [a_b__c] => a_b__c Object ( [attr] => Array ( [d_e_f] => value ) ) ) ',
+ 'Tags and attributes with name space and special characters'
+);
+
+match(
+ 'x & y',
+ 'foo Object ( [val] => x & y ) ',
+ 'Character data with entities'
+);
+
+match(
+ '& <a> & <b> & <c> ü',
+ 'foo Object ( [val] => & & & ü ) ',
+ 'Predecode illegal entities while keeping properly encoded ones'
+);
+
+match(
+ '& <a> & <b> & <c> ü',
+ utf8_encode('foo Object ( [val] => & & & ü ) '),
+ 'Predecode illegal entities while keeping properly encoded ones (UTF-8)',
+ "",
+ array('encoding' => "UTF-8")
+);
+
+
+match(
+ "a\x05b",
+ 'foo Object ( [val] => a b ) ',
+ 'Illegal latin 1 character',
+ "",
+ array('encoding' => "ISO-8859-1")
+);
+
+# Test inheritance
+class my_xml extends it_xml
+{
+
+function my_xml($xmldata)
+{
+ parent::it_xml($xmldata);
+
+ # Code which should be executed in root and only there
+ $this->qux = new it_xml;
+ $this->qux->val = "qux";
+
+ if (is_object($this->myfoo))
+ $this->myfoo->inheritbaseclass = is_a($this->myfoo, "my_xml");
+}
+
+}
+
+match(
+ '',
+ 'myfoo Object ( [inheritbaseclass] => ) ',
+ 'Inheritance and constructor (critical for e.g. tel_xmlentry)',
+ 'my'
+);
+
+$x = new foo("", array('prefix' => "test"));
+$x->set(array('gna' => 42, 'bar' => array('baz' => array("qux", "quux"))));
+match(
+ $x->to_xml(),
+ 'foo Object ( [gna] => gna Object ( [val] => 42 ) [bar] => bar Object ( [baz] => Array ( [0] => baz Object ( [val] => qux ) [1] => baz Object ( [val] => quux ) ) ) ) ',
+ "Method set()"
+);
+
+?>
--
cgit v1.2.3