diff options
Diffstat (limited to 'lib/plugins/config/_test/Setting/SettingTest.php')
-rw-r--r-- | lib/plugins/config/_test/Setting/SettingTest.php | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/lib/plugins/config/_test/Setting/SettingTest.php b/lib/plugins/config/_test/Setting/SettingTest.php new file mode 100644 index 000000000..49e0662e0 --- /dev/null +++ b/lib/plugins/config/_test/Setting/SettingTest.php @@ -0,0 +1,70 @@ +<?php + +namespace dokuwiki\plugin\config\test\Setting; + +use dokuwiki\plugin\config\core\Setting\Setting; + +/** + * @group plugin_config + * @group admin_plugins + * @group plugins + * @group bundled_plugins + */ +class SettingTest extends AbstractSettingTest { + + /** + * Dataprovider for testOut() + * + * @return array + */ + public function dataOut() { + return [ + ['bar', "\$conf['test'] = 'bar';\n"], + ["foo'bar", "\$conf['test'] = 'foo\\'bar';\n"], + ]; + } + + /** + * Check the output + * + * @param mixed $in The value to initialize the setting with + * @param string $out The expected output (for conf[test]) + * @dataProvider dataOut + */ + public function testOut($in, $out) { + /** @var Setting $setting */ + $setting = new $this->class('test'); + $setting->initialize('ignore', $in); + + $this->assertEquals($out, $setting->out('conf')); + } + + /** + * DataProvider for testShouldBeSaved() + * + * @return array + */ + public function dataShouldBeSaved() { + return [ + ['default', null, false], + ['default', 'default', false], + ['default', 'new', true], + ]; + } + + /** + * Check if shouldBeSaved works as expected + * + * @dataProvider dataShouldBeSaved + * @param mixed $default The default value + * @param mixed $local The current local value + * @param bool $expect The expected outcome + */ + public function testShouldBeSaved($default, $local, $expect) { + /** @var Setting $setting */ + $setting = new $this->class('test'); + $setting->initialize($default, $local, null); + $this->assertSame($expect, $setting->shouldBeSaved()); + } + +} |