summaryrefslogtreecommitdiff
path: root/ext/enchant/tests
diff options
context:
space:
mode:
Diffstat (limited to 'ext/enchant/tests')
-rw-r--r--ext/enchant/tests/broker_describe.phpt28
-rw-r--r--ext/enchant/tests/broker_free.phpt21
-rw-r--r--ext/enchant/tests/broker_init.phpt15
-rw-r--r--ext/enchant/tests/broker_request_dict.phpt31
-rw-r--r--ext/enchant/tests/bug13181.phpt43
-rw-r--r--ext/enchant/tests/dict_quick_check.phpt26
-rw-r--r--ext/enchant/tests/hindi_correct.txt1
-rw-r--r--ext/enchant/tests/hindi_incorrect.txt1
8 files changed, 166 insertions, 0 deletions
diff --git a/ext/enchant/tests/broker_describe.phpt b/ext/enchant/tests/broker_describe.phpt
new file mode 100644
index 0000000..4c03f6f
--- /dev/null
+++ b/ext/enchant/tests/broker_describe.phpt
@@ -0,0 +1,28 @@
+--TEST--
+enchant_broker_describe() function
+--SKIPIF--
+<?php
+if(!extension_loaded('enchant')) die('skip, enchant not loader');
+
+ ?>
+--FILE--
+<?php
+$broker = enchant_broker_init();
+
+if(!$broker) exit("failed, broker_init failure\n");
+
+$provides = enchant_broker_describe($broker);
+
+if (is_array($provides)) {
+ foreach ($provides as $backend) {
+ if (!(isset($backend['name']) && isset($backend['desc']) && isset($backend['file']))) {
+ exit("failed\n");
+ }
+ }
+ exit("OK\n");
+} else {
+ echo "failed";
+}
+?>
+--EXPECTF--
+OK
diff --git a/ext/enchant/tests/broker_free.phpt b/ext/enchant/tests/broker_free.phpt
new file mode 100644
index 0000000..d00c22a
--- /dev/null
+++ b/ext/enchant/tests/broker_free.phpt
@@ -0,0 +1,21 @@
+--TEST--
+enchant_broker_free() function
+--SKIPIF--
+<?php
+if(!extension_loaded('enchant')) die('skip, enchant not loader');
+
+ ?>
+--FILE--
+<?php
+$broker = enchant_broker_init();
+if (is_resource($broker)) {
+ echo "OK\n";
+ enchant_broker_free($broker);
+} else {
+ exit("init failed\n");
+}
+echo "OK\n";
+?>
+--EXPECT--
+OK
+OK
diff --git a/ext/enchant/tests/broker_init.phpt b/ext/enchant/tests/broker_init.phpt
new file mode 100644
index 0000000..359a653
--- /dev/null
+++ b/ext/enchant/tests/broker_init.phpt
@@ -0,0 +1,15 @@
+--TEST--
+enchant_broker_init() function
+--SKIPIF--
+<?php
+if(!extension_loaded('enchant')) die('skip, enchant not loader');
+
+ ?>
+--FILE--
+<?php
+$broker = enchant_broker_init();
+echo is_resource($broker) ? "OK" : "Failure";
+echo "\n";
+?>
+--EXPECT--
+OK
diff --git a/ext/enchant/tests/broker_request_dict.phpt b/ext/enchant/tests/broker_request_dict.phpt
new file mode 100644
index 0000000..5744da6
--- /dev/null
+++ b/ext/enchant/tests/broker_request_dict.phpt
@@ -0,0 +1,31 @@
+--TEST--
+enchant_broker_request_dict() function
+--SKIPIF--
+<?php
+if(!extension_loaded('enchant')) die('skip, enchant not loader');
+?>
+--FILE--
+<?php
+$broker = enchant_broker_init();
+if (!is_resource($broker)) {
+ exit("init failed\n");
+}
+
+$dicts = enchant_broker_list_dicts($broker);
+if (is_array($dicts)) {
+ if (count($dicts)) {
+ $dict = enchant_broker_request_dict($broker, $dicts[0]['lang_tag']);
+ if (is_resource($dict)) {
+ echo "OK\n";
+ } else {
+ echo "fail to request " . $dicts[0]['lang_tag'];
+ }
+ }
+} else {
+ exit("list dicts failed\n");
+}
+echo "OK\n";
+?>
+--EXPECT--
+OK
+OK
diff --git a/ext/enchant/tests/bug13181.phpt b/ext/enchant/tests/bug13181.phpt
new file mode 100644
index 0000000..38aec63
--- /dev/null
+++ b/ext/enchant/tests/bug13181.phpt
@@ -0,0 +1,43 @@
+--TEST--
+bug #13181, leaving a context frees the broker resources
+--SKIPIF--
+<?php
+if(!extension_loaded('enchant')) die('skip, enchant not loader');
+
+ ?>
+--FILE--
+<?php
+function get_dictionnary() {
+ $rBroker = enchant_broker_init();
+ $t = enchant_broker_request_dict($rBroker, 'en');
+ var_dump($t);
+ return $t;
+}
+$rDict = get_dictionnary();
+var_dump($rDict);
+enchant_dict_suggest($rDict, "soong");
+
+function get_broker() {
+ $t = enchant_broker_init();
+ var_dump($t);
+ return $t;
+}
+
+$rbroker = get_broker();
+var_dump($rbroker);
+
+function get_dict($broker) {
+ $t = enchant_broker_request_dict($broker, 'en');
+ var_dump($t);
+ return $t;
+}
+$rDict = get_dict($rbroker);
+var_dump($rDict);
+?>
+--EXPECTF--
+resource(%d) of type (enchant_dict)
+resource(%d) of type (enchant_dict)
+resource(%d) of type (enchant_broker)
+resource(%d) of type (enchant_broker)
+resource(%d) of type (enchant_dict)
+resource(%d) of type (enchant_dict)
diff --git a/ext/enchant/tests/dict_quick_check.phpt b/ext/enchant/tests/dict_quick_check.phpt
new file mode 100644
index 0000000..3412de1
--- /dev/null
+++ b/ext/enchant/tests/dict_quick_check.phpt
@@ -0,0 +1,26 @@
+--TEST--
+enchant_dict_quick_check() basic test
+--SKIPIF--
+<?php
+if(!extension_loaded('enchant')) die('skip, enchant not loader');
+
+$tag = 'en_US';
+$r = enchant_broker_init();
+if (!enchant_broker_dict_exists($r, $tag))
+ die('skip, no dictionary for ' . $tag . ' tag');
+?>
+--FILE--
+<?php
+
+$tag = 'en_US';
+$r = enchant_broker_init();
+
+$d = enchant_broker_request_dict($r, $tag);
+enchant_dict_quick_check($d, 'soong', $suggs);
+
+echo "Elements: " . count($suggs) . "\n";
+echo "Done\n";
+?>
+--EXPECTF--
+Elements: %d
+Done
diff --git a/ext/enchant/tests/hindi_correct.txt b/ext/enchant/tests/hindi_correct.txt
new file mode 100644
index 0000000..cced6b8
--- /dev/null
+++ b/ext/enchant/tests/hindi_correct.txt
@@ -0,0 +1 @@
+इस पृष्ठ में एक लिंक बनाने के लिये इस प्रतीक को खीचें व छोड़ें
diff --git a/ext/enchant/tests/hindi_incorrect.txt b/ext/enchant/tests/hindi_incorrect.txt
new file mode 100644
index 0000000..1f7353c
--- /dev/null
+++ b/ext/enchant/tests/hindi_incorrect.txt
@@ -0,0 +1 @@
+इस पृष्ठ में एक लिंक बनाने के लिये इस प्रतीक को खच व छड