public function testGroup()
{
$field = $this->_db->name('Images.id');
$galleries = Galleries::find('all', array('fields' => array(array("count({$field}) AS count")), 'with' => 'Images', 'group' => array('Galleries.id'), 'order' => array('Galleries.id' => 'ASC')));
$this->assertCount(2, $galleries);
$expected = array(3, 2);
foreach ($galleries as $gallery) {
$this->assertEqual(current($expected), $gallery->count);
next($expected);
}
}