summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/enchant/enchant.c4
-rw-r--r--ext/enchant/tests/broker_request_dict_error_on_empty_tag.phpt20
2 files changed, 22 insertions, 2 deletions
diff --git a/ext/enchant/enchant.c b/ext/enchant/enchant.c
index 089f1a9a5c..3ebb76e910 100644
--- a/ext/enchant/enchant.c
+++ b/ext/enchant/enchant.c
@@ -455,8 +455,8 @@ PHP_FUNCTION(enchant_broker_request_dict)
PHP_ENCHANT_GET_BROKER;
if (taglen == 0) {
- php_error_docref(NULL, E_WARNING, "Tag cannot be empty");
- RETURN_FALSE;
+ zend_argument_value_error(2, "cannot be empty");
+ RETURN_THROWS();
}
pdict = enchant_broker_request_dict(pbroker->pbroker, (const char *)tag);
diff --git a/ext/enchant/tests/broker_request_dict_error_on_empty_tag.phpt b/ext/enchant/tests/broker_request_dict_error_on_empty_tag.phpt
new file mode 100644
index 0000000000..63005a9ba6
--- /dev/null
+++ b/ext/enchant/tests/broker_request_dict_error_on_empty_tag.phpt
@@ -0,0 +1,20 @@
+--TEST--
+enchant_broker_request_dict() must throw ValueError on empty tag
+--SKIPIF--
+<?php
+if(!extension_loaded('enchant')) die('skip, enchant not loader');
+if (!is_object(enchant_broker_init())) {die("skip, resource dont load\n");}
+?>
+--FILE--
+<?php
+$broker = enchant_broker_init();
+
+try {
+ var_dump(enchant_broker_request_dict($broker, ''));
+} catch (\ValueError $e) {
+ echo $e->getMessage() . \PHP_EOL;
+}
+
+?>
+--EXPECT--
+enchant_broker_request_dict(): Argument #2 ($tag) cannot be empty