1<?php 2 3namespace dokuwiki\plugin\struct\test; 4 5use dokuwiki\plugin\struct\meta; 6 7/** 8 * Tests for parsing the aggregation config for the struct plugin 9 * 10 * @group plugin_struct 11 * @group plugins 12 * 13 */ 14class ConfigParser_struct_test extends StructTest 15{ 16 17 public function test_simple() 18 { 19 $lines = array( 20 "schema : testtable, another, foo bar", 21 "cols : %pageid%, count", 22 "sort : ^count", 23 "sort : %pageid%, ^bam", 24 "align : r,l,center,foo" 25 ); 26 27 $configParser = new meta\ConfigParser($lines); 28 $actual_config = $configParser->getConfig(); 29 30 $expected_config = array( 31 'limit' => 0, 32 'dynfilters' => false, 33 'summarize' => false, 34 'rownumbers' => false, 35 'sepbyheaders' => false, 36 'headers' => 37 array( 38 0 => NULL, 39 1 => NULL, 40 ), 41 'widths' => 42 array(), 43 'filter' => 44 array(), 45 'schemas' => 46 array( 47 0 => 48 array( 49 0 => 'testtable', 50 1 => '', 51 ), 52 1 => 53 array( 54 0 => 'another', 55 1 => '', 56 ), 57 2 => 58 array( 59 0 => 'foo', 60 1 => 'bar', 61 ), 62 ), 63 'cols' => 64 array( 65 0 => '%pageid%', 66 1 => 'count', 67 ), 68 'sort' => 69 array( 70 array( 71 0 => 'count', 72 1 => false, 73 ), 74 array( 75 0 => '%pageid%', 76 1 => true, 77 ), 78 array( 79 0 => 'bam', 80 1 => false, 81 ) 82 ), 83 'csv' => true, 84 'target' => '', 85 'align' => array('right', 'left', 'center', null) 86 ); 87 88 $this->assertEquals($expected_config, $actual_config); 89 } 90 91 public function test_width() 92 { 93 $lines = array('width: 5, 15px, 23.4em, meh, 10em'); 94 95 $configParser = new meta\ConfigParser($lines); 96 97 $config = $configParser->getConfig(); 98 99 $this->assertEquals( 100 array('5px', '15px', '23.4em', '', '10em'), 101 $config['widths'] 102 ); 103 } 104} 105