Skip to content

Commit 5a4d92e

Browse files
committed
add tests
1 parent 247c37a commit 5a4d92e

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

ext/enchant/tests/invalidobj.phpt

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
--TEST--
2+
invalid object raise exception() function
3+
--SKIPIF--
4+
<?php
5+
if(!extension_loaded('enchant')) die('skip, enchant not loader');
6+
if (!is_object(enchant_broker_init())) {die("skip, resource dont load\n");}
7+
?>
8+
--FILE--
9+
<?php
10+
$broker = enchant_broker_init();
11+
if (is_object($broker)) {
12+
echo "OK\n";
13+
@enchant_broker_free($broker);
14+
try {
15+
@enchant_broker_free($broker);
16+
} catch (ValueError $e) {
17+
echo $e->getMessage()."\n";
18+
}
19+
} else {
20+
exit("init failed\n");
21+
}
22+
echo "OK\n";
23+
?>
24+
--EXPECTF--
25+
OK
26+
Invalid or uninitialized EnchantBroker object
27+
OK

ext/enchant/tests/object.phpt

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
--TEST--
2+
Object API
3+
--SKIPIF--
4+
<?php
5+
if(!extension_loaded('enchant')) die('skip, enchant not loader');
6+
if (!is_object(new EnchantBroker)) {die("skip, resource dont load\n");}
7+
?>
8+
--FILE--
9+
<?php
10+
echo "+ Broker\n";
11+
var_dump($broker = new EnchantBroker);
12+
var_dump(is_array($broker->describe()));
13+
$dicts = $broker->listDicts();
14+
var_dump($lang = $dicts[0]['lang_tag']);
15+
16+
echo "+ Dict\n";
17+
var_dump($dict = $broker->requestDict($lang));
18+
var_dump(is_array($dict->describe()));
19+
unset($dict);
20+
21+
echo "+ Check\n";
22+
var_dump($dict = new EnchantDict($broker, $lang));
23+
$w = "ElePHPant";
24+
var_dump($dict->check($w));
25+
var_dump($dict->isAdded($w));
26+
$dict->addToSession($w);
27+
var_dump($dict->check($w));
28+
var_dump($dict->isAdded($w));
29+
30+
echo "+ Suggest\n";
31+
var_dump(is_array($dict->suggest("soong")));
32+
?>
33+
OK
34+
--EXPECTF--
35+
+ Broker
36+
object(EnchantBroker)#%d (0) {
37+
}
38+
bool(true)
39+
string(%d) "%s"
40+
+ Dict
41+
object(EnchantDict)#%d (0) {
42+
}
43+
bool(true)
44+
+ Check
45+
object(EnchantDict)#%d (0) {
46+
}
47+
bool(false)
48+
bool(false)
49+
bool(true)
50+
bool(true)
51+
+ Suggest
52+
bool(true)
53+
OK

0 commit comments

Comments
 (0)