Skip to content
Permalink
Browse files

Add tests for count with autoFields

  • Loading branch information...
Laykou committed Aug 25, 2014
1 parent 17719c6 commit b6cddfdda9eb73ba37e9e652878b79d12f62f9d9
Showing with 27 additions and 0 deletions.
  1. +27 −0 tests/TestCase/ORM/QueryTest.php
@@ -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.
You can’t perform that action at this time.