Skip to content

Commit

Permalink
Merge pull request #20 from aoliverwd/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
aoliverwd authored Nov 10, 2021
2 parents b1f8641 + ba1f9ba commit 04ce2e5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/brace.php
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand Down
1 change: 1 addition & 0 deletions tests/logs/testdox.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions tests/tests/conditions/conditionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit 04ce2e5

Please sign in to comment.