aboutsummaryrefslogtreecommitdiff
path: root/tests/MathTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/MathTest.php')
-rw-r--r--tests/MathTest.php15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/MathTest.php b/tests/MathTest.php
index 3eca351..14de2bf 100644
--- a/tests/MathTest.php
+++ b/tests/MathTest.php
@@ -589,6 +589,21 @@ class MathTest extends TestCase
$calculator->setVar('resource', tmpfile());
}
+ public function testSetCustomVarValidator()
+ {
+ $calculator = new MathExecutor();
+ $calculator->setVarValidationHandler(function ($name, $variable) {
+ if ($name === 'invalidVar' && $variable === 'invalid') {
+ throw new MathExecutorException("Invalid variable");
+ }
+ });
+
+ $calculator->setVar('valid', $this);
+
+ $this->expectException(MathExecutorException::class);
+ $calculator->setVar('invalidVar', 'invalid');
+ }
+
public function testVarExists()
{
$calculator = new MathExecutor();