mirror of
https://github.com/cosmocode/dokuwiki-plugin-struct.git
synced 2025-08-01 15:54:34 +00:00

This allows users to set custom CSS classes on aggregations potentially restyling them differently for different use cases. This makes startScope and finishScope part of the public API of the Aggregation class. It should no longer be called within render() but is instead called outside. This might potentially break plugins implementing their own aggregations. Needs to be checked
135 lines
3.4 KiB
PHP
135 lines
3.4 KiB
PHP
<?php
|
|
|
|
namespace dokuwiki\plugin\struct\test;
|
|
|
|
use dokuwiki\plugin\struct\meta;
|
|
|
|
/**
|
|
* Tests for parsing the aggregation config for the struct plugin
|
|
*
|
|
* @group plugin_struct
|
|
* @group plugins
|
|
*
|
|
*/
|
|
class ConfigParserTest extends StructTest
|
|
{
|
|
|
|
public function test_simple()
|
|
{
|
|
$lines = [
|
|
"schema : testtable, another, foo bar",
|
|
"cols : %pageid%, count",
|
|
"sort : ^count",
|
|
"sort : %pageid%, ^bam",
|
|
"align : r,l,center,foo",
|
|
"class : foo, bar",
|
|
];
|
|
|
|
$configParser = new meta\ConfigParser($lines);
|
|
$actual_config = $configParser->getConfig();
|
|
|
|
$expected_config = [
|
|
'limit' => 0,
|
|
'dynfilters' => false,
|
|
'summarize' => false,
|
|
'rownumbers' => false,
|
|
'sepbyheaders' => false,
|
|
'headers' =>
|
|
[
|
|
0 => NULL,
|
|
1 => NULL,
|
|
],
|
|
'widths' =>
|
|
[],
|
|
'filter' =>
|
|
[],
|
|
'schemas' =>
|
|
[
|
|
0 =>
|
|
[
|
|
0 => 'testtable',
|
|
1 => '',
|
|
],
|
|
1 =>
|
|
[
|
|
0 => 'another',
|
|
1 => '',
|
|
],
|
|
2 =>
|
|
[
|
|
0 => 'foo',
|
|
1 => 'bar',
|
|
],
|
|
],
|
|
'cols' =>
|
|
[
|
|
0 => '%pageid%',
|
|
1 => 'count',
|
|
],
|
|
'sort' =>
|
|
[
|
|
[
|
|
0 => 'count',
|
|
1 => false,
|
|
],
|
|
[
|
|
0 => '%pageid%',
|
|
1 => true,
|
|
],
|
|
[
|
|
0 => 'bam',
|
|
1 => false,
|
|
]
|
|
],
|
|
'csv' => true,
|
|
'target' => '',
|
|
'align' => ['right', 'left', 'center', null],
|
|
'nesting' => 0,
|
|
'index' => 0,
|
|
'classes' => ['struct-custom-foo', 'struct-custom-bar'],
|
|
];
|
|
|
|
$this->assertEquals($expected_config, $actual_config);
|
|
}
|
|
|
|
public function test_width()
|
|
{
|
|
$lines = ['width: 5, 15px, 23.4em, meh, 10em'];
|
|
|
|
$configParser = new meta\ConfigParser($lines);
|
|
|
|
$config = $configParser->getConfig();
|
|
|
|
$this->assertEquals(
|
|
['5px', '15px', '23.4em', '', '10em'],
|
|
$config['widths']
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @see test_splitLine
|
|
*/
|
|
public function provide_splitLine()
|
|
{
|
|
return [
|
|
['', ['', '']],
|
|
[' ', ['', '']],
|
|
['foo', ['foo', '']],
|
|
['foo:bar', ['foo', 'bar']],
|
|
['foo: bar', ['foo', 'bar']],
|
|
['fOO: bar', ['foo', 'bar']],
|
|
[' fOO: bar ', ['foo', 'bar']],
|
|
];
|
|
}
|
|
|
|
/**
|
|
* @dataProvider provide_splitLine
|
|
*/
|
|
public function test_splitLine($line, $expected)
|
|
{
|
|
$configParser = new meta\ConfigParser(array());
|
|
$actual = $this->callInaccessibleMethod($configParser, 'splitLine', [$line]);
|
|
$this->assertEquals($expected, $actual);
|
|
}
|
|
}
|