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