xref: /plugin/struct/_test/AggregationFilterTest.php (revision f1812f0b7ac4d9c715e38beb78ffe9711588b0c0)
1<?php
2
3namespace dokuwiki\plugin\struct\test;
4
5
6class AggregationFilterTest extends StructTest
7{
8    protected $items = [
9        [['green', 'yellow'], 'car', 'audi', 'a80'],
10        [[], 'car', 'audi', 'a4'],
11        [['black', 'green'], '', 'audi', 'quattro'],
12        [['red', 'black'], 'car', 'bmw', 'i3'],
13        [['blue', 'gray'], 'car', 'bmw', 'mini'],
14        [['red', 'black'], 'car', 'bmw', 'z1'],
15        [['green', 'blue'], 'laptop', 'apple', 'pro 16'],
16        [['red', 'blue'], 'laptop', 'apple', 'air'],
17        [['black', 'red'], 'laptop', 'apple', 'm1'],
18        [[], 'laptop', 'dell', 'xps'],
19        [['blue', 'yellow'], '', 'dell', 'inspiron'],
20        [['gray', 'yellow'], 'laptop', 'dell', 'latitude'],
21    ];
22
23    public function testGetAllColumnValues()
24    {
25        $result = $this->createAggregationResult($this->items);
26        $filter = new mock\AggregationFilter();
27        $values = $filter->getAllColumnValues($result);
28
29        $this->assertCount(4, $values);
30
31        $this->assertEquals(
32            ['black', 'blue', 'gray', 'green', 'red', 'yellow'],
33            $values['test.field1']['values']
34        );
35
36        $this->assertEquals(
37            'Label 1',
38            $values['test.field1']['label']
39        );
40
41        $this->assertEquals(
42            ['car', 'laptop'],
43            $values['test.field2']['values']
44        );
45
46        $this->assertEquals(
47            'Label 2',
48            $values['test.field2']['label']
49        );
50    }
51}
52