createAggregationResult($this->items); $filter = new mock\AggregationFilter(); $values = $filter->getAllColumnValues($result); $this->assertCount(4, $values); // we expect value => displayValue pairs, sorted by displayValue $this->assertSame( [ 'black' => 'black', 'blue' => 'blue', 'gray' => 'gray', 'green' => 'green', 'red' => 'red', 'yellow' => 'yellow' ], $this->trimKeys($values[0]['values']) ); $this->assertEquals( 'Label 1', $values[0]['label'] ); $this->assertSame( [ 'car' => 'car', 'laptop' => 'laptop' ], $this->trimKeys($values[1]['values']) ); $this->assertEquals( 'Label 2', $values[1]['label'] ); } /** * Reverses key padding workaround in AggregationFilter::getAllColumnValues() * * @param array $values * @return int[]|string[] */ protected function trimKeys($values) { return array_flip(array_map(static fn($val) => trim($val), array_flip($values))); } }