1<?php
2
3namespace dokuwiki\plugin\struct\test;
4
5use dokuwiki\plugin\struct\meta;
6
7/**
8 * Tests for parsing the inline aggregation config for the struct plugin
9 *
10 * @group plugin_struct
11 * @group plugins
12 *
13 */
14// phpcs:ignore Squiz.Classes.ValidClassName
15class InlineConfigParser_struct_test extends StructTest
16{
17    // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps
18    public function test_simple()
19    {
20        // Same initial setup as ConfigParser.test
21        $inline = '"testtable, another, foo bar"."%pageid%, count" ';
22        $inline .= '?sort: ^count sort: "%pageid%, ^bam" align: "r,l,center,foo"';
23        // Add InlineConfigParser-specific tests:
24        $inline .= ' & "%pageid% != start" | "count = 1"';
25
26        $configParser = new meta\InlineConfigParser($inline);
27        $actual_config = $configParser->getConfig();
28
29        $expected_config = [
30            'align' => ['right', 'left', 'center', null],
31            'cols' => ['%pageid%', 'count'],
32            'csv' => true,
33            'dynfilters' => false,
34            'filter' => [
35                ['%pageid%', '!=', 'start', 'AND'],
36                ['count', '=', '1', 'OR'],
37            ],
38            'headers' => [null, null],
39            'limit' => 0,
40            'rownumbers' => false,
41            'schemas' => [
42                ['testtable', ''],
43                ['another', ''],
44                ['foo', 'bar'],
45            ],
46            'sepbyheaders' => false,
47            'sort' => [
48                ['count', false],
49                ['%pageid%', true],
50                ['bam', false],
51            ],
52            'summarize' => false,
53            'target' => '',
54            'widths' => [],
55        ];
56
57        $this->assertEquals($expected_config, $actual_config);
58    }
59}
60