]> granicus.if.org Git - php/commitdiff
sync code and tests between HEAD and PHP_5_2 branches. what a confusion...
authorNuno Lopes <nlopess@php.net>
Tue, 5 Sep 2006 15:23:26 +0000 (15:23 +0000)
committerNuno Lopes <nlopess@php.net>
Tue, 5 Sep 2006 15:23:26 +0000 (15:23 +0000)
ext/tidy/tests/007.phpt
ext/tidy/tests/020.phpt
ext/tidy/tests/021.phpt [new file with mode: 0644]
ext/tidy/tests/022.phpt [new file with mode: 0644]
ext/tidy/tests/023.phpt [new file with mode: 0644]
ext/tidy/tidy.c

index 26867ff3fb277f55752de3e0eb049c369f5b9f71..f6bb13d556a8fd74726d9a9e6d4b6a786324bef9 100644 (file)
@@ -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)
index e7ee4b3c0c4961d100c1fd8c7e7bb6a97e3211f7..dbfda96375bcb42eb86486ccb2c0dfe3120e2236 100644 (file)
@@ -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 (file)
index 0000000..bdf9546
--- /dev/null
@@ -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 (file)
index 0000000..9d2c693
--- /dev/null
@@ -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 (file)
index 0000000..e7ee4b3
--- /dev/null
@@ -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)
index 4de0bbf347ae5a0e241866b4f7f5e84eaa82f6b6..9ba59ffcf42bff3a145544c088945473db54e5ae 100644 (file)
@@ -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;