diff options
author | Matthijs Meulenbrug <mrm@users.noreply.github.com> | 2022-04-25 17:50:51 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-25 17:50:51 +0300 |
commit | ef82911187771e56c8987af5bf03d331cc533fde (patch) | |
tree | c1f0454c302b23bbe17f497c8ff75966686d1d59 /tests/MathTest.php | |
parent | a0ff7a79af8c3bc5e9c5decee24cbefb5d80e93b (diff) |
Add a custom variable validator + protected props (#98)
Diffstat (limited to 'tests/MathTest.php')
-rw-r--r-- | tests/MathTest.php | 15 |
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(); |