1*98a151baSAndreas Gohr<?php 2*98a151baSAndreas Gohr 3*98a151baSAndreas Gohrnamespace dokuwiki\plugin\config\test; 4*98a151baSAndreas Gohr 5*98a151baSAndreas Gohruse dokuwiki\plugin\config\core\ConfigParser; 6*98a151baSAndreas Gohr 7*98a151baSAndreas Gohr/** 8*98a151baSAndreas Gohr * @group plugin_config 9*98a151baSAndreas Gohr * @group admin_plugins 10*98a151baSAndreas Gohr * @group plugins 11*98a151baSAndreas Gohr * @group bundled_plugins 12*98a151baSAndreas Gohr */ 13*98a151baSAndreas Gohrclass ConfigParserTest extends \DokuWikiTest { 14*98a151baSAndreas Gohr 15*98a151baSAndreas Gohr function test_readconfig() { 16*98a151baSAndreas Gohr $parser = new ConfigParser(); 17*98a151baSAndreas Gohr $conf = $parser->parse(__DIR__ . '/data/config.php'); 18*98a151baSAndreas Gohr 19*98a151baSAndreas Gohr // var_dump($conf); 20*98a151baSAndreas Gohr 21*98a151baSAndreas Gohr $this->assertEquals('42', $conf['int1']); 22*98a151baSAndreas Gohr $this->assertEquals('6*7', $conf['int2']); 23*98a151baSAndreas Gohr 24*98a151baSAndreas Gohr $this->assertEquals('Hello World', $conf['str1']); 25*98a151baSAndreas Gohr $this->assertEquals('G\'day World', $conf['str2']); 26*98a151baSAndreas Gohr $this->assertEquals('Hello World', $conf['str3']); 27*98a151baSAndreas Gohr $this->assertEquals("Hello 'World'", $conf['str4']); 28*98a151baSAndreas Gohr $this->assertEquals('Hello "World"', $conf['str5']); 29*98a151baSAndreas Gohr 30*98a151baSAndreas Gohr $this->assertEquals(array('foo', 'bar', 'baz'), $conf['arr1']); 31*98a151baSAndreas Gohr } 32*98a151baSAndreas Gohr 33*98a151baSAndreas Gohr function test_readconfig_onoff() { 34*98a151baSAndreas Gohr $parser = new ConfigParser(); 35*98a151baSAndreas Gohr $conf = $parser->parse(__DIR__ . '/data/config.php'); 36*98a151baSAndreas Gohr 37*98a151baSAndreas Gohr // var_dump($conf); 38*98a151baSAndreas Gohr 39*98a151baSAndreas Gohr $this->assertEquals(0, $conf['onoff1']); 40*98a151baSAndreas Gohr $this->assertEquals(1, $conf['onoff2']); 41*98a151baSAndreas Gohr $this->assertEquals(2, $conf['onoff3']); 42*98a151baSAndreas Gohr $this->assertEquals(0, $conf['onoff4']); 43*98a151baSAndreas Gohr $this->assertEquals(1, $conf['onoff5']); 44*98a151baSAndreas Gohr $this->assertEquals(false, $conf['onoff6']); 45*98a151baSAndreas Gohr $this->assertEquals(true, $conf['onoff7']); 46*98a151baSAndreas Gohr $this->assertEquals('false', $conf['onoff8']); 47*98a151baSAndreas Gohr $this->assertEquals('true', $conf['onoff9']); 48*98a151baSAndreas Gohr 49*98a151baSAndreas Gohr $this->assertEquals('false senctence', $conf['str11']); 50*98a151baSAndreas Gohr $this->assertEquals('true sentence', $conf['str12']); 51*98a151baSAndreas Gohr $this->assertEquals('truesfdf', $conf['str13']); 52*98a151baSAndreas Gohr $this->assertEquals("true", $conf['str14']); 53*98a151baSAndreas Gohr $this->assertEquals("truesfdsf", $conf['str15']); 54*98a151baSAndreas Gohr 55*98a151baSAndreas Gohr $this->assertTrue($conf['onoff1'] == false); 56*98a151baSAndreas Gohr $this->assertTrue($conf['onoff2'] == true); 57*98a151baSAndreas Gohr $this->assertTrue($conf['onoff3'] == true); 58*98a151baSAndreas Gohr $this->assertTrue($conf['onoff4'] == false); 59*98a151baSAndreas Gohr $this->assertTrue($conf['onoff5'] == true); 60*98a151baSAndreas Gohr $this->assertTrue($conf['onoff6'] == false); 61*98a151baSAndreas Gohr $this->assertTrue($conf['onoff7'] == true); 62*98a151baSAndreas Gohr $this->assertTrue($conf['onoff8'] == true); //string 63*98a151baSAndreas Gohr $this->assertTrue($conf['onoff9'] == true); //string 64*98a151baSAndreas Gohr } 65*98a151baSAndreas Gohr 66*98a151baSAndreas Gohr} 67