summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNuno Lopes <nlopess@php.net>2006-06-28 14:36:23 +0000
committerNuno Lopes <nlopess@php.net>2006-06-28 14:36:23 +0000
commite8a3530d5093e42902f5c42f63bbff40bb74de02 (patch)
tree216b291b909f948e6d03793c45f300e1b3c11d37
parent58c82af64dc10f4ae11625426397c40e1e1c7e3d (diff)
downloadphp-git-e8a3530d5093e42902f5c42f63bbff40bb74de02.tar.gz
new tests (001.phpt is just a rename from the older one)
increases coverage from 20% to 70%
-rw-r--r--ext/pspell/tests/001.phpt (renamed from ext/pspell/tests/01pspell_basic.phpt)8
-rw-r--r--ext/pspell/tests/002.phpt38
-rw-r--r--ext/pspell/tests/003.phpt39
-rw-r--r--ext/pspell/tests/004.phpt35
-rw-r--r--ext/pspell/tests/005.phpt46
-rw-r--r--ext/pspell/tests/wordlist.txt5
6 files changed, 167 insertions, 4 deletions
diff --git a/ext/pspell/tests/01pspell_basic.phpt b/ext/pspell/tests/001.phpt
index 1cfb684485..0a22352eef 100644
--- a/ext/pspell/tests/01pspell_basic.phpt
+++ b/ext/pspell/tests/001.phpt
@@ -2,10 +2,10 @@
pspell basic tests (warning: may fail with pspell/aspell < GNU Aspell 0.50.3)
--SKIPIF--
<?php
- if (!extension_loaded("pspell")) print "skip";
- if (!@pspell_new ("en", "", "", "", (PSPELL_FAST|PSPELL_RUN_TOGETHER))) {
- die("skip English dictionary is not available");
- }
+if (!extension_loaded("pspell")) die("skip");
+if (!@pspell_new ("en", "", "", "", (PSPELL_FAST|PSPELL_RUN_TOGETHER))) {
+ die("skip English dictionary is not available");
+}
?>
--FILE--
<?php // $Id$
diff --git a/ext/pspell/tests/002.phpt b/ext/pspell/tests/002.phpt
new file mode 100644
index 0000000000..b736b4ee2f
--- /dev/null
+++ b/ext/pspell/tests/002.phpt
@@ -0,0 +1,38 @@
+--TEST--
+pspell session
+--SKIPIF--
+<?php
+if (!extension_loaded('pspell')) die('skip');
+if (!@pspell_new('en')) die('skip English dictionary is not available');
+?>
+--FILE--
+<?php
+
+$p = pspell_new('en');
+
+var_dump(pspell_check('a'));
+var_dump(pspell_check($p, 'somebogusword'));
+
+var_dump(pspell_add_to_session($p, ''));
+var_dump(pspell_add_to_session($p, 'somebogusword'));
+var_dump(pspell_check($p, 'somebogusword'));
+
+var_dump(pspell_clear_session(new stdclass));
+var_dump(pspell_clear_session($p));
+var_dump(pspell_check($p, 'somebogusword'));
+
+?>
+--EXPECTF--
+Warning: Wrong parameter count for pspell_check() in %s002.php on line 5
+NULL
+bool(false)
+bool(false)
+bool(true)
+bool(true)
+
+Notice: Object of class stdClass could not be converted to int in %s002.php on line 12
+
+Warning: pspell_clear_session(): 1 is not a PSPELL result index in %s002.php on line 12
+bool(false)
+bool(true)
+bool(false)
diff --git a/ext/pspell/tests/003.phpt b/ext/pspell/tests/003.phpt
new file mode 100644
index 0000000000..7af81683f9
--- /dev/null
+++ b/ext/pspell/tests/003.phpt
@@ -0,0 +1,39 @@
+--TEST--
+pspell_config_ignore
+--SKIPIF--
+<?php
+if (!extension_loaded('pspell')) die('skip');
+if (!@pspell_new('en')) die('skip English dictionary is not available');
+?>
+--FILE--
+<?php
+
+$cfg = pspell_config_create('en', 'british', '', 'iso8859-1');
+$cfg2 = pspell_config_create('en', 'british', '', 'b0rked');
+
+$p = pspell_new_config($cfg);
+var_dump(pspell_check($p, 'yy'));
+
+$p2 = pspell_new_config($cfg2);
+var_dump(pspell_check($p2, 'yy'));
+
+echo "---\n";
+var_dump(pspell_config_ignore($cfg, 2));
+$p = pspell_new_config($cfg);
+var_dump(pspell_check($p, 'yy'));
+
+// segfault it?
+var_dump(pspell_config_ignore($cfg, PHP_INT_MAX));
+
+?>
+--EXPECTF--
+bool(false)
+
+Warning: pspell_new_config(): PSPELL couldn't open the dictionary. reason: The encoding "b0rked" is not known. This could also mean that the file "%sb0rked.dat" could not be opened for reading or does not exist. in %s003.php on line 9
+
+Warning: pspell_check(): 0 is not a PSPELL result index in %s003.php on line 10
+bool(false)
+---
+bool(true)
+bool(true)
+bool(true)
diff --git a/ext/pspell/tests/004.phpt b/ext/pspell/tests/004.phpt
new file mode 100644
index 0000000000..80602bce39
--- /dev/null
+++ b/ext/pspell/tests/004.phpt
@@ -0,0 +1,35 @@
+--TEST--
+pspell configs
+--SKIPIF--
+<?php
+if (!extension_loaded('pspell')) die('skip');
+if (!@pspell_new('en')) die('skip English dictionary is not available');
+?>
+--FILE--
+<?php
+
+$cfg = pspell_config_create('en', 'british', '', 'iso8859-1');
+var_dump(pspell_config_mode($cfg, PSPELL_BAD_SPELLERS));
+
+var_dump(pspell_config_runtogether($cfg, false));
+$p = pspell_new_config($cfg);
+var_dump(pspell_check($p, 'theoasis'));
+
+echo "---\n";
+
+// now it should pass
+var_dump(pspell_config_runtogether($cfg, true));
+$p = pspell_new_config($cfg);
+var_dump(pspell_check($p, 'theoasis'));
+
+var_dump(pspell_config_runtogether($cfg, NULL))
+
+?>
+--EXPECT--
+bool(true)
+bool(true)
+bool(false)
+---
+bool(true)
+bool(true)
+bool(true)
diff --git a/ext/pspell/tests/005.phpt b/ext/pspell/tests/005.phpt
new file mode 100644
index 0000000000..8aeb206031
--- /dev/null
+++ b/ext/pspell/tests/005.phpt
@@ -0,0 +1,46 @@
+--TEST--
+pspell configs
+--SKIPIF--
+<?php
+if (!extension_loaded('pspell')) die('skip');
+if (!@pspell_new('en')) die('skip English dictionary is not available');
+?>
+--FILE--
+<?php
+
+$wordlist = dirname(__FILE__).'/wordlist.txt';
+
+var_dump(pspell_new_personal(__FILE__, 'en'));
+$p = pspell_new_personal($wordlist, 'en');
+
+var_dump(pspell_check($p, 'dfnvnsafksfksf'));
+
+echo "--\n";
+$cfg = pspell_config_create('en');
+var_dump(pspell_config_personal($cfg, "$wordlist.tmp"));
+$p = pspell_new_config($cfg);
+
+copy($wordlist, "$wordlist.tmp");
+
+var_dump(pspell_check($p, 'ola'));
+var_dump(pspell_add_to_personal($p, 'ola'));
+var_dump(pspell_check($p, 'ola'));
+
+echo "--\n";
+var_dump(pspell_save_wordlist($p));
+var_dump(strpos(file_get_contents("$wordlist.tmp"), 'ola') !== FALSE);
+
+unlink("$wordlist.tmp");
+?>
+--EXPECTF--
+Warning: pspell_new_personal(): PSPELL couldn't open the dictionary. reason: The file "%s005.php" is not in the proper format. in %s005.php on line 5
+bool(false)
+bool(true)
+--
+bool(true)
+bool(false)
+bool(true)
+bool(true)
+--
+bool(true)
+bool(true)
diff --git a/ext/pspell/tests/wordlist.txt b/ext/pspell/tests/wordlist.txt
new file mode 100644
index 0000000000..e9d8da7ca3
--- /dev/null
+++ b/ext/pspell/tests/wordlist.txt
@@ -0,0 +1,5 @@
+personal_ws-1.1 en 4
+dfnvnsafksfksf
+fg
+iufrsn
+jsksjfsjf