summaryrefslogtreecommitdiff
path: root/tests/xml.t
diff options
context:
space:
mode:
authorChristian Schneider2007-02-09 13:26:17 +0000
committerChristian Schneider2007-02-09 13:26:17 +0000
commitbbc8b31566fcae832081f1d890dfa6fd5c5c842a (patch)
treec9df6eaf5a193b4a9d622356c189567b4652f37c /tests/xml.t
parent0b9f19b72396d8bd399f4d7353f2fdb445bc55f3 (diff)
downloaditools-bbc8b31566fcae832081f1d890dfa6fd5c5c842a.tar.gz
itools-bbc8b31566fcae832081f1d890dfa6fd5c5c842a.tar.bz2
itools-bbc8b31566fcae832081f1d890dfa6fd5c5c842a.zip
Renamed tests to match file names of class tested
Diffstat (limited to 'tests/xml.t')
-rwxr-xr-xtests/xml.t66
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/xml.t b/tests/xml.t
new file mode 100755
index 0000000..85f16c8
--- /dev/null
+++ b/tests/xml.t
@@ -0,0 +1,66 @@
+#!/www/server/bin/php -qC
+<?php
+#
+# $Id$
+#
+# Tests for itools/xml.class
+
+require 'searchlib/search_test.class';
+
+function match($xmldata, $expected, $name, $prefix = "")
+{
+ $classname = $prefix ? ($prefix . "_xml") : "it_xml";
+ $varname = $prefix . "foo";
+ $xml = new $classname("<root>$xmldata</root>");
+
+ is(
+ preg_replace('/[#\s]+/', " ", search_test::dump($xml->$varname)),
+ $expected,
+ $name,
+ );
+}
+
+match(
+ '<foo />',
+ 'class foo { }',
+ 'empty tag'
+);
+
+#match(
+# '<foo /><foo />',
+# 'array ( 0 => class foo { }, 1 => class foo { }, )',
+# 'multiple empty tags converted to array'
+#);
+
+match(
+ '<foo title="Zürich">Stüssihofstadt</foo>',
+ 'class foo { var $attr = array( \'title\' => \'Zürich\' ); var $val = \'Stüssihofstadt\'; }',
+ 'simple tag with latin1 content and attribute'
+);
+
+# 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 />',
+ 'class myfoo { var $inheritbaseclass = false; }',
+ 'Inheritance and constructor (critical for e.g. tel_xmlentry)',
+ 'my'
+);
+
+?>