function test_join() { $query = new SQL_Query(); $join = new SQL_Query_Join(); $join->addJoin(array('t' => 'table', 'table1'), new SQL_Condition('table.x', '=', 'table1.x')); $query->setFrom($join); $ren = new $this->_renderer($query); $this->assertStringEquals('table t INNER JOIN table1 ON table.x = table1.x', $ren->renderFrom()); }
function test_nestedJoinsAndAliases() { $join1 = new SQL_Query_Join(); $join1->addJoin(array('1t' => '1table', '1t2' => '1table2'), null); $join2 = new SQL_Query_Join(); $join2->addJoin(array('2t' => '2table', '2t2' => $join1), null); $join = new SQL_Query_Join(); // the alias 't2' is not important here and getTables() doesnt return it either $join->addJoin(array('t' => 'table1', 't2' => $join2), null); $expected = array(array('table1', 't'), array('2table', '2t'), array('1table', '1t'), array('1table2', '1t2')); $this->assertEquals($expected, $join->getTables()); }