diff options
author | Christian Schneider | 2007-02-08 14:51:25 +0000 |
---|---|---|
committer | Christian Schneider | 2007-02-08 14:51:25 +0000 |
commit | 6943a9f3bc10a60fcc01f126dfbd22b24b9c99cb (patch) | |
tree | 7115430bdc88c9a05788b560cf0d58d62807d8f3 /tests/it_xml.t | |
parent | e49941bbff3f9d7e87e26265b9971c788b861628 (diff) | |
download | itools-6943a9f3bc10a60fcc01f126dfbd22b24b9c99cb.tar.gz itools-6943a9f3bc10a60fcc01f126dfbd22b24b9c99cb.tar.bz2 itools-6943a9f3bc10a60fcc01f126dfbd22b24b9c99cb.zip |
Moved ITools tests from searchlib to itools/live
Diffstat (limited to 'tests/it_xml.t')
-rwxr-xr-x | tests/it_xml.t | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/tests/it_xml.t b/tests/it_xml.t new file mode 100755 index 0000000..06df969 --- /dev/null +++ b/tests/it_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->properbaseclass = is_a($this->myfoo, "my_xml"); +} + +} + +match( + '<myfoo />', + 'class myfoo { var $properbaseclass = true; }', + 'Inheritance and constructor', + 'my' +); + +?> |