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 */ 14class InlineConfigParserTest extends StructTest 15{ 16 // phpcs:ignore PSR1.Methods.CamelCapsMethodName.NotCamelCaps 17 public function test_simple() 18 { 19 // Same initial setup as ConfigParser.test 20 $inline = '"testtable, another, foo bar"."%pageid%, count" '; 21 $inline .= '?sort: ^count sort: "%pageid%, ^bam" align: "r,l,center,foo"'; 22 // Add InlineConfigParser-specific tests: 23 $inline .= ' & "%pageid% != start" | "count = 1"'; 24 25 $configParser = new meta\InlineConfigParser($inline); 26 $actual_config = $configParser->getConfig(); 27 28 $expected_config = [ 29 'align' => ['right', 'left', 'center', null], 30 'cols' => ['%pageid%', 'count'], 31 'csv' => true, 32 'dynfilters' => false, 33 'filter' => [ 34 ['%pageid%', '!=', 'start', 'AND'], 35 ['count', '=', '1', 'OR'], 36 ], 37 'headers' => [null, null], 38 'limit' => 0, 39 'rownumbers' => false, 40 'schemas' => [ 41 ['testtable', ''], 42 ['another', ''], 43 ['foo', 'bar'], 44 ], 45 'sepbyheaders' => false, 46 'sort' => [ 47 ['count', false], 48 ['%pageid%', true], 49 ['bam', false], 50 ], 51 'summarize' => false, 52 'target' => '', 53 'widths' => [], 54 'nesting' => 0, 55 'index' => 0, 56 'classes' => [], 57 'actcol' => -1, 58 ]; 59 60 $this->assertEquals($expected_config, $actual_config); 61 } 62} 63