예제 #1
0
 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));
 }
예제 #2
0
 public function testShouldFetchAllPersistedObjects()
 {
     self::$phactory->getConnection()->exec("DELETE FROM tests");
     $users = array();
     for ($i = 1; $i <= 10; $i++) {
         $users[] = self::$phactory->create('test');
     }
     $query = Query::getInstance();
     $query->select(Projections::count("id"))->from("tests");
     $database = new Database(self::$phactory->getConnection());
     $result = $database->query($query)->uniqueResult();
     $this->assertThat(array_pop($result), $this->equalTo(10));
 }