public function testCustomOperators() { $rule = new Rule(':this is greater than :that', [':this' => 8, ':that' => 7]); $rule->registerToken(Tokenizer::TOKEN_GREATER, '\\bis\\s+greater\\s+than\\b'); $rule->registerToken(Tokenizer::TOKEN_VARIABLE, ':\\w+'); $this->assertTrue($rule->isTrue()); }
public function testIsValidReturnsTrueOnValidSyntax() { $ruleStr = '(2 == 2) && (1 < 3 && 3 > 2 || (1 == 1))'; $rule = new Rules\Rule($ruleStr); $this->assertTrue($rule->isValid()); $this->assertEmpty($rule->getError()); $this->assertTrue($rule->isTrue()); }