Skip to content
This repository was archived by the owner on Sep 20, 2021. It is now read-only.

Commit 3d3f2c8

Browse files
committed
cast operator name for insensitive compatibility
1 parent 95e7c66 commit 3d3f2c8

2 files changed

Lines changed: 27 additions & 1 deletion

File tree

Test/Integration/Model/Operator.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,30 @@ function ($b) use (&$gExecuted) {
204204
->boolean($gExecuted)
205205
->isTrue();
206206
}
207+
208+
public function case_insensitive()
209+
{
210+
$this
211+
->given(
212+
$ruler = new LUT(),
213+
$asserter = $ruler->getDefaultAsserter(),
214+
$asserter->setOperator(
215+
'myFirstMethod',
216+
function () { return true; }
217+
),
218+
$asserter->setOperator(
219+
'mySecondMethod',
220+
function () { return true; }
221+
),
222+
$asserter->setOperator(
223+
'mythirdmethod',
224+
function () { return true; }
225+
),
226+
$rule = 'myFirstMethod() and mysecondmethod() and myThirdMethod()'
227+
)
228+
->when($result = $ruler->assert($rule, new LUT\Context()))
229+
->then
230+
->boolean($result)
231+
->isTrue();
232+
}
207233
}

Visitor/Asserter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ public function getContext()
465465
*/
466466
public function setOperator($operator, $callable)
467467
{
468-
$this->_operators[$operator] = $callable;
468+
$this->_operators[mb_strtolower($operator)] = $callable;
469469

470470
return $this;
471471
}

0 commit comments

Comments
 (0)