Pinq\Tests\Integration\Traversable\GroupByTest::testThatGroupByGroupsTheElementsCorrectlyAndPreservesKeys PHP Метод

testThatGroupByGroupsTheElementsCorrectlyAndPreservesKeys() публичный Метод

public testThatGroupByGroupsTheElementsCorrectlyAndPreservesKeys ( Pinq\ITraversable $traversable, array $data )
$traversable Pinq\ITraversable
$data array
    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));
    }