Beispiel #1
0
 public function testNotAddEqualTo()
 {
     $rb = new RuleBuilder();
     $context = new Context(array('A2' => 8, 'A3' => 4, 'B2' => 13));
     $rule = $rb->logicalNot($rb['A2']->equalTo($rb['B2']));
     $this->assertTrue($rule->evaluate($context));
     $rule = $rb['A2']->add($rb['A3']);
     $rule = $rb->logicalNot($rule->equalTo($rb['B2']));
     $this->assertTrue($rule->evaluate($context));
 }
Beispiel #2
0
 public function testLogicalOperatorGeneration()
 {
     $rb = new RuleBuilder();
     $context = new Context();
     $true = new TrueProposition();
     $false = new FalseProposition();
     $this->assertInstanceOf('Ruler\\Operator\\LogicalOperator', $rb->logicalAnd($true, $false));
     $this->assertInstanceOf('Ruler\\Operator\\LogicalAnd', $rb->logicalAnd($true, $false));
     $this->assertFalse($rb->logicalAnd($true, $false)->evaluate($context));
     $this->assertInstanceOf('Ruler\\Operator\\LogicalOr', $rb->logicalOr($true, $false));
     $this->assertTrue($rb->logicalOr($true, $false)->evaluate($context));
     $this->assertInstanceOf('Ruler\\Operator\\LogicalNot', $rb->logicalNot($true));
     $this->assertFalse($rb->logicalNot($true)->evaluate($context));
     $this->assertInstanceOf('Ruler\\Operator\\LogicalXor', $rb->logicalXor($true, $false));
     $this->assertTrue($rb->logicalXor($true, $false)->evaluate($context));
 }
Beispiel #3
0
 /**
  * @dataProvider truthTableOne
  */
 public function testNonContradiction($p)
 {
     $rb = new RuleBuilder();
     $context = new Context(compact('p'));
     $this->assertEquals($rb->create($rb->logicalNot($rb->logicalAnd($rb['p']->equalTo(true), $rb->logicalNot($rb['p']->equalTo(true)))))->evaluate($context), true);
 }