Beispiel #1
0
 public function testCompositeConstructor()
 {
     $j = new Join(['foo1', 'foo2'], ['bar1', 'bar2'], 'LEFT JOIN');
     $expect = [['left' => 'foo1', 'operator' => '=', 'right' => 'bar1'], ['left' => 'foo2', 'operator' => '=', 'right' => 'bar2']];
     $this->assertEquals($expect, $j->getConditions());
     $this->assertEquals('LEFT JOIN', $j->getJoinType());
 }
Beispiel #2
0
 public function testJoinObject()
 {
     $j = new Join('TABLE_A.COL_1', 'TABLE_B.COL_2');
     $this->assertEquals('INNER JOIN', $j->getJoinType());
     $this->assertEquals('TABLE_A.COL_1', $j->getLeftColumn());
     $this->assertEquals('TABLE_A', $j->getLeftTableName());
     $this->assertEquals('COL_1', $j->getLeftColumnName());
     $this->assertEquals('TABLE_B.COL_2', $j->getRightColumn());
     $this->assertEquals('TABLE_B', $j->getRightTableName());
     $this->assertEquals('COL_2', $j->getRightColumnName());
     $j = new Join('TABLE_A.COL_1', 'TABLE_B.COL_1', Criteria::LEFT_JOIN);
     $this->assertEquals('LEFT JOIN', $j->getJoinType());
     $this->assertEquals('TABLE_A.COL_1', $j->getLeftColumn());
     $this->assertEquals('TABLE_B.COL_1', $j->getRightColumn());
     $j = new Join('TABLE_A.COL_1', 'TABLE_B.COL_1', Criteria::RIGHT_JOIN);
     $this->assertEquals('RIGHT JOIN', $j->getJoinType());
     $this->assertEquals('TABLE_A.COL_1', $j->getLeftColumn());
     $this->assertEquals('TABLE_B.COL_1', $j->getRightColumn());
     $j = new Join('TABLE_A.COL_1', 'TABLE_B.COL_1', Criteria::INNER_JOIN);
     $this->assertEquals('INNER JOIN', $j->getJoinType());
     $this->assertEquals('TABLE_A.COL_1', $j->getLeftColumn());
     $this->assertEquals('TABLE_B.COL_1', $j->getRightColumn());
     $j = new Join(array('TABLE_A.COL_1', 'TABLE_A.COL_2'), array('TABLE_B.COL_1', 'TABLE_B.COL_2'), Criteria::INNER_JOIN);
     $this->assertEquals('TABLE_A.COL_1', $j->getLeftColumn(0));
     $this->assertEquals('TABLE_A.COL_2', $j->getLeftColumn(1));
     $this->assertEquals('TABLE_B.COL_1', $j->getRightColumn(0));
     $this->assertEquals('TABLE_B.COL_2', $j->getRightColumn(1));
 }
Beispiel #3
0
 /**
  * @param null|Join $join
  * @return bool
  */
 public function equals($join)
 {
     $parametersOfThisClauses = array();
     $parametersOfJoinClauses = array();
     return null !== $join && $join instanceof Join && $this->getJoinType() === $join->getJoinType() && $this->getConditions() == $join->getConditions() && $this->getClause($parametersOfThisClauses) == $join->getClause($parametersOfJoinClauses);
 }