mirror of
https://github.com/php/php-src.git
synced 2024-12-03 06:44:07 +08:00
new tests (001.phpt is just a rename from the older one)
increases coverage from 20% to 70%
This commit is contained in:
parent
58c82af64d
commit
e8a3530d50
@ -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$
|
38
ext/pspell/tests/002.phpt
Normal file
38
ext/pspell/tests/002.phpt
Normal file
@ -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)
|
39
ext/pspell/tests/003.phpt
Normal file
39
ext/pspell/tests/003.phpt
Normal file
@ -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)
|
35
ext/pspell/tests/004.phpt
Normal file
35
ext/pspell/tests/004.phpt
Normal file
@ -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)
|
46
ext/pspell/tests/005.phpt
Normal file
46
ext/pspell/tests/005.phpt
Normal file
@ -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)
|
5
ext/pspell/tests/wordlist.txt
Normal file
5
ext/pspell/tests/wordlist.txt
Normal file
@ -0,0 +1,5 @@
|
||||
personal_ws-1.1 en 4
|
||||
dfnvnsafksfksf
|
||||
fg
|
||||
iufrsn
|
||||
jsksjfsjf
|
Loading…
Reference in New Issue
Block a user