1<?php 2 3namespace dokuwiki\plugin\struct\test; 4 5/** 6 * @group plugin_struct 7 * @group plugins 8 * 9 */ 10class ConfigHelperTest extends StructTest 11{ 12 13 public static function filter_testdata() 14 { 15 return [ 16 ['a=b', [0 => 'a', 1 => '=', 2 => 'b'], false, ''], 17 ['a<b', [0 => 'a', 1 => '<', 2 => 'b'], false, ''], 18 ['a>b', [0 => 'a', 1 => '>', 2 => 'b'], false, ''], 19 ['a<=b', [0 => 'a', 1 => '<=', 2 => 'b'], false, ''], 20 ['a>=b', [0 => 'a', 1 => '>=', 2 => 'b'], false, ''], 21 ['a!=b', [0 => 'a', 1 => '!=', 2 => 'b'], false, ''], 22 ['a<>b', [0 => 'a', 1 => '<>', 2 => 'b'], false, ''], 23 ['a!~b', [0 => 'a', 1 => '!~', 2 => 'b'], false, ''], 24 ['a~b', [0 => 'a', 1 => '~', 2 => 'b'], false, ''], 25 ['a*~b', [0 => 'a', 1 => '*~', 2 => 'b'], false, ''], 26 ['a?b', [], '\dokuwiki\plugin\struct\meta\StructException', 'Exception should be thrown on unknown operator'] 27 ]; 28 } 29 30 /** 31 * @dataProvider filter_testdata 32 * 33 * @param $input_filter 34 * @param $expected_filter 35 * @param string $msg 36 */ 37 public function test_parseFilter($input_filter, $expected_filter, $expectException, $msg) 38 { 39 $confHelper = new mock\helper_plugin_struct_config(); 40 if ($expectException !== false) $this->setExpectedException($expectException); 41 42 $actual_filter = $confHelper->parseFilter($input_filter); 43 44 $this->assertSame($expected_filter, $actual_filter, $input_filter . ' ' . $msg); 45 } 46 47 public function test_parseSort_asc() 48 { 49 /** @var \helper_plugin_struct_config $confHelper */ 50 $confHelper = plugin_load('helper', 'struct_config'); 51 $teststring = "column"; 52 53 $actual_sort = $confHelper->parseSort($teststring); 54 55 $this->assertEquals([$teststring, true], $actual_sort); 56 } 57 58 public function test_parseSort_desc() 59 { 60 /** @var \helper_plugin_struct_config $confHelper */ 61 $confHelper = plugin_load('helper', 'struct_config'); 62 $teststring = "^column"; 63 64 $actual_sort = $confHelper->parseSort($teststring); 65 66 $this->assertEquals(['column', false], $actual_sort); 67 } 68} 69