diff options
Diffstat (limited to 'ext/tidy/tests')
45 files changed, 1687 insertions, 0 deletions
diff --git a/ext/tidy/tests/001.phpt b/ext/tidy/tests/001.phpt new file mode 100644 index 0000000..bfd3782 --- /dev/null +++ b/ext/tidy/tests/001.phpt @@ -0,0 +1,10 @@ +--TEST-- +Check for tidy presence +--SKIPIF-- +<?php if (!extension_loaded("tidy")) print "skip"; ?> +--FILE-- +<?php +echo "tidy extension is available"; +?> +--EXPECT-- +tidy extension is available diff --git a/ext/tidy/tests/002.phpt b/ext/tidy/tests/002.phpt new file mode 100644 index 0000000..89c3804 --- /dev/null +++ b/ext/tidy/tests/002.phpt @@ -0,0 +1,18 @@ +--TEST-- +tidy_parse_string() +--SKIPIF-- +<?php if (!extension_loaded("tidy")) print "skip"; ?> +--FILE-- +<?php + $a = tidy_parse_string("<HTML></HTML>"); + echo tidy_get_output($a); + +?> +--EXPECT-- +<html> +<head> +<title></title> +</head> +<body> +</body> +</html>
\ No newline at end of file diff --git a/ext/tidy/tests/003.phpt b/ext/tidy/tests/003.phpt new file mode 100644 index 0000000..7201d6a --- /dev/null +++ b/ext/tidy/tests/003.phpt @@ -0,0 +1,21 @@ +--TEST-- +tidy_clean_repair() +--SKIPIF-- +<?php if (!extension_loaded("tidy")) print "skip"; ?> +--FILE-- +<?php + + $a = tidy_parse_string("<HTML></HTML>"); + tidy_clean_repair($a); + echo tidy_get_output($a); + +?> +--EXPECT-- +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN"> +<html> +<head> +<title></title> +</head> +<body> +</body> +</html> diff --git a/ext/tidy/tests/004.phpt b/ext/tidy/tests/004.phpt new file mode 100644 index 0000000..d13c37d --- /dev/null +++ b/ext/tidy/tests/004.phpt @@ -0,0 +1,31 @@ +--TEST-- +tidy_diagnose() +--SKIPIF-- +<?php if (!extension_loaded("tidy")) print "skip"; ?> +--FILE-- +<?php +$a = tidy_parse_string('<HTML></HTML>'); +var_dump(tidy_diagnose($a)); +echo str_replace("\r", "", tidy_get_error_buffer($a)); + +$html = <<< HTML +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN"> +<html> +<head><title>foo</title></head> +<body><p>hello</p></body> +</html> +HTML; +$a = tidy_parse_string($html); +var_dump(tidy_diagnose($a)); +echo tidy_get_error_buffer($a); +?> +--EXPECT-- +bool(true) +line 1 column 1 - Warning: missing <!DOCTYPE> declaration +line 1 column 7 - Warning: discarding unexpected </html> +line 1 column 14 - Warning: inserting missing 'title' element +Info: Document content looks like HTML 3.2 +3 warnings, 0 errors were found! +bool(true) +Info: Document content looks like HTML 3.2 +No warnings or errors were found. diff --git a/ext/tidy/tests/005.html b/ext/tidy/tests/005.html new file mode 100644 index 0000000..8c17451 --- /dev/null +++ b/ext/tidy/tests/005.html @@ -0,0 +1 @@ +<HTML></HTML> diff --git a/ext/tidy/tests/005.phpt b/ext/tidy/tests/005.phpt new file mode 100644 index 0000000..1d3a10c --- /dev/null +++ b/ext/tidy/tests/005.phpt @@ -0,0 +1,18 @@ +--TEST-- +tidy_parse_file() +--SKIPIF-- +<?php if (!extension_loaded("tidy")) print "skip"; ?> +--FILE-- +<?php + $a = tidy_parse_file(dirname(__FILE__)."/005.html"); + echo tidy_get_output($a); + +?> +--EXPECT-- +<html> +<head> +<title></title> +</head> +<body> +</body> +</html>
\ No newline at end of file diff --git a/ext/tidy/tests/006.phpt b/ext/tidy/tests/006.phpt new file mode 100644 index 0000000..c826181 --- /dev/null +++ b/ext/tidy/tests/006.phpt @@ -0,0 +1,16 @@ +--TEST-- +Verbose tidy_get_error_buffer() +--SKIPIF-- +<?php if (!extension_loaded("tidy")) print "skip"; ?> +--FILE-- +<?php + $a = tidy_parse_string("<HTML><asd asdf></HTML>"); + echo tidy_get_error_buffer($a); + +?> +--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/007.html b/ext/tidy/tests/007.html new file mode 100644 index 0000000..7dc0357 --- /dev/null +++ b/ext/tidy/tests/007.html @@ -0,0 +1 @@ +<B>testing</I> diff --git a/ext/tidy/tests/007.phpt b/ext/tidy/tests/007.phpt new file mode 100644 index 0000000..f6bb13d --- /dev/null +++ b/ext/tidy/tests/007.phpt @@ -0,0 +1,29 @@ +--TEST-- +Verbose tidy_getopt() +--SKIPIF-- +<?php if (!extension_loaded("tidy")) print "skip"; ?> +--INI-- +tidy.default_config= +--FILE-- +<?php + $a = new tidy(dirname(__FILE__)."/007.html"); + echo "Current Value of 'tidy-mark': "; + var_dump($a->getopt("tidy-mark")); + echo "Current Value of 'error-file': "; + var_dump($a->getopt("error-file")); + echo "Current Value of 'tab-size': "; + var_dump($a->getopt("tab-size")); + + var_dump($a->getopt('bogus-opt')); + var_dump(tidy_getopt($a, 'non-ASCII string àáç')); +?> +--EXPECTF-- +Current Value of 'tidy-mark': bool(false) +Current Value of 'error-file': string(0) "" +Current Value of 'tab-size': int(8) + +Warning: tidy::getOpt(): Unknown Tidy Configuration Option 'bogus-opt' in %s007.php on line 10 +bool(false) + +Warning: tidy_getopt(): Unknown Tidy Configuration Option 'non-ASCII string àáç' in %s007.php on line 11 +bool(false) diff --git a/ext/tidy/tests/008.phpt b/ext/tidy/tests/008.phpt new file mode 100644 index 0000000..150b98f --- /dev/null +++ b/ext/tidy/tests/008.phpt @@ -0,0 +1,15 @@ +--TEST-- +Accessing the error buffer via $obj->error_buf... +--SKIPIF-- +<?php if (!extension_loaded("tidy")) print "skip"; ?> +--FILE-- +<?php + $a = tidy_parse_string("<HTML><asd asdf></HTML>"); + echo $a->errorBuffer; +?> +--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 0000000..02c65df --- /dev/null +++ b/ext/tidy/tests/009.phpt @@ -0,0 +1,19 @@ +--TEST-- +tidy_doc object overloading +--SKIPIF-- +<?php if (!extension_loaded("tidy")) print "skip"; ?> +--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 0000000..9d5ab82 --- /dev/null +++ b/ext/tidy/tests/010.phpt @@ -0,0 +1,317 @@ +--TEST-- +Accessing root, body, html, and head nodes.. +--SKIPIF-- +<?php if (!extension_loaded("tidy")) print "skip"; ?> +--FILE-- +<?php +$a = tidy_parse_string("<HTML><BODY BGCOLOR=#FFFFFF ALINK=#000000></BODY></HTML>", array('newline' => 'LF')); +var_dump($a->root()); +var_dump($a->body()); +var_dump($a->html()); +var_dump($a->head()); + +?> +--EXPECT-- +object(tidyNode)#2 (8) { + ["value"]=> + string(94) "<html> +<head> +<title></title> +</head> +<body bgcolor="#FFFFFF" alink="#000000"> +</body> +</html>" + ["name"]=> + string(0) "" + ["type"]=> + int(0) + ["line"]=> + int(1) + ["column"]=> + int(1) + ["proprietary"]=> + bool(false) + ["attribute"]=> + NULL + ["child"]=> + array(1) { + [0]=> + &object(tidyNode)#3 (9) { + ["value"]=> + string(94) "<html> +<head> +<title></title> +</head> +<body bgcolor="#FFFFFF" alink="#000000"> +</body> +</html>" + ["name"]=> + string(4) "html" + ["type"]=> + int(5) + ["line"]=> + int(1) + ["column"]=> + int(1) + ["proprietary"]=> + bool(false) + ["id"]=> + int(48) + ["attribute"]=> + NULL + ["child"]=> + array(2) { + [0]=> + &object(tidyNode)#4 (9) { + ["value"]=> + string(31) "<head> +<title></title> +</head> +" + ["name"]=> + string(4) "head" + ["type"]=> + int(5) + ["line"]=> + int(1) + ["column"]=> + int(7) + ["proprietary"]=> + bool(false) + ["id"]=> + int(46) + ["attribute"]=> + NULL + ["child"]=> + array(1) { + [0]=> + &object(tidyNode)#5 (9) { + ["value"]=> + string(16) "<title></title> +" + ["name"]=> + string(5) "title" + ["type"]=> + int(5) + ["line"]=> + int(1) + ["column"]=> + int(57) + ["proprietary"]=> + bool(false) + ["id"]=> + int(111) + ["attribute"]=> + NULL + ["child"]=> + NULL + } + } + } + [1]=> + &object(tidyNode)#6 (9) { + ["value"]=> + string(49) "<body bgcolor="#FFFFFF" alink="#000000"> +</body> +" + ["name"]=> + string(4) "body" + ["type"]=> + int(5) + ["line"]=> + int(1) + ["column"]=> + int(7) + ["proprietary"]=> + bool(false) + ["id"]=> + int(16) + ["attribute"]=> + array(2) { + ["bgcolor"]=> + string(7) "#FFFFFF" + ["alink"]=> + string(7) "#000000" + } + ["child"]=> + NULL + } + } + } + } +} +object(tidyNode)#2 (9) { + ["value"]=> + string(49) "<body bgcolor="#FFFFFF" alink="#000000"> +</body> +" + ["name"]=> + string(4) "body" + ["type"]=> + int(5) + ["line"]=> + int(1) + ["column"]=> + int(7) + ["proprietary"]=> + bool(false) + ["id"]=> + int(16) + ["attribute"]=> + array(2) { + ["bgcolor"]=> + string(7) "#FFFFFF" + ["alink"]=> + string(7) "#000000" + } + ["child"]=> + NULL +} +object(tidyNode)#2 (9) { + ["value"]=> + string(94) "<html> +<head> +<title></title> +</head> +<body bgcolor="#FFFFFF" alink="#000000"> +</body> +</html>" + ["name"]=> + string(4) "html" + ["type"]=> + int(5) + ["line"]=> + int(1) + ["column"]=> + int(1) + ["proprietary"]=> + bool(false) + ["id"]=> + int(48) + ["attribute"]=> + NULL + ["child"]=> + array(2) { + [0]=> + &object(tidyNode)#3 (9) { + ["value"]=> + string(31) "<head> +<title></title> +</head> +" + ["name"]=> + string(4) "head" + ["type"]=> + int(5) + ["line"]=> + int(1) + ["column"]=> + int(7) + ["proprietary"]=> + bool(false) + ["id"]=> + int(46) + ["attribute"]=> + NULL + ["child"]=> + array(1) { + [0]=> + &object(tidyNode)#6 (9) { + ["value"]=> + string(16) "<title></title> +" + ["name"]=> + string(5) "title" + ["type"]=> + int(5) + ["line"]=> + int(1) + ["column"]=> + int(57) + ["proprietary"]=> + bool(false) + ["id"]=> + int(111) + ["attribute"]=> + NULL + ["child"]=> + NULL + } + } + } + [1]=> + &object(tidyNode)#4 (9) { + ["value"]=> + string(49) "<body bgcolor="#FFFFFF" alink="#000000"> +</body> +" + ["name"]=> + string(4) "body" + ["type"]=> + int(5) + ["line"]=> + int(1) + ["column"]=> + int(7) + ["proprietary"]=> + bool(false) + ["id"]=> + int(16) + ["attribute"]=> + array(2) { + ["bgcolor"]=> + string(7) "#FFFFFF" + ["alink"]=> + string(7) "#000000" + } + ["child"]=> + NULL + } + } +} +object(tidyNode)#2 (9) { + ["value"]=> + string(31) "<head> +<title></title> +</head> +" + ["name"]=> + string(4) "head" + ["type"]=> + int(5) + ["line"]=> + int(1) + ["column"]=> + int(7) + ["proprietary"]=> + bool(false) + ["id"]=> + int(46) + ["attribute"]=> + NULL + ["child"]=> + array(1) { + [0]=> + &object(tidyNode)#4 (9) { + ["value"]=> + string(16) "<title></title> +" + ["name"]=> + string(5) "title" + ["type"]=> + int(5) + ["line"]=> + int(1) + ["column"]=> + int(57) + ["proprietary"]=> + bool(false) + ["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 0000000..2a94616 --- /dev/null +++ b/ext/tidy/tests/011.phpt @@ -0,0 +1,22 @@ +--TEST-- +Accessing attributes of a node +--SKIPIF-- +<?php if (!extension_loaded("tidy")) print "skip"; ?> +--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 0000000..1205812 --- /dev/null +++ b/ext/tidy/tests/012.phpt @@ -0,0 +1,473 @@ +--TEST-- +Accessing children nodes +--SKIPIF-- +<?php if (!extension_loaded("tidy")) print "skip"; ?> +--FILE-- +<?php + + function dump_nodes(tidyNode $node) { + + var_dump($node->hasChildren()); + if($node->hasChildren()) { + + foreach($node->child as $c) { + + var_dump($c); + + if($c->hasChildren()) { + + dump_nodes($c); + + } + } + + } + + } + + $a = tidy_parse_string("<HTML><BODY BGCOLOR=#FFFFFF ALINK=#000000><B>Hi</B><I>Bye<U>Test</U></I></BODY></HTML>", array('newline' => 'LF')); + $html = $a->html(); + dump_nodes($html); + +?> +--EXPECT-- +bool(true) +object(tidyNode)#3 (9) { + ["value"]=> + string(31) "<head> +<title></title> +</head> +" + ["name"]=> + string(4) "head" + ["type"]=> + int(5) + ["line"]=> + int(1) + ["column"]=> + int(7) + ["proprietary"]=> + bool(false) + ["id"]=> + int(46) + ["attribute"]=> + NULL + ["child"]=> + array(1) { + [0]=> + &object(tidyNode)#4 (9) { + ["value"]=> + string(16) "<title></title> +" + ["name"]=> + string(5) "title" + ["type"]=> + int(5) + ["line"]=> + int(1) + ["column"]=> + int(87) + ["proprietary"]=> + bool(false) + ["id"]=> + int(111) + ["attribute"]=> + NULL + ["child"]=> + NULL + } + } +} +bool(true) +object(tidyNode)#4 (9) { + ["value"]=> + string(16) "<title></title> +" + ["name"]=> + string(5) "title" + ["type"]=> + int(5) + ["line"]=> + int(1) + ["column"]=> + int(87) + ["proprietary"]=> + bool(false) + ["id"]=> + int(111) + ["attribute"]=> + NULL + ["child"]=> + NULL +} +object(tidyNode)#5 (9) { + ["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) + ["line"]=> + int(1) + ["column"]=> + int(7) + ["proprietary"]=> + bool(false) + ["id"]=> + int(16) + ["attribute"]=> + array(2) { + ["bgcolor"]=> + string(7) "#FFFFFF" + ["alink"]=> + string(7) "#000000" + } + ["child"]=> + array(2) { + [0]=> + &object(tidyNode)#6 (9) { + ["value"]=> + string(9) "<b>Hi</b>" + ["name"]=> + string(1) "b" + ["type"]=> + int(5) + ["line"]=> + int(1) + ["column"]=> + int(43) + ["proprietary"]=> + bool(false) + ["id"]=> + int(8) + ["attribute"]=> + NULL + ["child"]=> + array(1) { + [0]=> + &object(tidyNode)#7 (8) { + ["value"]=> + string(2) "Hi" + ["name"]=> + string(0) "" + ["type"]=> + int(4) + ["line"]=> + int(1) + ["column"]=> + int(46) + ["proprietary"]=> + bool(false) + ["attribute"]=> + NULL + ["child"]=> + NULL + } + } + } + [1]=> + &object(tidyNode)#8 (9) { + ["value"]=> + string(21) "<i>Bye<u>Test</u></i>" + ["name"]=> + string(1) "i" + ["type"]=> + int(5) + ["line"]=> + int(1) + ["column"]=> + int(52) + ["proprietary"]=> + bool(false) + ["id"]=> + int(49) + ["attribute"]=> + NULL + ["child"]=> + array(2) { + [0]=> + &object(tidyNode)#9 (8) { + ["value"]=> + string(3) "Bye" + ["name"]=> + string(0) "" + ["type"]=> + int(4) + ["line"]=> + int(1) + ["column"]=> + int(55) + ["proprietary"]=> + bool(false) + ["attribute"]=> + NULL + ["child"]=> + NULL + } + [1]=> + &object(tidyNode)#10 (9) { + ["value"]=> + string(11) "<u>Test</u>" + ["name"]=> + string(1) "u" + ["type"]=> + int(5) + ["line"]=> + int(1) + ["column"]=> + int(58) + ["proprietary"]=> + bool(false) + ["id"]=> + int(114) + ["attribute"]=> + NULL + ["child"]=> + array(1) { + [0]=> + &object(tidyNode)#11 (8) { + ["value"]=> + string(4) "Test" + ["name"]=> + string(0) "" + ["type"]=> + int(4) + ["line"]=> + int(1) + ["column"]=> + int(61) + ["proprietary"]=> + bool(false) + ["attribute"]=> + NULL + ["child"]=> + NULL + } + } + } + } + } + } +} +bool(true) +object(tidyNode)#6 (9) { + ["value"]=> + string(9) "<b>Hi</b>" + ["name"]=> + string(1) "b" + ["type"]=> + int(5) + ["line"]=> + int(1) + ["column"]=> + int(43) + ["proprietary"]=> + bool(false) + ["id"]=> + int(8) + ["attribute"]=> + NULL + ["child"]=> + array(1) { + [0]=> + &object(tidyNode)#7 (8) { + ["value"]=> + string(2) "Hi" + ["name"]=> + string(0) "" + ["type"]=> + int(4) + ["line"]=> + int(1) + ["column"]=> + int(46) + ["proprietary"]=> + bool(false) + ["attribute"]=> + NULL + ["child"]=> + NULL + } + } +} +bool(true) +object(tidyNode)#7 (8) { + ["value"]=> + string(2) "Hi" + ["name"]=> + string(0) "" + ["type"]=> + int(4) + ["line"]=> + int(1) + ["column"]=> + int(46) + ["proprietary"]=> + bool(false) + ["attribute"]=> + NULL + ["child"]=> + NULL +} +object(tidyNode)#8 (9) { + ["value"]=> + string(21) "<i>Bye<u>Test</u></i>" + ["name"]=> + string(1) "i" + ["type"]=> + int(5) + ["line"]=> + int(1) + ["column"]=> + int(52) + ["proprietary"]=> + bool(false) + ["id"]=> + int(49) + ["attribute"]=> + NULL + ["child"]=> + array(2) { + [0]=> + &object(tidyNode)#9 (8) { + ["value"]=> + string(3) "Bye" + ["name"]=> + string(0) "" + ["type"]=> + int(4) + ["line"]=> + int(1) + ["column"]=> + int(55) + ["proprietary"]=> + bool(false) + ["attribute"]=> + NULL + ["child"]=> + NULL + } + [1]=> + &object(tidyNode)#10 (9) { + ["value"]=> + string(11) "<u>Test</u>" + ["name"]=> + string(1) "u" + ["type"]=> + int(5) + ["line"]=> + int(1) + ["column"]=> + int(58) + ["proprietary"]=> + bool(false) + ["id"]=> + int(114) + ["attribute"]=> + NULL + ["child"]=> + array(1) { + [0]=> + &object(tidyNode)#11 (8) { + ["value"]=> + string(4) "Test" + ["name"]=> + string(0) "" + ["type"]=> + int(4) + ["line"]=> + int(1) + ["column"]=> + int(61) + ["proprietary"]=> + bool(false) + ["attribute"]=> + NULL + ["child"]=> + NULL + } + } + } + } +} +bool(true) +object(tidyNode)#9 (8) { + ["value"]=> + string(3) "Bye" + ["name"]=> + string(0) "" + ["type"]=> + int(4) + ["line"]=> + int(1) + ["column"]=> + int(55) + ["proprietary"]=> + bool(false) + ["attribute"]=> + NULL + ["child"]=> + NULL +} +object(tidyNode)#10 (9) { + ["value"]=> + string(11) "<u>Test</u>" + ["name"]=> + string(1) "u" + ["type"]=> + int(5) + ["line"]=> + int(1) + ["column"]=> + int(58) + ["proprietary"]=> + bool(false) + ["id"]=> + int(114) + ["attribute"]=> + NULL + ["child"]=> + array(1) { + [0]=> + &object(tidyNode)#11 (8) { + ["value"]=> + string(4) "Test" + ["name"]=> + string(0) "" + ["type"]=> + int(4) + ["line"]=> + int(1) + ["column"]=> + int(61) + ["proprietary"]=> + bool(false) + ["attribute"]=> + NULL + ["child"]=> + NULL + } + } +} +bool(true) +object(tidyNode)#11 (8) { + ["value"]=> + string(4) "Test" + ["name"]=> + string(0) "" + ["type"]=> + int(4) + ["line"]=> + int(1) + ["column"]=> + int(61) + ["proprietary"]=> + bool(false) + ["attribute"]=> + NULL + ["child"]=> + NULL +} diff --git a/ext/tidy/tests/013.html b/ext/tidy/tests/013.html new file mode 100644 index 0000000..7dc0357 --- /dev/null +++ b/ext/tidy/tests/013.html @@ -0,0 +1 @@ +<B>testing</I> diff --git a/ext/tidy/tests/013.phpt b/ext/tidy/tests/013.phpt new file mode 100644 index 0000000..8f1ac94 --- /dev/null +++ b/ext/tidy/tests/013.phpt @@ -0,0 +1,13 @@ +--TEST-- +Parsing a file using constructor +--SKIPIF-- +<?php if (!extension_loaded("tidy")) print "skip"; ?> +--FILE-- +<?php + $tidy = new tidy(dirname(__FILE__)."/013.html", array("show-body-only"=>true)); + $tidy->cleanRepair(); + echo $tidy; + +?> +--EXPECT-- +<b>testing</b> diff --git a/ext/tidy/tests/014.phpt b/ext/tidy/tests/014.phpt new file mode 100644 index 0000000..a391b3d --- /dev/null +++ b/ext/tidy/tests/014.phpt @@ -0,0 +1,14 @@ +--TEST-- +Passing configuration options through tidy_parse_string(). +--SKIPIF-- +<?php if (!extension_loaded("tidy")) print "skip"; ?> +--FILE-- +<?php + $text = "<B>testing</I>"; + $tidy = tidy_parse_string($text, array('show-body-only'=>true)); + tidy_clean_repair($tidy); + echo tidy_get_output($tidy); + +?> +--EXPECT-- +<b>testing</b>
\ No newline at end of file diff --git a/ext/tidy/tests/015.html b/ext/tidy/tests/015.html new file mode 100644 index 0000000..7dc0357 --- /dev/null +++ b/ext/tidy/tests/015.html @@ -0,0 +1 @@ +<B>testing</I> diff --git a/ext/tidy/tests/015.phpt b/ext/tidy/tests/015.phpt new file mode 100644 index 0000000..03018ff --- /dev/null +++ b/ext/tidy/tests/015.phpt @@ -0,0 +1,13 @@ +--TEST-- +Passing configuration options through tidy_parse_file(). +--SKIPIF-- +<?php if (!extension_loaded("tidy")) print "skip"; ?> +--FILE-- +<?php + $tidy = tidy_parse_file(dirname(__FILE__)."/015.html", array('show-body-only'=>true)); + tidy_clean_repair($tidy); + echo tidy_get_output($tidy); + +?> +--EXPECT-- +<b>testing</b>
\ No newline at end of file diff --git a/ext/tidy/tests/016.html b/ext/tidy/tests/016.html new file mode 100644 index 0000000..7dc6e4a --- /dev/null +++ b/ext/tidy/tests/016.html @@ -0,0 +1 @@ +<P><B><FONT SIZE=10 COLOR=#FF0000>testing</FONT></I></P> diff --git a/ext/tidy/tests/016.phpt b/ext/tidy/tests/016.phpt new file mode 100644 index 0000000..001371a --- /dev/null +++ b/ext/tidy/tests/016.phpt @@ -0,0 +1,24 @@ +--TEST-- +Passing configuration file through tidy_parse_file() (may fail with buggy libtidy) +--SKIPIF-- +<?php if (!extension_loaded("tidy")) print "skip"; ?> +--FILE-- +<?php + $tidy = tidy_parse_file(dirname(__FILE__)."/016.html", dirname(__FILE__)."/016.tcfg"); + tidy_clean_repair($tidy); + echo tidy_get_output($tidy); +?> +--EXPECT-- +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN"> +<html> +<head> +<title></title> + +<style type="text/css"> + p.c1 {font-weight: bold} +</style> +</head> +<body> +<p class="c1">testing</p> +</body> +</html> diff --git a/ext/tidy/tests/016.tcfg b/ext/tidy/tests/016.tcfg new file mode 100644 index 0000000..fd6e4e4 --- /dev/null +++ b/ext/tidy/tests/016.tcfg @@ -0,0 +1 @@ +clean: yes diff --git a/ext/tidy/tests/017.phpt b/ext/tidy/tests/017.phpt new file mode 100644 index 0000000..ba620a3 --- /dev/null +++ b/ext/tidy/tests/017.phpt @@ -0,0 +1,17 @@ +--TEST-- +The Tidy Output Buffer Filter +--SKIPIF-- +<?php if (!extension_loaded("tidy")) print "skip"; ?> +--FILE-- +<?php ob_start("ob_tidyhandler"); ?> +<B>testing</I> +--EXPECT-- +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN"> +<html> +<head> +<title></title> +</head> +<body> +<b>testing</b> +</body> +</html>
\ No newline at end of file diff --git a/ext/tidy/tests/018.phpt b/ext/tidy/tests/018.phpt new file mode 100644 index 0000000..405a46d --- /dev/null +++ b/ext/tidy/tests/018.phpt @@ -0,0 +1,16 @@ +--TEST-- +binary safety +--SKIPIF-- +<?php if (!extension_loaded("tidy")) print "skip"; ?> +--FILE-- +<?php +$x = tidy_repair_string("<p>abra\0cadabra</p>", + array( 'show-body-only' => true, + 'clean' => false, + 'newline' => "\n") + ); +var_dump($x); +?> +--EXPECT-- +string(19) "<p>abracadabra</p> +" diff --git a/ext/tidy/tests/019.phpt b/ext/tidy/tests/019.phpt new file mode 100644 index 0000000..5e9c38d --- /dev/null +++ b/ext/tidy/tests/019.phpt @@ -0,0 +1,42 @@ +--TEST-- +tidy_repair_*() and invalid parameters +--SKIPIF-- +<?php if (!extension_loaded("tidy")) print "skip"; ?> +--FILE-- +<?php + +$l = 1; +$s = ""; +$a = array(); + +tidy_repair_string($s, $l, $l, $l); +tidy_repair_string($s, $s, $s, $s); +tidy_repair_string($l, $l, $l ,$l); +tidy_repair_string($a, $a, $a, $a); + +tidy_repair_file($s, $l, $l, $l); +tidy_repair_file($s, $s, $s, $s); +tidy_repair_file($l, $l, $l ,$l); +tidy_repair_file($a, $a, $a, $a); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: tidy_repair_string(): Could not load configuration file '1' in %s on line %d + +Warning: tidy_repair_string(): Could not set encoding '1' in %s on line %d + +Warning: tidy_repair_string(): Could not load configuration file '' in %s on line %d + +Warning: tidy_repair_string(): Could not load configuration file '1' in %s on line %d + +Warning: tidy_repair_string(): Could not set encoding '1' in %s on line %d + +Warning: tidy_repair_string() expects parameter 1 to be string, array given in %s on line %d + +Warning: tidy_repair_file(): Filename cannot be empty in %s on line %d + +Warning: tidy_repair_file(): Filename cannot be empty in %s on line %d + +Warning: tidy_repair_file() expects parameter 1 to be a valid path, array given in %s on line %d +Done diff --git a/ext/tidy/tests/020.phpt b/ext/tidy/tests/020.phpt new file mode 100644 index 0000000..dbfda96 --- /dev/null +++ b/ext/tidy/tests/020.phpt @@ -0,0 +1,36 @@ +--TEST-- +OO API +--SKIPIF-- +<?php if (!extension_loaded("tidy")) print "skip"; ?> +--FILE-- +<?php + +$tidy = new tidy(); +$str = <<<EOF +<p>Isto é um texto em Português<br> +para testes.</p> +EOF; + +$tidy->parseString($str, array('output-xhtml'=>1), 'latin1'); +$tidy->cleanRepair(); +$tidy->diagnose(); +var_dump(tidy_warning_count($tidy) > 0); +var_dump(strlen($tidy->errorBuffer) > 50); + +echo $tidy; +?> +--EXPECT-- +bool(true) +bool(true) +<?xml version="1.0" encoding="iso-8859-1"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> +<title></title> +</head> +<body> +<p>Isto é um texto em Português<br /> +para testes.</p> +</body> +</html> diff --git a/ext/tidy/tests/021.phpt b/ext/tidy/tests/021.phpt new file mode 100644 index 0000000..bdf9546 --- /dev/null +++ b/ext/tidy/tests/021.phpt @@ -0,0 +1,18 @@ +--TEST-- +tidy_get_opt_doc() +--SKIPIF-- +<?php if (!extension_loaded("tidy") || !function_exists('tidy_get_opt_doc')) print "skip"; ?> +--FILE-- +<?php + +var_dump(tidy_get_opt_doc(new tidy, 'some_bogus_cfg')); + +$t = new tidy; +var_dump($t->getOptDoc('ncr')); +var_dump(strlen(tidy_get_opt_doc($t, 'wrap')) > 99); +?> +--EXPECTF-- +Warning: tidy_get_opt_doc(): Unknown Tidy Configuration Option 'some_bogus_cfg' in %s021.php on line 3 +bool(false) +string(73) "This option specifies if Tidy should allow numeric character references. " +bool(true) diff --git a/ext/tidy/tests/022.phpt b/ext/tidy/tests/022.phpt new file mode 100644 index 0000000..5e9c38d --- /dev/null +++ b/ext/tidy/tests/022.phpt @@ -0,0 +1,42 @@ +--TEST-- +tidy_repair_*() and invalid parameters +--SKIPIF-- +<?php if (!extension_loaded("tidy")) print "skip"; ?> +--FILE-- +<?php + +$l = 1; +$s = ""; +$a = array(); + +tidy_repair_string($s, $l, $l, $l); +tidy_repair_string($s, $s, $s, $s); +tidy_repair_string($l, $l, $l ,$l); +tidy_repair_string($a, $a, $a, $a); + +tidy_repair_file($s, $l, $l, $l); +tidy_repair_file($s, $s, $s, $s); +tidy_repair_file($l, $l, $l ,$l); +tidy_repair_file($a, $a, $a, $a); + +echo "Done\n"; +?> +--EXPECTF-- +Warning: tidy_repair_string(): Could not load configuration file '1' in %s on line %d + +Warning: tidy_repair_string(): Could not set encoding '1' in %s on line %d + +Warning: tidy_repair_string(): Could not load configuration file '' in %s on line %d + +Warning: tidy_repair_string(): Could not load configuration file '1' in %s on line %d + +Warning: tidy_repair_string(): Could not set encoding '1' in %s on line %d + +Warning: tidy_repair_string() expects parameter 1 to be string, array given in %s on line %d + +Warning: tidy_repair_file(): Filename cannot be empty in %s on line %d + +Warning: tidy_repair_file(): Filename cannot be empty in %s on line %d + +Warning: tidy_repair_file() expects parameter 1 to be a valid path, array given in %s on line %d +Done diff --git a/ext/tidy/tests/023.phpt b/ext/tidy/tests/023.phpt new file mode 100644 index 0000000..1f7b02d --- /dev/null +++ b/ext/tidy/tests/023.phpt @@ -0,0 +1,41 @@ +--TEST-- +tidy and tidyNode OO +--SKIPIF-- +<?php if (!extension_loaded('tidy')) echo 'skip'; ?> +--FILE-- +<?php + +//test leaks here: +new tidy(); +var_dump(new tidy()); + +echo "-------\n"; + +$tidy = new tidy(); +$tidy->parseString('<html><?php echo "xpto;" ?></html>'); + +var_dump(tidy_get_root($tidy)->child[0]->isHtml()); +var_dump(tidy_get_root($tidy)->child[0]->child[0]->isPHP()); +var_dump(tidy_get_root($tidy)->child[0]->child[0]->isAsp()); +var_dump(tidy_get_root($tidy)->child[0]->child[0]->isJste()); +var_dump(tidy_get_root($tidy)->child[0]->child[0]->type === TIDY_NODETYPE_PHP); + +var_dump(tidy_get_root($tidy)->child[0]->hasChildren()); +var_dump(tidy_get_root($tidy)->child[0]->child[0]->hasChildren()); + +?> +--EXPECT-- +object(tidy)#1 (2) { + ["errorBuffer"]=> + NULL + ["value"]=> + NULL +} +------- +bool(true) +bool(true) +bool(false) +bool(false) +bool(true) +bool(true) +bool(false) diff --git a/ext/tidy/tests/024.phpt b/ext/tidy/tests/024.phpt new file mode 100644 index 0000000..b09f5b4 --- /dev/null +++ b/ext/tidy/tests/024.phpt @@ -0,0 +1,40 @@ +--TEST-- +libtidy handling of 'new-blocklevel-tags' +--SKIPIF-- +<?php +if (!extension_loaded('tidy')) die('skip'); +if (strtotime(tidy_get_release()) < strtotime('20 january 2007')) die ('skip old libtidy'); +?> +--FILE-- +<?php + +// more info at http://sf.net/tracker/?func=detail&atid=390963&aid=1598422&group_id=27659 + +$contents = ' +<wps:block> +<wps:var> +<wps:value/> +</wps:var> +</wps:block>'; + +$config = array( +'new-blocklevel-tags' => 'wps:block,wps:var,wps:value', +'newline' => 'LF' +); + +$tidy = tidy_parse_string($contents, $config, 'utf8'); +$tidy->cleanRepair(); + +var_dump($tidy->value); + +?> +--EXPECTF-- +string(11%d) "<html> +<head> +<title></title> +</head> +<body> +<wps:block>%w<wps:var> +<wps:value></wps:var>%w</wps:block> +</body> +</html>" diff --git a/ext/tidy/tests/025.phpt b/ext/tidy/tests/025.phpt new file mode 100644 index 0000000..df9392e --- /dev/null +++ b/ext/tidy/tests/025.phpt @@ -0,0 +1,36 @@ +--TEST-- +tidyNode tests +--SKIPIF-- +<?php if (!extension_loaded('tidy')) die('skip'); ?> +--FILE-- +<?php + +$tidy=tidy_parse_string('<% %>', array('newline' => 'LF')); +var_dump($tidy->Root()->child[0]->isAsp()); + +$tidy=tidy_parse_string('<# #>', array('newline' => 'LF')); +var_dump($tidy->Root()->child[0]->isJste()); + +$tidy=tidy_parse_string('<html><body>text</body></html>'); +var_dump($tidy->Root()->child[0]->child[1]->child[0]->isText()); + +$tidy=tidy_parse_string('<html><body><!-- comment --></body></html>', array('newline' => 'LF')); +$n = $tidy->Root()->child[0]->child[1]->child[0]; +var_dump($n->isComment()); +var_dump((string)$n); +var_dump((bool)$n); +var_dump((double)$n); +var_dump((int)$n); +var_dump($tidy->Root()->child[0]->child[0]->hasSiblings()); + +?> +--EXPECT-- +bool(true) +bool(true) +bool(true) +bool(true) +string(16) "<!-- comment -->" +bool(true) +float(0) +int(0) +bool(true) diff --git a/ext/tidy/tests/026.phpt b/ext/tidy/tests/026.phpt new file mode 100644 index 0000000..24a1e6f --- /dev/null +++ b/ext/tidy/tests/026.phpt @@ -0,0 +1,24 @@ +--TEST-- +tidy.clean_output test +--SKIPIF-- +<?php if (!extension_loaded('tidy')) die('skip'); ?> +--INI-- +tidy.clean_output=1 +--FILE-- +<html> +<?php + +echo '<p>xpto</p>'; + +?> +</html> +--EXPECT-- +<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN"> +<html> +<head> +<title></title> +</head> +<body> +<p>xpto</p> +</body> +</html> diff --git a/ext/tidy/tests/027.phpt b/ext/tidy/tests/027.phpt new file mode 100644 index 0000000..8d9f66e --- /dev/null +++ b/ext/tidy/tests/027.phpt @@ -0,0 +1,59 @@ +--TEST-- +Bug: tidy segfaults with markup=false +--SKIPIF-- +<?php if (!extension_loaded('tidy')) die('skip'); ?> +--FILE-- +<?php + +// bug report from http://sf.net/tracker/?func=detail&atid=390963&aid=1641868&group_id=27659 + +abstract class BaseClass { + private static $tidyconfig; + + public function BaseClass() { + $this->tidyconfig = array( + 'indent' => false, + 'clean' => true, + 'merge-divs' => false, + 'quote-marks' => true, + 'drop-empty-paras' => false, + 'markup' => false, + 'output-xhtml' => true, + 'wrap' => 0); + + } + + abstract public function run(); + + public function getURL($url) { + $data = "awerawer"; // in my code, $data is downloaded from a site + + $tidy = new tidy; + $tidy->parseString($data, $this->tidyconfig, 'utf8'); + $tidy->cleanRepair(); + + return $tidy; + } + +} + +class ChildClass extends BaseClass { + public function ChildClass() { + parent::__construct(); + } + + public function run() { + $result = $this->getURL('awer'); + if ($result === null) { + echo "\tError:\n"; + } + var_dump((string)$result); + } +} + +$instance = new ChildClass(); +$instance->run(); + +?> +--EXPECT-- +string(0) "" diff --git a/ext/tidy/tests/028.phpt b/ext/tidy/tests/028.phpt new file mode 100644 index 0000000..01f3fd1 --- /dev/null +++ b/ext/tidy/tests/028.phpt @@ -0,0 +1,15 @@ +--TEST-- +tidyNode::getParent() +--SKIPIF-- +<?php if (!extension_loaded("tidy")) print "skip"; ?> +--FILE-- +<?php +$x = tidy_parse_string("<body><div>Content</div></body>"); +var_dump($x->body()->child[0]->name); +var_dump($x->body()->child[0]->getParent()->name); +var_dump($x->root()->getParent()); +?> +--EXPECT-- +string(3) "div" +string(4) "body" +NULL diff --git a/ext/tidy/tests/029.phpt b/ext/tidy/tests/029.phpt new file mode 100644 index 0000000..1709cd6 --- /dev/null +++ b/ext/tidy/tests/029.phpt @@ -0,0 +1,28 @@ +--TEST-- +tidy_get_body() crash +--SKIPIF-- +<?php if (!extension_loaded('tidy')) die('skip'); ?> +--FILE-- +<?php + +// bug report taken from http://news.php.net/php.notes/130628 + +$inputs = array( + '<frameset > </frameset>', + '<html><frameset> </frameset> </html', +); + + +foreach ($inputs as $input) { + + $t = tidy_parse_string($input); + $t->cleanRepair(); + var_dump(tidy_get_body($t)); +} + +echo "Done\n"; +?> +--EXPECT-- +NULL +NULL +Done diff --git a/ext/tidy/tests/030.phpt b/ext/tidy/tests/030.phpt new file mode 100644 index 0000000..c351f9a --- /dev/null +++ b/ext/tidy/tests/030.phpt @@ -0,0 +1,29 @@ +--TEST-- +getConfig() method - basic test for getConfig() +--CREDITS-- +Christian Wenz <wenz@php.net> +--SKIPIF-- +<?php + if (!extension_loaded('tidy')) die ('skip tidy not present'); +?> +--FILE-- +<?php +$buffer = '<html></html>'; +$config = array( + 'indent' => true, // AutoBool + 'indent-attributes' => true, // Boolean + 'indent-spaces' => 3, // Integer + 'language' => 'de'); // String +$tidy = new tidy(); +$tidy->parseString($buffer, $config); +$c = $tidy->getConfig(); +var_dump($c['indent']); +var_dump($c['indent-attributes']); +var_dump($c['indent-spaces']); +var_dump($c['language']); +?> +--EXPECTF-- +int(1) +bool(true) +int(3) +%s(2) "de" diff --git a/ext/tidy/tests/031.phpt b/ext/tidy/tests/031.phpt new file mode 100644 index 0000000..cf6aed9 --- /dev/null +++ b/ext/tidy/tests/031.phpt @@ -0,0 +1,18 @@ +--TEST-- +tidy_config_count() function - basic test for tidy_config_count() +--CREDITS-- +Christian Wenz <wenz@php.net> +--SKIPIF-- +<?php + if (!extension_loaded('tidy')) die ('skip tidy not present'); +?> +--FILE-- +<?php +$buffer = '<html></html>'; +$config = array('doctype' => 'php'); + +$tidy = tidy_parse_string($buffer, $config); +var_dump(tidy_config_count($tidy)); +?> +--EXPECTF-- +int(%d) diff --git a/ext/tidy/tests/032.phpt b/ext/tidy/tests/032.phpt new file mode 100644 index 0000000..23230b0 --- /dev/null +++ b/ext/tidy/tests/032.phpt @@ -0,0 +1,17 @@ +--TEST-- +tidy_error_count() function - basic test for tidy_error_count() +--CREDITS-- +Christian Wenz <wenz@php.net> +--SKIPIF-- +<?php + if (!extension_loaded('tidy')) die ('skip tidy not present'); +?> +--FILE-- +<?php +$buffer = '<img src="file.png" /><php>'; + +$tidy = tidy_parse_string($buffer); +var_dump(tidy_error_count($tidy)); +?> +--EXPECTF-- +int(%d) diff --git a/ext/tidy/tests/033.phpt b/ext/tidy/tests/033.phpt new file mode 100644 index 0000000..2c4bb44 --- /dev/null +++ b/ext/tidy/tests/033.phpt @@ -0,0 +1,17 @@ +--TEST-- +tidy_warning_count() function - basic test for tidy_warning_count() +--CREDITS-- +Christian Wenz <wenz@php.net> +--SKIPIF-- +<?php + if (!extension_loaded('tidy')) die ('skip tidy not present'); +?> +--FILE-- +<?php +$buffer = '<img src="file.png" /><php>'; + +$tidy = tidy_parse_string($buffer); +var_dump(tidy_warning_count($tidy)); +?> +--EXPECTF-- +int(%d) diff --git a/ext/tidy/tests/034.phpt b/ext/tidy/tests/034.phpt new file mode 100644 index 0000000..9780315 --- /dev/null +++ b/ext/tidy/tests/034.phpt @@ -0,0 +1,20 @@ +--TEST-- +tidy_access_count() function - basic test for tidy_access_count() +--CREDITS-- +Christian Wenz <wenz@php.net> +--SKIPIF-- +<?php + if (!extension_loaded('tidy')) die ('skip tidy not present'); +?> +--FILE-- +<?php +$buffer = '<img src="file.png" /><php>'; +$config = array( + 'accessibility-check' => 1); + +$tidy = tidy_parse_string($buffer, $config); +$tidy->diagnose(); +var_dump(tidy_access_count($tidy)); +?> +--EXPECTF-- +int(%d) diff --git a/ext/tidy/tests/035.phpt b/ext/tidy/tests/035.phpt new file mode 100644 index 0000000..832f90f --- /dev/null +++ b/ext/tidy/tests/035.phpt @@ -0,0 +1,12 @@ +--TEST-- +tidyNode::__construct() +--SKIPIF-- +<?php + if (!extension_loaded('tidy')) die ('skip tidy not present'); +?> +--FILE-- +<?php +new tidyNode; +?> +--EXPECTF-- +Fatal error: Call to private tidyNode::__construct() from invalid context in %s on line %d diff --git a/ext/tidy/tests/bug54682.phpt b/ext/tidy/tests/bug54682.phpt new file mode 100644 index 0000000..2bebe11 --- /dev/null +++ b/ext/tidy/tests/bug54682.phpt @@ -0,0 +1,13 @@ +--TEST-- +Tidy::diagnose() NULL pointer dereference +--SKIPIF-- +<?php if (!extension_loaded("tidy")) print "skip"; ?> +--FILE-- +<?php + +$nx = new Tidy("*"); +$nx->diagnose(); + +?> +--EXPECTF-- +Warning: tidy::__construct(): Cannot Load '*' into memory%win %s on line %d diff --git a/ext/tidy/tests/bug_50558.phpt b/ext/tidy/tests/bug_50558.phpt new file mode 100644 index 0000000..b37cb92 --- /dev/null +++ b/ext/tidy/tests/bug_50558.phpt @@ -0,0 +1,28 @@ +--TEST-- +Bug #50558 - Broken object model when extending tidy +--SKIPIF-- +<?php if (!extension_loaded("tidy")) print "skip"; ?> +--FILE-- +<?php +class MyTidy extends tidy +{ + // foo +} + +function doSomething(MyTidy $o) +{ + var_dump($o); +} + +$o = new MyTidy(); +var_dump($o instanceof MyTidy); +doSomething($o); +?> +--EXPECTF-- +bool(true) +object(MyTidy)#%d (%d) { + ["errorBuffer"]=> + NULL + ["value"]=> + NULL +} diff --git a/ext/tidy/tests/tidy_error.phpt b/ext/tidy/tests/tidy_error.phpt new file mode 100644 index 0000000..5416da8 --- /dev/null +++ b/ext/tidy/tests/tidy_error.phpt @@ -0,0 +1,41 @@ +--TEST-- +Ensure tidy_get_status() returns correct status +--CREDITS-- +Stefan Priebsch +--SKIPIF-- +<?php + if (!extension_loaded("tidy")) print "skip tidy extension not loaded"; +?> +--FILE-- +<?php + +$html = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 3.2//EN"> +<html> +<head> +<title></title> +</head> +<body> +<p>paragraph</p> +</body> +</html>'; +$tidy = tidy_parse_string($html); + +echo tidy_get_status($tidy); +// status 0 indicates no errors or warnings + +$html = '<p>paragraph</i>'; +$tidy = tidy_parse_string($html); + +echo tidy_get_status($tidy); +// status 1 indicates warnings + +$html = '<bogus>test</bogus>'; +$tidy = tidy_parse_string($html); + +echo tidy_get_status($tidy); +// status 2 indicates error + +?> +--EXPECT-- +012 + diff --git a/ext/tidy/tests/tidy_error1.phpt b/ext/tidy/tests/tidy_error1.phpt new file mode 100644 index 0000000..a924469 --- /dev/null +++ b/ext/tidy/tests/tidy_error1.phpt @@ -0,0 +1,19 @@ +--TEST-- +Notice triggered by invalid configuration options +--CREDITS-- +Christian Wenz <wenz@php.net> +--SKIPIF-- +<?php + if (!extension_loaded('tidy')) die ('skip tidy not present'); +?> +--FILE-- +<?php +$buffer = '<html></html>'; +$config = array('bogus' => 'willnotwork'); + +$tidy = new tidy(); +var_dump($tidy->parseString($buffer, $config)); +?> +--EXPECTF-- +Notice: tidy::parseString(): Unknown Tidy Configuration Option 'bogus' in %s on line %d +bool(true) |