diff --git a/src/brace.php b/src/brace.php index 7ae0007..b8a95cb 100644 --- a/src/brace.php +++ b/src/brace.php @@ -754,8 +754,12 @@ private function processSingleCondition(array $condition, array $dataset): bool { if (count($condition) > 0 && $data = $this->returnChainedVariables(trim($condition[0]), $dataset)) { $challenge = (isset($condition[1]) ? $condition[1] : 'EXISTS'); - $expected = (isset($condition[2]) ? trim($condition[2]) : true); - $expected = str_replace(['"','+'], ['',' '], $this->strArray($expected)); + $expected = (isset($condition[2]) ? $this->returnChainedVariables(trim($condition[2]), $dataset) : false); + + if (!$expected) { + $expected = (isset($condition[2]) ? trim($condition[2]) : true); + $expected = str_replace(['"','+'], ['',' '], $this->strArray($expected)); + } switch ($challenge) { case 'EXISTS': diff --git a/tests/logs/testdox.txt b/tests/logs/testdox.txt index edfda56..dbdc1ae 100644 --- a/tests/logs/testdox.txt +++ b/tests/logs/testdox.txt @@ -31,6 +31,7 @@ Block Conditions (ConditionTests\BlockConditions) Conditions (ConditionTests\Conditions) [x] Equals [x] More than or equal to + [x] More than or equal to include variable [x] Less than or equal to [x] More than [x] Less than diff --git a/tests/tests/conditions/conditionsTest.php b/tests/tests/conditions/conditionsTest.php index 930144b..e9c8d1d 100644 --- a/tests/tests/conditions/conditionsTest.php +++ b/tests/tests/conditions/conditionsTest.php @@ -46,6 +46,19 @@ public function testMoreThanOrEqualTo(): void ); } + /** + * [testMoreThanOrEqualToIncludeVariable description] + * @return [type] [description] + */ + public function testMoreThanOrEqualToIncludeVariable(): void + { + $brace = new Brace\Parser(); + $this->assertEquals( + "25\n", + $brace->parseInputString('{{age_1 >= age_2 ? "__age_1__"}}', ['age_1' => 25, 'age_2' => 21], false)->return() + ); + } + /** * [testLessThanOrEqualTo description] * @return [type] [description]