Exemplo n.º 1
0
 public function test_group_by_attribute()
 {
     $data = new Collection(array(array('rating' => 1, 'url' => '1'), array('rating' => 1, 'url' => '2'), array('rating' => 2, 'url' => '2')));
     $actual = $data->groupBy('rating');
     $expected = array(1 => array(array('rating' => 1, 'url' => '1'), array('rating' => 1, 'url' => '2')), 2 => array(array('rating' => 2, 'url' => '2')));
     $this->assertEquals($expected, $actual->toArray());
     $actual = $data->groupBy('url');
     $expected = array(1 => array(array('rating' => 1, 'url' => '1')), 2 => array(array('rating' => 1, 'url' => '2'), array('rating' => 2, 'url' => '2')));
     $this->assertEquals($expected, $actual->toArray());
 }