mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Test to prove having count issue
This commit is contained in:
parent
5f5662b069
commit
e94c2a944e
@ -7,7 +7,22 @@ class SQLQueryTest extends SapphireTest {
|
||||
protected $extraDataObjects = array(
|
||||
'SQLQueryTest_DO',
|
||||
);
|
||||
|
||||
|
||||
public function testCount() {
|
||||
|
||||
//basic counting
|
||||
$qry = SQLQueryTest_DO::get()->dataQuery()->getFinalisedQuery();
|
||||
$qry->setGroupBy('Common');
|
||||
$ids = $this->allFixtureIDs('SQLQueryTest_DO');
|
||||
$this->assertEquals(count($ids), $qry->count('"SQLQueryTest_DO"."ID"'));
|
||||
|
||||
//test with `having`
|
||||
if (DB::getConn() instanceof MySQLDatabase) {
|
||||
$qry->setHaving('"Date" > 2012-02-01');
|
||||
$this->assertEquals(1, $qry->count('"SQLQueryTest_DO"."ID"'));
|
||||
}
|
||||
}
|
||||
|
||||
public function testEmptyQueryReturnsNothing() {
|
||||
$query = new SQLQuery();
|
||||
$this->assertEquals('', $query->sql());
|
||||
|
Loading…
Reference in New Issue
Block a user