Skip to content
Permalink
Browse files

Adding test to show how to use Collection funcitons in resultSet

  • Loading branch information...
lorenzo committed Dec 26, 2013
1 parent b1b2424 commit 3de9a13746b259d2b8fc9c5e92dc11cf0d9c8c08
Showing with 21 additions and 0 deletions.
  1. +21 −0 Cake/Test/TestCase/ORM/ResultSetTest.php
@@ -18,6 +18,7 @@
use Cake\Core\Configure;
use Cake\Database\ConnectionManager;
use Cake\ORM\Entity;
use Cake\ORM\Query;
use Cake\ORM\ResultSet;
use Cake\ORM\Table;
@@ -191,4 +192,24 @@ public function testCountAfterSerialize() {
$this->assertCount(3, $results, 'Should be countable and 3');
}
/**
* Integration test to show methods from CollectionTrait work
*
* @return void
*/
public function testGroupBy() {
$query = $this->table->find('all');
$results = $query->execute()->groupBy('author_id')->toArray();
$options = ['markNew' => false, 'markClean' => true];
$expected = [
1 => [
new Entity($this->fixtureData[0], $options),
new Entity($this->fixtureData[2], $options)
],
3 => [
new Entity($this->fixtureData[1], $options),
]
];
$this->assertEquals($expected, $results);
}
}

0 comments on commit 3de9a13

Please sign in to comment.
You can’t perform that action at this time.