public function testCompositesWithoutIntersection()
 {
     // (x > 999) or ((x > 7) and (x <= 42))
     $comp1 = new ConditionComposite();
     // (x > 999)
     $comp1_1 = new ValueGreaterThan(999);
     // ()
     $comp1_2 = new ConditionComposite();
     $comp1->addOR($comp1_1)->addOR($comp1_2);
     // (x > 7)
     $comp1_2_1 = new ValueGreaterThan(7);
     // (x <= 42)
     $comp1_2_2 = new ValueGreaterThan(42);
     $comp1_2_2->negate();
     $comp1_2->addAND($comp1_2_1)->addAND($comp1_2_2);
     // (x > 100) and (x <= 999)
     $comp2 = new ConditionComposite();
     // (x > 100)
     $comp2_1 = new ValueGreaterThan(100);
     // (x <= 999)
     $comp2_2 = new ValueGreaterThan(999);
     $comp2_2->negate();
     $comp2->addAND($comp2_1)->addAND($comp2_2);
     $this->assertFalse($this->detector->intersectExists($comp1, $comp2));
 }
 public function testNegationSupport()
 {
     $c1 = new ValueGreaterThan(42);
     $c2 = new ValueGreaterThan(42);
     $c2->negate();
     $this->assertFalse($this->cmp->equal($c1, $c2));
 }
 protected function intersectExistsImpl(ValueGreaterThan $c1, ValueGreaterThan $c2)
 {
     if (!$c1->isNegated() && $c2->isNegated()) {
         return $c2->getMustBeGreaterThanValue() > $c1->getMustBeGreaterThanValue();
     } elseif ($c1->isNegated() && !$c2->isNegated()) {
         return $c1->getMustBeGreaterThanValue() > $c2->getMustBeGreaterThanValue();
     }
     return true;
 }
 public function testNegationSupport1()
 {
     $c1 = new ValueGreaterThan(5);
     $c2 = new ValueGreaterThan(10);
     $c2->negate();
     $this->assertTrue($this->detector->intersectExists($c1, $c2));
     $c1 = new ValueGreaterThan(10);
     $c1->negate();
     $c2 = new ValueGreaterThan(5);
     $this->assertTrue($this->detector->intersectExists($c1, $c2));
 }
 protected function equalImpl(ValueGreaterThan $c1, ValueGreaterThan $c2)
 {
     return $c1->isNegated() === $c2->isNegated() && (double) $c1->getMustBeGreaterThanValue() === (double) $c2->getMustBeGreaterThanValue();
 }
 public function testComparingDifferentComposites()
 {
     // (x > 7) and (!(x > 42) or (x > 99))
     $comp1 = new ConditionComposite();
     // (x > 7)
     $comp1_1 = new ValueGreaterThan(7);
     // ()
     $comp1_2 = new ConditionComposite();
     // !(x > 42)
     $comp1_2_1 = new ValueGreaterThan(42);
     $comp1_2_1->negate();
     // (x > 99)
     $comp1_2_2 = new ValueGreaterThan(99);
     //(!(x > 42) or (x > 99))
     $comp1_2->addOR($comp1_2_1)->addOR($comp1_2_2);
     //// (x > 7) and (!(x > 42) or (x > 99))
     $comp1->addAND($comp1_1)->addAND($comp1_2);
     // (!(x > 42) and (x > 7)) or ((x > 7) and !(x > 99))
     $comp2 = new ConditionComposite();
     // ()
     $comp2_1 = new ConditionComposite();
     // ()
     $comp2_2 = new ConditionComposite();
     $comp2->addOR($comp2_1)->addOR($comp2_2);
     // !(x > 42)
     $comp2_1_1 = new ValueGreaterThan(42);
     $comp2_1_1->negate();
     // (x > 7)
     $comp2_1_2 = new ValueGreaterThan(7);
     // !(x > 42) and (x > 7))
     $comp2_1->addAND($comp2_1_1)->addAND($comp2_1_2);
     // (x > 7)
     $comp2_2_1 = new ValueGreaterThan(7);
     // (x > 99)
     $comp2_2_2 = new ValueGreaterThan(99);
     $comp2_2_2->negate();
     // ((x > 7) and (x > 99))
     $comp2_2->addAND($comp2_2_1)->addAND($comp2_2_2);
     $this->assertFalse($this->cmp->equal($comp1, $comp2));
 }