diff options
author | Christian Schneider | 2007-10-11 00:39:30 +0000 |
---|---|---|
committer | Christian Schneider | 2007-10-11 00:39:30 +0000 |
commit | 35fe33f7364329dacf415c950bff01b6de9ef88e (patch) | |
tree | b0e6b018b50038ca20266723c53750268f508df5 /tests/it_html.t | |
parent | 1f95711ff3e9697cd85a54545ab42e5fd3611317 (diff) | |
download | itools-35fe33f7364329dacf415c950bff01b6de9ef88e.tar.gz itools-35fe33f7364329dacf415c950bff01b6de9ef88e.tar.bz2 itools-35fe33f7364329dacf415c950bff01b6de9ef88e.zip |
Populated release branch
Diffstat (limited to 'tests/it_html.t')
-rwxr-xr-x | tests/it_html.t | 99 |
1 files changed, 99 insertions, 0 deletions
diff --git a/tests/it_html.t b/tests/it_html.t new file mode 100755 index 0000000..cd934be --- /dev/null +++ b/tests/it_html.t @@ -0,0 +1,99 @@ +#!/www/server/bin/php -qC +<?php + +# Tests for html.class + +require 'searchlib/search_test.class'; + +# Traditional html generation +new it_html(array('htmltype' => "html")); + +is( + a(array('href' => "&foo", 'true' => true, 'false' => false, 'null' => null, 'empty' => ""), "bar"), + '<a href="&foo" true empty="">bar</a>', + "tag with attributes" +); + +is( + div(), + "<div></div>\n", + "empty script tag" +); + +is( + img(array('src' => "foo.png")), + '<img src="foo.png">', + "empty link tag" +); + +is( + tag('link'), + "<link>\n", + "empty link tag" +); + +is( + tag('link', "foo"), + "<link>foo</link>\n", + "link tag with data" +); + +# XML generation +unset($GLOBALS['it_html']); +new it_html(array('htmltype' => "xhtml", 'tags' => "xmltest")); + +is( + xmltest(), + "<xmltest />\n", + "empty xmltest tag" +); + +is( + xmltest("foo"), + "<xmltest>foo</xmltest>\n", + "empty xmltest tag" +); + +is( + xmltest(array('href' => "&foo", 'true' => true, 'false' => false, 'null' => null, 'empty' => "")), + '<xmltest href="&foo" true="true" empty="" />' . "\n", + "xmltest tag with attributes" +); + +# Inheriting and extending it_html +class myhtml extends it_html +{ +function myimg($args) +{ + array_unshift($args, array('alt' => "ALT", 'bar' => "BAR")); + + return parent::img($args); +} +} + +unset($GLOBALS['it_html']); +new myhtml(array('htmltype' => "html")); + +is( + myimg(array('src' => "foo.gif", 'alt' => "foo")), + '<img alt="foo" bar="BAR" src="foo.gif">', + "it_html inheritance" +); + +is( + it_html::sanitize(' <p><a href="http://www.flickr.com/people/swisspics/">swisspics</a> posted < < ä & yesterday <b>a <i>photo</i></b> <b><i>tag missmatch</b></i>:</p><br><br /> + +<p><a href="javascript:window.close()" title="Wolken"><img src="http://farm1.static.flickr.com/177/377214376_bcba167a7d_m.jpg" width="240" height="180" alt="Wolken" style="border: 1px solid #ddd;" /></a></p> +'), + ' <a href="http://www.flickr.com/people/swisspics/">swisspics</a> posted < < ä & yesterday a <i>photo</i> <i>tag missmatch</i>:<br /><br /> <p><img src="http://farm1.static.flickr.com/177/377214376_bcba167a7d_m.jpg" alt="" /></p> ', + 'it_html::sanitize tag soup' +); + +is( + U("/foo.html", array('bar' => array('gna' => 42, 'qux' => array('quux' => "<Zürich>", 'gnöp' => "fasel")))), + '/foo.html?bar[gna]=42&bar[qux][quux]=%3CZ%FCrich%3E&bar[qux][gn%F6p]=fasel', + 'U() with nested arrays' +); + + +?> |