public function testShouldProduceSelectStatementWithHaving() { $table = "test"; $sql = Query::getInstance()->select(Projections::count("id"))->from($table)->group(Group::groupBy("id"))->having(Projections::gt(Projections::count("id"), "?"))->build(); $expectedSql = "SELECT COUNT(id) FROM {$table} GROUP BY id HAVING ( COUNT(id) > ?)"; $this->assertThat($sql, $this->equalTo($expectedSql)); }
/** * Add a group by clause to query * * @param Group $groupBy * @return Query */ public function group(Group $groupBy) { $this->group = $groupBy->toSql(); return $this; }