diff options
author | John Coggeshall <john@php.net> | 2004-01-03 05:23:24 +0000 |
---|---|---|
committer | John Coggeshall <john@php.net> | 2004-01-03 05:23:24 +0000 |
commit | 4ddb3d194d2780d7477d4bb4ce65f242cce46df4 (patch) | |
tree | df2d80bd0a3dea3cd9b28431cf80d5bacb19c804 /ext/tidy/tests | |
parent | f37c9932ba822106070abd86184c2e303c06e987 (diff) | |
download | php-git-4ddb3d194d2780d7477d4bb4ce65f242cce46df4.tar.gz |
Added examples for tidy v2.0 (in PHP5) and a few more tests..
Diffstat (limited to 'ext/tidy/tests')
-rw-r--r-- | ext/tidy/tests/007.phpt | 5 | ||||
-rw-r--r-- | ext/tidy/tests/008.phpt | 19 | ||||
-rw-r--r-- | ext/tidy/tests/009.phpt | 21 | ||||
-rw-r--r-- | ext/tidy/tests/010.phpt | 248 | ||||
-rw-r--r-- | ext/tidy/tests/011.phpt | 25 | ||||
-rw-r--r-- | ext/tidy/tests/012.phpt | 350 | ||||
-rw-r--r-- | ext/tidy/tests/013.phpt | 350 |
7 files changed, 1018 insertions, 0 deletions
diff --git a/ext/tidy/tests/007.phpt b/ext/tidy/tests/007.phpt index e5015eb3fd..4e7a088763 100644 --- a/ext/tidy/tests/007.phpt +++ b/ext/tidy/tests/007.phpt @@ -23,6 +23,9 @@ tidy.default_config= $a->setopt("tab-size", 10); echo "\nNew Value of 'tab-size': "; var_dump($a->getopt("tab-size")); + tidy_setopt($a, "tab-size", 12); + echo "\nNew Value of 'tab-size': "; + var_dump(tidy_getopt($a, "tab-size")); } else { echo "Current Value of 'tidy-mark': "; var_dump(tidy_getopt("tidy-mark")); @@ -51,3 +54,5 @@ New Value of 'error-file': string(6) "foobar" Current Value of 'tab-size': int(8) New Value of 'tab-size': int(10) + +New Value of 'tab-size': int(12) diff --git a/ext/tidy/tests/008.phpt b/ext/tidy/tests/008.phpt new file mode 100644 index 0000000000..2896514726 --- /dev/null +++ b/ext/tidy/tests/008.phpt @@ -0,0 +1,19 @@ +--TEST-- +Accessing the error buffer via $obj->error_buf... +--SKIPIF-- +<?php if (!extension_loaded("tidy") || !class_exists("tidy_doc")) print "skip"; ?> +--POST-- +--GET-- +--INI-- +--FILE-- +<?php + $a = tidy_parse_string("<HTML><asd asdf></HTML>"); + echo $a->error_buf; + +?> +--EXPECT-- +line 1 column 1 - Warning: missing <!DOCTYPE> declaration +line 1 column 7 - Error: <asd> is not recognized! +line 1 column 7 - Warning: discarding unexpected <asd> +line 1 column 17 - Warning: discarding unexpected </html> +line 1 column 7 - Warning: inserting missing 'title' element
\ No newline at end of file diff --git a/ext/tidy/tests/009.phpt b/ext/tidy/tests/009.phpt new file mode 100644 index 0000000000..7c04b81a9e --- /dev/null +++ b/ext/tidy/tests/009.phpt @@ -0,0 +1,21 @@ +--TEST-- +tidy_doc object overloading +--SKIPIF-- +<?php if (!extension_loaded("tidy") || !class_exists("tidy_doc")) print "skip"; ?> +--POST-- +--GET-- +--INI-- +--FILE-- +<?php + $a = tidy_parse_string("<HTML></HTML>"); + echo $a; + +?> +--EXPECT-- +<html> +<head> +<title></title> +</head> +<body> +</body> +</html>
\ No newline at end of file diff --git a/ext/tidy/tests/010.phpt b/ext/tidy/tests/010.phpt new file mode 100644 index 0000000000..0d38f9df60 --- /dev/null +++ b/ext/tidy/tests/010.phpt @@ -0,0 +1,248 @@ +--TEST-- +Accessing root, body, html, and head nodes.. +--SKIPIF-- +<?php if (!extension_loaded("tidy") || !class_exists("tidy_doc")) print "skip"; ?> +--POST-- +--GET-- +--INI-- +--FILE-- +<?php + $a = tidy_parse_string("<HTML><BODY BGCOLOR=#FFFFFF ALINK=#000000></BODY></HTML>"); + var_dump($a->root()); + var_dump($a->body()); + var_dump($a->html()); + var_dump($a->head()); + +?> +--EXPECT-- +object(tidy_node)#2 (5) { + ["value"]=> + string(94) "<html> +<head> +<title></title> +</head> +<body bgcolor="#FFFFFF" alink="#000000"> +</body> +</html>" + ["name"]=> + string(0) "" + ["type"]=> + int(0) + ["attribute"]=> + NULL + ["child"]=> + array(1) { + [0]=> + &object(tidy_node)#3 (6) { + ["value"]=> + string(94) "<html> +<head> +<title></title> +</head> +<body bgcolor="#FFFFFF" alink="#000000"> +</body> +</html>" + ["name"]=> + string(4) "html" + ["type"]=> + int(5) + ["id"]=> + int(48) + ["attribute"]=> + NULL + ["child"]=> + array(2) { + [0]=> + &object(tidy_node)#4 (6) { + ["value"]=> + string(31) "<head> +<title></title> +</head> +" + ["name"]=> + string(4) "head" + ["type"]=> + int(5) + ["id"]=> + int(46) + ["attribute"]=> + NULL + ["child"]=> + array(1) { + [0]=> + &object(tidy_node)#5 (6) { + ["value"]=> + string(16) "<title></title> +" + ["name"]=> + string(5) "title" + ["type"]=> + int(5) + ["id"]=> + int(111) + ["attribute"]=> + NULL + ["child"]=> + NULL + } + } + } + [1]=> + &object(tidy_node)#6 (6) { + ["value"]=> + string(49) "<body bgcolor="#FFFFFF" alink="#000000"> +</body> +" + ["name"]=> + string(4) "body" + ["type"]=> + int(5) + ["id"]=> + int(16) + ["attribute"]=> + array(2) { + ["bgcolor"]=> + string(7) "#FFFFFF" + ["alink"]=> + string(7) "#000000" + } + ["child"]=> + NULL + } + } + } + } +} +object(tidy_node)#2 (6) { + ["value"]=> + string(49) "<body bgcolor="#FFFFFF" alink="#000000"> +</body> +" + ["name"]=> + string(4) "body" + ["type"]=> + int(5) + ["id"]=> + int(16) + ["attribute"]=> + array(2) { + ["bgcolor"]=> + string(7) "#FFFFFF" + ["alink"]=> + string(7) "#000000" + } + ["child"]=> + NULL +} +object(tidy_node)#2 (6) { + ["value"]=> + string(94) "<html> +<head> +<title></title> +</head> +<body bgcolor="#FFFFFF" alink="#000000"> +</body> +</html>" + ["name"]=> + string(4) "html" + ["type"]=> + int(5) + ["id"]=> + int(48) + ["attribute"]=> + NULL + ["child"]=> + array(2) { + [0]=> + &object(tidy_node)#3 (6) { + ["value"]=> + string(31) "<head> +<title></title> +</head> +" + ["name"]=> + string(4) "head" + ["type"]=> + int(5) + ["id"]=> + int(46) + ["attribute"]=> + NULL + ["child"]=> + array(1) { + [0]=> + &object(tidy_node)#6 (6) { + ["value"]=> + string(16) "<title></title> +" + ["name"]=> + string(5) "title" + ["type"]=> + int(5) + ["id"]=> + int(111) + ["attribute"]=> + NULL + ["child"]=> + NULL + } + } + } + [1]=> + &object(tidy_node)#4 (6) { + ["value"]=> + string(49) "<body bgcolor="#FFFFFF" alink="#000000"> +</body> +" + ["name"]=> + string(4) "body" + ["type"]=> + int(5) + ["id"]=> + int(16) + ["attribute"]=> + array(2) { + ["bgcolor"]=> + string(7) "#FFFFFF" + ["alink"]=> + string(7) "#000000" + } + ["child"]=> + NULL + } + } +} +object(tidy_node)#2 (6) { + ["value"]=> + string(31) "<head> +<title></title> +</head> +" + ["name"]=> + string(4) "head" + ["type"]=> + int(5) + ["id"]=> + int(46) + ["attribute"]=> + NULL + ["child"]=> + array(1) { + [0]=> + &object(tidy_node)#4 (6) { + ["value"]=> + string(16) "<title></title> +" + ["name"]=> + string(5) "title" + ["type"]=> + int(5) + ["id"]=> + int(111) + ["attribute"]=> + NULL + ["child"]=> + NULL + } + } +} diff --git a/ext/tidy/tests/011.phpt b/ext/tidy/tests/011.phpt new file mode 100644 index 0000000000..223da8500c --- /dev/null +++ b/ext/tidy/tests/011.phpt @@ -0,0 +1,25 @@ +--TEST-- +Accessing attributes of a node +--SKIPIF-- +<?php if (!extension_loaded("tidy") || !class_exists("tidy_doc")) print "skip"; ?> +--POST-- +--GET-- +--INI-- +--FILE-- +<?php + $a = tidy_parse_string("<HTML><BODY BGCOLOR=#FFFFFF ALINK=#000000></BODY></HTML>"); + $body = $a->body(); + var_dump($body->attribute); + foreach($body->attribute as $key=>$val) { + echo "Attrib '$key': $val\n"; + } +?> +--EXPECT-- +array(2) { + ["bgcolor"]=> + string(7) "#FFFFFF" + ["alink"]=> + string(7) "#000000" +} +Attrib 'bgcolor': #FFFFFF +Attrib 'alink': #000000
\ No newline at end of file diff --git a/ext/tidy/tests/012.phpt b/ext/tidy/tests/012.phpt new file mode 100644 index 0000000000..013cb1fd0d --- /dev/null +++ b/ext/tidy/tests/012.phpt @@ -0,0 +1,350 @@ +--TEST-- +Accessing children nodes +--SKIPIF-- +<?php if (!extension_loaded("tidy") || !class_exists("tidy_doc")) print "skip"; ?> +--POST-- +--GET-- +--INI-- +--FILE-- +<?php + + function dump_nodes(tidy_node $node) { + + var_dump($node->has_children()); + if($node->has_children()) { + + foreach($node->child as $c) { + + var_dump($c); + + if($c->has_children()) { + + dump_nodes($c); + + } + } + + } + + } + + $a = tidy_parse_string("<HTML><BODY BGCOLOR=#FFFFFF ALINK=#000000><B>Hi</B><I>Bye<U>Test</U></I></BODY></HTML>"); + $html = $a->html(); + dump_nodes($html); + +?> +--EXPECT-- +bool(true) +object(tidy_node)#3 (6) { + ["value"]=> + string(31) "<head> +<title></title> +</head> +" + ["name"]=> + string(4) "head" + ["type"]=> + int(5) + ["id"]=> + int(46) + ["attribute"]=> + NULL + ["child"]=> + array(1) { + [0]=> + &object(tidy_node)#4 (6) { + ["value"]=> + string(16) "<title></title> +" + ["name"]=> + string(5) "title" + ["type"]=> + int(5) + ["id"]=> + int(111) + ["attribute"]=> + NULL + ["child"]=> + NULL + } + } +} +bool(true) +object(tidy_node)#4 (6) { + ["value"]=> + string(16) "<title></title> +" + ["name"]=> + string(5) "title" + ["type"]=> + int(5) + ["id"]=> + int(111) + ["attribute"]=> + NULL + ["child"]=> + NULL +} +object(tidy_node)#5 (6) { + ["value"]=> + string(80) "<body bgcolor="#FFFFFF" alink="#000000"> +<b>Hi</b><i>Bye<u>Test</u></i> +</body> +" + ["name"]=> + string(4) "body" + ["type"]=> + int(5) + ["id"]=> + int(16) + ["attribute"]=> + array(2) { + ["bgcolor"]=> + string(7) "#FFFFFF" + ["alink"]=> + string(7) "#000000" + } + ["child"]=> + array(2) { + [0]=> + &object(tidy_node)#6 (6) { + ["value"]=> + string(9) "<b>Hi</b>" + ["name"]=> + string(1) "b" + ["type"]=> + int(5) + ["id"]=> + int(8) + ["attribute"]=> + NULL + ["child"]=> + array(1) { + [0]=> + &object(tidy_node)#7 (5) { + ["value"]=> + string(2) "Hi" + ["name"]=> + string(0) "" + ["type"]=> + int(4) + ["attribute"]=> + NULL + ["child"]=> + NULL + } + } + } + [1]=> + &object(tidy_node)#8 (6) { + ["value"]=> + string(21) "<i>Bye<u>Test</u></i>" + ["name"]=> + string(1) "i" + ["type"]=> + int(5) + ["id"]=> + int(49) + ["attribute"]=> + NULL + ["child"]=> + array(2) { + [0]=> + &object(tidy_node)#9 (5) { + ["value"]=> + string(3) "Bye" + ["name"]=> + string(0) "" + ["type"]=> + int(4) + ["attribute"]=> + NULL + ["child"]=> + NULL + } + [1]=> + &object(tidy_node)#10 (6) { + ["value"]=> + string(11) "<u>Test</u>" + ["name"]=> + string(1) "u" + ["type"]=> + int(5) + ["id"]=> + int(114) + ["attribute"]=> + NULL + ["child"]=> + array(1) { + [0]=> + &object(tidy_node)#11 (5) { + ["value"]=> + string(4) "Test" + ["name"]=> + string(0) "" + ["type"]=> + int(4) + ["attribute"]=> + NULL + ["child"]=> + NULL + } + } + } + } + } + } +} +bool(true) +object(tidy_node)#6 (6) { + ["value"]=> + string(9) "<b>Hi</b>" + ["name"]=> + string(1) "b" + ["type"]=> + int(5) + ["id"]=> + int(8) + ["attribute"]=> + NULL + ["child"]=> + array(1) { + [0]=> + &object(tidy_node)#7 (5) { + ["value"]=> + string(2) "Hi" + ["name"]=> + string(0) "" + ["type"]=> + int(4) + ["attribute"]=> + NULL + ["child"]=> + NULL + } + } +} +bool(true) +object(tidy_node)#7 (5) { + ["value"]=> + string(2) "Hi" + ["name"]=> + string(0) "" + ["type"]=> + int(4) + ["attribute"]=> + NULL + ["child"]=> + NULL +} +object(tidy_node)#8 (6) { + ["value"]=> + string(21) "<i>Bye<u>Test</u></i>" + ["name"]=> + string(1) "i" + ["type"]=> + int(5) + ["id"]=> + int(49) + ["attribute"]=> + NULL + ["child"]=> + array(2) { + [0]=> + &object(tidy_node)#9 (5) { + ["value"]=> + string(3) "Bye" + ["name"]=> + string(0) "" + ["type"]=> + int(4) + ["attribute"]=> + NULL + ["child"]=> + NULL + } + [1]=> + &object(tidy_node)#10 (6) { + ["value"]=> + string(11) "<u>Test</u>" + ["name"]=> + string(1) "u" + ["type"]=> + int(5) + ["id"]=> + int(114) + ["attribute"]=> + NULL + ["child"]=> + array(1) { + [0]=> + &object(tidy_node)#11 (5) { + ["value"]=> + string(4) "Test" + ["name"]=> + string(0) "" + ["type"]=> + int(4) + ["attribute"]=> + NULL + ["child"]=> + NULL + } + } + } + } +} +bool(true) +object(tidy_node)#9 (5) { + ["value"]=> + string(3) "Bye" + ["name"]=> + string(0) "" + ["type"]=> + int(4) + ["attribute"]=> + NULL + ["child"]=> + NULL +} +object(tidy_node)#10 (6) { + ["value"]=> + string(11) "<u>Test</u>" + ["name"]=> + string(1) "u" + ["type"]=> + int(5) + ["id"]=> + int(114) + ["attribute"]=> + NULL + ["child"]=> + array(1) { + [0]=> + &object(tidy_node)#11 (5) { + ["value"]=> + string(4) "Test" + ["name"]=> + string(0) "" + ["type"]=> + int(4) + ["attribute"]=> + NULL + ["child"]=> + NULL + } + } +} +bool(true) +object(tidy_node)#11 (5) { + ["value"]=> + string(4) "Test" + ["name"]=> + string(0) "" + ["type"]=> + int(4) + ["attribute"]=> + NULL + ["child"]=> + NULL +} diff --git a/ext/tidy/tests/013.phpt b/ext/tidy/tests/013.phpt new file mode 100644 index 0000000000..013cb1fd0d --- /dev/null +++ b/ext/tidy/tests/013.phpt @@ -0,0 +1,350 @@ +--TEST-- +Accessing children nodes +--SKIPIF-- +<?php if (!extension_loaded("tidy") || !class_exists("tidy_doc")) print "skip"; ?> +--POST-- +--GET-- +--INI-- +--FILE-- +<?php + + function dump_nodes(tidy_node $node) { + + var_dump($node->has_children()); + if($node->has_children()) { + + foreach($node->child as $c) { + + var_dump($c); + + if($c->has_children()) { + + dump_nodes($c); + + } + } + + } + + } + + $a = tidy_parse_string("<HTML><BODY BGCOLOR=#FFFFFF ALINK=#000000><B>Hi</B><I>Bye<U>Test</U></I></BODY></HTML>"); + $html = $a->html(); + dump_nodes($html); + +?> +--EXPECT-- +bool(true) +object(tidy_node)#3 (6) { + ["value"]=> + string(31) "<head> +<title></title> +</head> +" + ["name"]=> + string(4) "head" + ["type"]=> + int(5) + ["id"]=> + int(46) + ["attribute"]=> + NULL + ["child"]=> + array(1) { + [0]=> + &object(tidy_node)#4 (6) { + ["value"]=> + string(16) "<title></title> +" + ["name"]=> + string(5) "title" + ["type"]=> + int(5) + ["id"]=> + int(111) + ["attribute"]=> + NULL + ["child"]=> + NULL + } + } +} +bool(true) +object(tidy_node)#4 (6) { + ["value"]=> + string(16) "<title></title> +" + ["name"]=> + string(5) "title" + ["type"]=> + int(5) + ["id"]=> + int(111) + ["attribute"]=> + NULL + ["child"]=> + NULL +} +object(tidy_node)#5 (6) { + ["value"]=> + string(80) "<body bgcolor="#FFFFFF" alink="#000000"> +<b>Hi</b><i>Bye<u>Test</u></i> +</body> +" + ["name"]=> + string(4) "body" + ["type"]=> + int(5) + ["id"]=> + int(16) + ["attribute"]=> + array(2) { + ["bgcolor"]=> + string(7) "#FFFFFF" + ["alink"]=> + string(7) "#000000" + } + ["child"]=> + array(2) { + [0]=> + &object(tidy_node)#6 (6) { + ["value"]=> + string(9) "<b>Hi</b>" + ["name"]=> + string(1) "b" + ["type"]=> + int(5) + ["id"]=> + int(8) + ["attribute"]=> + NULL + ["child"]=> + array(1) { + [0]=> + &object(tidy_node)#7 (5) { + ["value"]=> + string(2) "Hi" + ["name"]=> + string(0) "" + ["type"]=> + int(4) + ["attribute"]=> + NULL + ["child"]=> + NULL + } + } + } + [1]=> + &object(tidy_node)#8 (6) { + ["value"]=> + string(21) "<i>Bye<u>Test</u></i>" + ["name"]=> + string(1) "i" + ["type"]=> + int(5) + ["id"]=> + int(49) + ["attribute"]=> + NULL + ["child"]=> + array(2) { + [0]=> + &object(tidy_node)#9 (5) { + ["value"]=> + string(3) "Bye" + ["name"]=> + string(0) "" + ["type"]=> + int(4) + ["attribute"]=> + NULL + ["child"]=> + NULL + } + [1]=> + &object(tidy_node)#10 (6) { + ["value"]=> + string(11) "<u>Test</u>" + ["name"]=> + string(1) "u" + ["type"]=> + int(5) + ["id"]=> + int(114) + ["attribute"]=> + NULL + ["child"]=> + array(1) { + [0]=> + &object(tidy_node)#11 (5) { + ["value"]=> + string(4) "Test" + ["name"]=> + string(0) "" + ["type"]=> + int(4) + ["attribute"]=> + NULL + ["child"]=> + NULL + } + } + } + } + } + } +} +bool(true) +object(tidy_node)#6 (6) { + ["value"]=> + string(9) "<b>Hi</b>" + ["name"]=> + string(1) "b" + ["type"]=> + int(5) + ["id"]=> + int(8) + ["attribute"]=> + NULL + ["child"]=> + array(1) { + [0]=> + &object(tidy_node)#7 (5) { + ["value"]=> + string(2) "Hi" + ["name"]=> + string(0) "" + ["type"]=> + int(4) + ["attribute"]=> + NULL + ["child"]=> + NULL + } + } +} +bool(true) +object(tidy_node)#7 (5) { + ["value"]=> + string(2) "Hi" + ["name"]=> + string(0) "" + ["type"]=> + int(4) + ["attribute"]=> + NULL + ["child"]=> + NULL +} +object(tidy_node)#8 (6) { + ["value"]=> + string(21) "<i>Bye<u>Test</u></i>" + ["name"]=> + string(1) "i" + ["type"]=> + int(5) + ["id"]=> + int(49) + ["attribute"]=> + NULL + ["child"]=> + array(2) { + [0]=> + &object(tidy_node)#9 (5) { + ["value"]=> + string(3) "Bye" + ["name"]=> + string(0) "" + ["type"]=> + int(4) + ["attribute"]=> + NULL + ["child"]=> + NULL + } + [1]=> + &object(tidy_node)#10 (6) { + ["value"]=> + string(11) "<u>Test</u>" + ["name"]=> + string(1) "u" + ["type"]=> + int(5) + ["id"]=> + int(114) + ["attribute"]=> + NULL + ["child"]=> + array(1) { + [0]=> + &object(tidy_node)#11 (5) { + ["value"]=> + string(4) "Test" + ["name"]=> + string(0) "" + ["type"]=> + int(4) + ["attribute"]=> + NULL + ["child"]=> + NULL + } + } + } + } +} +bool(true) +object(tidy_node)#9 (5) { + ["value"]=> + string(3) "Bye" + ["name"]=> + string(0) "" + ["type"]=> + int(4) + ["attribute"]=> + NULL + ["child"]=> + NULL +} +object(tidy_node)#10 (6) { + ["value"]=> + string(11) "<u>Test</u>" + ["name"]=> + string(1) "u" + ["type"]=> + int(5) + ["id"]=> + int(114) + ["attribute"]=> + NULL + ["child"]=> + array(1) { + [0]=> + &object(tidy_node)#11 (5) { + ["value"]=> + string(4) "Test" + ["name"]=> + string(0) "" + ["type"]=> + int(4) + ["attribute"]=> + NULL + ["child"]=> + NULL + } + } +} +bool(true) +object(tidy_node)#11 (5) { + ["value"]=> + string(4) "Test" + ["name"]=> + string(0) "" + ["type"]=> + int(4) + ["attribute"]=> + NULL + ["child"]=> + NULL +} |