From aa6593f984f9c0b4d4ecce7fe4deafeca4c9508d Mon Sep 17 00:00:00 2001
From: Nuno Lopes
Date: Tue, 5 Sep 2006 15:23:26 +0000
Subject: [PATCH] sync code and tests between HEAD and PHP_5_2 branches. what a
confusion...
---
ext/tidy/tests/007.phpt | 12 ++++++--
ext/tidy/tests/020.phpt | 61 ++++++++++++++++-------------------------
ext/tidy/tests/021.phpt | 18 ++++++++++++
ext/tidy/tests/022.phpt | 38 +++++++++++++++++++++++++
ext/tidy/tests/023.phpt | 49 +++++++++++++++++++++++++++++++++
ext/tidy/tidy.c | 2 +-
6 files changed, 140 insertions(+), 40 deletions(-)
create mode 100644 ext/tidy/tests/021.phpt
create mode 100644 ext/tidy/tests/022.phpt
create mode 100644 ext/tidy/tests/023.phpt
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--
-
+
--FILE--
isHtml());
-
$tidy = new tidy();
-$tidy->parseString('');
+$str = <<Isto é um texto em Português
+para testes.
+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)
+
+
+
+
+
+
+
+Isto é um texto em Português
+para testes.
+
+
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--
+
+--FILE--
+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--
+
+--FILE--
+
+--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--
+
+--FILE--
+isHtml());
+
+$tidy = new tidy();
+$tidy->parseString('');
+
+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;
--
2.40.0