summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNuno Lopes <nlopess@php.net>2006-09-05 15:23:26 +0000
committerNuno Lopes <nlopess@php.net>2006-09-05 15:23:26 +0000
commitaa6593f984f9c0b4d4ecce7fe4deafeca4c9508d (patch)
tree4fb860dfadee749f7847341c836b36caff7ceeee
parentdc8895ed82230e386fdb0f38139c82aa30311c8b (diff)
downloadphp-git-aa6593f984f9c0b4d4ecce7fe4deafeca4c9508d.tar.gz
sync code and tests between HEAD and PHP_5_2 branches. what a confusion...
-rw-r--r--ext/tidy/tests/007.phpt12
-rw-r--r--ext/tidy/tests/020.phpt61
-rw-r--r--ext/tidy/tests/021.phpt18
-rw-r--r--ext/tidy/tests/022.phpt38
-rw-r--r--ext/tidy/tests/023.phpt49
-rw-r--r--ext/tidy/tidy.c2
6 files changed, 140 insertions, 40 deletions
diff --git a/ext/tidy/tests/007.phpt b/ext/tidy/tests/007.phpt
index 26867ff3fb..f6bb13d556 100644
--- a/ext/tidy/tests/007.phpt
+++ b/ext/tidy/tests/007.phpt
@@ -13,9 +13,17 @@ tidy.default_config=
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 àáç'));
?>
---EXPECT--
+--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/020.phpt b/ext/tidy/tests/020.phpt
index e7ee4b3c0c..dbfda96375 100644
--- a/ext/tidy/tests/020.phpt
+++ b/ext/tidy/tests/020.phpt
@@ -1,49 +1,36 @@
--TEST--
-tidy and tidyNode OO
+OO API
--SKIPIF--
-<?php if (!extension_loaded('tidy')) echo 'skip'; ?>
+<?php if (!extension_loaded("tidy")) print "skip"; ?>
--FILE--
<?php
-//test leaks here:
-new tidyNode();
-var_dump(new tidyNode());
-new tidy();
-var_dump(new tidy());
-
-echo "-------\n";
-
-$x = new tidyNode();
-var_dump($x->isHtml());
-
$tidy = new tidy();
-$tidy->parseString('<html><?php echo "xpto;" ?></html>');
+$str = <<<EOF
+<p>Isto é um texto em Português<br>
+para testes.</p>
+EOF;
-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());
+$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--
-object(tidyNode)#1 (0) {
-}
-object(tidy)#1 (2) {
- ["errorBuffer"]=>
- NULL
- ["value"]=>
- NULL
-}
--------
-bool(false)
-bool(true)
-bool(true)
-bool(false)
-bool(false)
bool(true)
bool(true)
-bool(false)
+<?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 0000000000..bdf954617b
--- /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 0000000000..9d2c693cdb
--- /dev/null
+++ b/ext/tidy/tests/022.phpt
@@ -0,0 +1,38 @@
+--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() expects parameter 1 to be string, 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 0000000000..e7ee4b3c0c
--- /dev/null
+++ b/ext/tidy/tests/023.phpt
@@ -0,0 +1,49 @@
+--TEST--
+tidy and tidyNode OO
+--SKIPIF--
+<?php if (!extension_loaded('tidy')) echo 'skip'; ?>
+--FILE--
+<?php
+
+//test leaks here:
+new tidyNode();
+var_dump(new tidyNode());
+new tidy();
+var_dump(new tidy());
+
+echo "-------\n";
+
+$x = new tidyNode();
+var_dump($x->isHtml());
+
+$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(tidyNode)#1 (0) {
+}
+object(tidy)#1 (2) {
+ ["errorBuffer"]=>
+ NULL
+ ["value"]=>
+ NULL
+}
+-------
+bool(false)
+bool(true)
+bool(true)
+bool(false)
+bool(false)
+bool(true)
+bool(true)
+bool(false)
diff --git a/ext/tidy/tidy.c b/ext/tidy/tidy.c
index 4de0bbf347..9ba59ffcf4 100644
--- a/ext/tidy/tidy.c
+++ b/ext/tidy/tidy.c
@@ -358,7 +358,7 @@ static zend_function_entry tidy_funcs_node[] = {
{NULL, NULL, NULL}
};
-zend_class_entry *tidy_ce_doc, *tidy_ce_node, *tidy_ce_exception;
+static zend_class_entry *tidy_ce_doc, *tidy_ce_node;
static zend_object_handlers tidy_object_handlers_doc;
static zend_object_handlers tidy_object_handlers_node;