public function test_arbitrary_selects() { $qb = new QueryBuilder(); $qb->addSelectStatement('a.b', 'C'); $expectedSQL = 'SELECT a.b AS C FROM WHERE'; list($actual_sql, $actual_opts) = $qb->getSQL(); $this->assertEquals($this->cleanWS($expectedSQL), $this->cleanWS($actual_sql)); $this->assertEquals(array(), $actual_opts); }
public function test_join() { $qb = new QueryBuilder(); $qb->addTable('first', 'T1'); $qb->addTable('second', 'T2'); $qb->addTable('third', 'T3'); $qb->addLeftJoin('T2', 'fourth', 'T4', 'T2.foo=T4.foo'); $expectedSQL = ' SELECT FROM first AS T1, second AS T2 LEFT OUTER JOIN fourth AS T4 ON T2.foo = T4.foo, third AS T3 WHERE '; list($actual_sql, $actual_opts) = $qb->getSQL(); $this->assertEquals($this->cleanWS($expectedSQL), $this->cleanWS($actual_sql)); $this->assertEquals(array(), $actual_opts); }