Skip to content

Commit

Permalink
Add tests for count with autoFields
Browse files Browse the repository at this point in the history
  • Loading branch information
Ladislav Gallay committed Aug 25, 2014
1 parent 17719c6 commit b6cddfd
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/TestCase/ORM/QueryTest.php
Expand Up @@ -2072,5 +2072,32 @@ public function testAutoFieldsWithContainQueryBuilder() {
$this->assertArrayHasKey('name', $result['author']);
$this->assertArrayHasKey('compute', $result);
}

/**
* Test count with autoFields
*
* @return void
*/
public function testAutoFieldsCount() {
$table = TableRegistry::get('Articles');
$table->belongsTo('Authors');

$resultNormal = $table->find()
->select(['myField' => '(SELECT RAND())'])
->hydrate(false)
->contain('Authors')
->count();

$resultAutoFields = $table->find()
->select(['myField' => '(SELECT RAND())'])
->autoFields(true)
->hydrate(false)
->contain('Authors')
->count();

$this->assertNotNull($resultNormal);
$this->assertNotNull($resultAutoFields);
$this->assertEquals($resultNormal, $resultAutoFields);
}

}

0 comments on commit b6cddfd

Please sign in to comment.