public function groupBy(callable $function);
/** * @dataProvider assocOneToTen */ public function testThatGroupByGroupsTheElementsCorrectlyAndPreservesKeys(\Pinq\ITraversable $traversable, array $data) { $isEven = function ($i) { return $i % 2 === 0; }; //First number is odd, so the first group should be the odd group list($odd, $even) = $traversable->groupBy($isEven)->asArray(); $this->assertMatches($odd, array_filter($data, function ($i) use($isEven) { return !$isEven($i); })); $this->assertMatches($even, array_filter($data, $isEven)); }