Esempio n. 1
0
 public function testEquality()
 {
     $j1 = new Join('foo', 'bar', 'INNER JOIN');
     $j2 = new Join('foo', 'bar', 'INNER JOIN');
     $this->assertTrue($j1->equals($j2));
     $j3 = new Join('foo', 'bar', 'LEFT JOIN');
     $this->assertFalse($j1->equals($j3), 'INNER JOIN is not equal to LEFT JOIN');
     $j4 = new Join('foo', 'bar', 'RIGHT JOIN');
     $this->assertFalse($j1->equals($j4), 'INNER JOIN is not equal to RIGHT JOIN');
     $j5 = new Join('foo', 'bar');
     $j6 = new Join('foo', 'bar');
     $this->assertTrue($j5->equals($j6), 'Joins without specified join type should be equal,
                                             as they fallback to default join type');
     $j7 = new Join('foo', 'bar', 'INNER JOIN');
     $this->assertTrue($j5->equals($j7), 'Join without specified join type should be equal
                                             to INNER JOIN, as it fallback to default join type');
     $j8 = new Join('foo', 'bar', 'INNER JOIN');
     $j8->addCondition('baz.foo', 'baz.bar');
     $this->assertFalse($j5->equals($j8));
 }
Esempio n. 2
0
 public function equals($join)
 {
     return parent::equals($join) && $this->relationMap == $join->getRelationMap() && $this->previousJoin == $join->getPreviousJoin() && $this->rightTableAlias == $join->getRightTableAlias();
 }
Esempio n. 3
0
 /**
  * Add a join object to the Criteria
  *
  * @param Join $join A join object
  *
  * @return Criteria A modified Criteria object
  */
 public function addJoinObject(Join $join)
 {
     $isAlreadyAdded = false;
     foreach ($this->joins as $alreadyAddedJoin) {
         if ($join->equals($alreadyAddedJoin)) {
             $isAlreadyAdded = true;
             break;
         }
     }
     if (!$isAlreadyAdded) {
         $this->joins[] = $join;
     }
     return $this;
 }