xref: /PHP-8.0/ext/pspell/tests/005.phpt (revision 54dd762f)
1--TEST--
2pspell configs
3--SKIPIF--
4<?php
5if (!extension_loaded('pspell')) die('skip');
6if (!@pspell_new('en')) die('skip English dictionary is not available');
7if (getenv('SKIP_ASAN')) die('skip pspell leaks memory for invalid dicationaries');
8?>
9--FILE--
10<?php
11
12$wordlist = __DIR__.'/wordlist.txt';
13
14var_dump(pspell_new_personal(__FILE__, 'en'));
15$p = pspell_new_personal($wordlist, 'en');
16
17var_dump(pspell_check($p, 'dfnvnsafksfksf'));
18
19echo "--\n";
20$cfg = pspell_config_create('en');
21var_dump(pspell_config_personal($cfg, "$wordlist.tmp"));
22$p = pspell_new_config($cfg);
23
24copy($wordlist, "$wordlist.tmp");
25
26var_dump(pspell_check($p, 'ola'));
27var_dump(pspell_add_to_personal($p, 'ola'));
28var_dump(pspell_check($p, 'ola'));
29
30echo "--\n";
31var_dump(pspell_save_wordlist($p));
32var_dump(strpos(file_get_contents("$wordlist.tmp"), 'ola') !== FALSE);
33
34unlink("$wordlist.tmp");
35?>
36--EXPECTF--
37Warning: 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
38bool(false)
39bool(true)
40--
41bool(true)
42bool(false)
43bool(true)
44bool(true)
45--
46bool(true)
47bool(true)
48