summaryrefslogtreecommitdiff
path: root/ext/tidy/tests
diff options
context:
space:
mode:
authorJohn Coggeshall <john@php.net>2003-08-01 00:22:43 +0000
committerJohn Coggeshall <john@php.net>2003-08-01 00:22:43 +0000
commit2fb97cdf951eddd1f6376ba5a42a101e2728b298 (patch)
treecd3ba01f62f315da1aa883190be045b637d5578f /ext/tidy/tests
parentde7f7658cfabda9b8fa780fc78e3f6d3749e039e (diff)
downloadphp-git-2fb97cdf951eddd1f6376ba5a42a101e2728b298.tar.gz
Adding the tidy extension to PECL
Diffstat (limited to 'ext/tidy/tests')
-rw-r--r--ext/tidy/tests/001.phpt24
-rw-r--r--ext/tidy/tests/002.phpt25
-rw-r--r--ext/tidy/tests/003.phpt27
-rw-r--r--ext/tidy/tests/004.phpt24
-rw-r--r--ext/tidy/tests/005.html1
-rw-r--r--ext/tidy/tests/005.phpt25
-rw-r--r--ext/tidy/tests/006.phpt23
-rw-r--r--ext/tidy/tests/007.phpt37
8 files changed, 186 insertions, 0 deletions
diff --git a/ext/tidy/tests/001.phpt b/ext/tidy/tests/001.phpt
new file mode 100644
index 0000000000..4be56d0403
--- /dev/null
+++ b/ext/tidy/tests/001.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Check for tidy presence
+--SKIPIF--
+<?php if (!extension_loaded("Tidy")) print "skip"; ?>
+--POST--
+--GET--
+--INI--
+--FILE--
+<?php
+echo "tidy extension is available";
+/*
+ you can add regression tests for your extension here
+
+ the output of your test code has to be equal to the
+ text in the --EXPECT-- section below for the tests
+ to pass, differences between the output and the
+ expected text are interpreted as failure
+
+ see php4/README.TESTING for further information on
+ writing regression tests
+*/
+?>
+--EXPECT--
+tidy extension is available
diff --git a/ext/tidy/tests/002.phpt b/ext/tidy/tests/002.phpt
new file mode 100644
index 0000000000..b3fccffb3f
--- /dev/null
+++ b/ext/tidy/tests/002.phpt
@@ -0,0 +1,25 @@
+--TEST--
+tidy_parse_string()
+--SKIPIF--
+<?php if (!extension_loaded("Tidy")) print "skip"; ?>
+--POST--
+--GET--
+--INI--
+--FILE--
+<?php
+
+ $tidy = tidy_create();
+
+ tidy_parse_string($tidy, "<HTML></HTML>");
+
+ echo tidy_get_output($tidy);
+
+?>
+--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 0000000000..fe0fefc688
--- /dev/null
+++ b/ext/tidy/tests/003.phpt
@@ -0,0 +1,27 @@
+--TEST--
+tidy_clean_repair()
+--SKIPIF--
+<?php if (!extension_loaded("Tidy")) print "skip"; ?>
+--POST--
+--GET--
+--INI--
+--FILE--
+<?php
+
+ $tidy = tidy_create();
+
+ tidy_parse_string($tidy, "<HTML></HTML>");
+ tidy_clean_repair($tidy);
+
+ echo tidy_get_output($tidy);
+
+?>
+--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 0000000000..930a2093c7
--- /dev/null
+++ b/ext/tidy/tests/004.phpt
@@ -0,0 +1,24 @@
+--TEST--
+tidy_diagnose()
+--SKIPIF--
+<?php if (!extension_loaded("Tidy")) print "skip"; ?>
+--POST--
+--GET--
+--INI--
+--FILE--
+<?php
+
+ $tidy = tidy_create();
+
+ tidy_parse_string($tidy, "<HTML></HTML>");
+ tidy_diagnose($tidy);
+ echo tidy_get_error_buffer($tidy);
+
+?>
+--EXPECT--
+
+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! \ No newline at end of file
diff --git a/ext/tidy/tests/005.html b/ext/tidy/tests/005.html
new file mode 100644
index 0000000000..8c17451f91
--- /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 0000000000..828bc148ea
--- /dev/null
+++ b/ext/tidy/tests/005.phpt
@@ -0,0 +1,25 @@
+--TEST--
+tidy_parse_file()
+--SKIPIF--
+<?php if (!extension_loaded("Tidy")) print "skip"; ?>
+--POST--
+--GET--
+--INI--
+--FILE--
+<?php
+
+ $tidy = tidy_create();
+
+ tidy_parse_file($tidy, "ext/tidy/tests/005.html");
+
+ echo tidy_get_output($tidy);
+
+?>
+--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 0000000000..2ea27d38f4
--- /dev/null
+++ b/ext/tidy/tests/006.phpt
@@ -0,0 +1,23 @@
+--TEST--
+Verbose tidy_get_error_buffer()
+--SKIPIF--
+<?php if (!extension_loaded("Tidy")) print "skip"; ?>
+--POST--
+--GET--
+--INI--
+--FILE--
+<?php
+
+ $tidy = tidy_create();
+
+ tidy_parse_string($tidy, "<HTML><asd asdf></HTML>");
+
+ echo tidy_get_error_buffer($tidy, true);
+
+?>
+--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.phpt b/ext/tidy/tests/007.phpt
new file mode 100644
index 0000000000..7fcbb8f39c
--- /dev/null
+++ b/ext/tidy/tests/007.phpt
@@ -0,0 +1,37 @@
+--TEST--
+Verbose tidy_setopt() / tidy_getopt()
+--SKIPIF--
+<?php if (!extension_loaded("Tidy")) print "skip"; ?>
+--POST--
+--GET--
+--INI--
+--FILE--
+<?php
+
+ $tidy = tidy_create();
+ echo "Current Value of 'tidy-mark': ";
+ var_dump(tidy_getopt($tidy, "tidy-mark"));
+ tidy_setopt($tidy, "tidy-mark", true);
+ echo "\nNew Value of 'tidy-mark': ";
+ var_dump(tidy_getopt($tidy, "tidy-mark"));
+ echo "Current Value of 'error-file': ";
+ var_dump(tidy_getopt($tidy, "error-file"));
+ tidy_setopt($tidy, "error-file", "foobar");
+ echo "\nNew Value of 'error-file': ";
+ var_dump(tidy_getopt($tidy, "error-file"));
+ echo "Current Value of 'tab-size': ";
+ var_dump(tidy_getopt($tidy, "tab-size"));
+ tidy_setopt($tidy, "tab-size", 10);
+ echo "\nNew Value of 'tab-size': ";
+ var_dump(tidy_getopt($tidy, "tab-size"));
+?>
+--EXPECT--
+Current Value of 'tidy-mark': bool(false)
+
+New Value of 'tidy-mark': bool(true)
+Current Value of 'error-file': string(0) ""
+
+New Value of 'error-file': string(6) "foobar"
+Current Value of 'tab-size': int(8)
+
+New Value of 'tab-size': int(10) \ No newline at end of file