diff options
author | Urban Müller | 2007-07-26 13:02:24 +0000 |
---|---|---|
committer | Urban Müller | 2007-07-26 13:02:24 +0000 |
commit | 806a5297e7e99d455b97a4f0acaba2f40f470584 (patch) | |
tree | b9fc43ef227da87d873cf3676c08c49fa0dc1240 /tests/it_xml.t | |
parent | c3cba034c8009b65c25dd4ef5f54b18d9c8ee7d4 (diff) | |
download | itools-806a5297e7e99d455b97a4f0acaba2f40f470584.tar.gz itools-806a5297e7e99d455b97a4f0acaba2f40f470584.tar.bz2 itools-806a5297e7e99d455b97a4f0acaba2f40f470584.zip |
renamed files for autoloader
Diffstat (limited to 'tests/it_xml.t')
-rwxr-xr-x | tests/it_xml.t | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/tests/it_xml.t b/tests/it_xml.t new file mode 100755 index 0000000..5d652cc --- /dev/null +++ b/tests/it_xml.t @@ -0,0 +1,70 @@ +#!/www/server/bin/php -qC +<?php + +# Tests for 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]+/', " ", print_r($xml->$varname, true)), + $expected, + $name, + ); +} + +match( + '<foo />', + 'foo Object ( ) ', + 'empty tag' +); + +match( + '<foo /><foo />', + 'Array ( [0] => foo Object ( ) [1] => foo Object ( ) ) ', + 'multiple empty tags converted to array' +); + +match( + '<foo title="Zürich">Stüssihofstadt</foo>', + 'foo Object ( [attr] => Array ( [title] => Zürich ) [val] => Stüssihofstadt ) ', + 'simple tag with latin1 content and attribute' +); + +match( + '<foo><ns:a.b.-c ns2:d.e-f="value" /></foo>', + 'foo Object ( [a_b__c] => a_b__c Object ( [attr] => Array ( [d_e_f] => value ) ) ) ', + 'Tags and attributes with name space and special characters' +); + +# 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 />', + 'myfoo Object ( [inheritbaseclass] => ) ', + 'Inheritance and constructor (critical for e.g. tel_xmlentry)', + 'my' +); + +?> |