xref: /dokuwiki/lib/plugins/config/_test/Setting/SettingTest.php (revision 98a151bacda13410294dc25f5881614c1d228099)
1*98a151baSAndreas Gohr<?php
2*98a151baSAndreas Gohr
3*98a151baSAndreas Gohrnamespace dokuwiki\plugin\config\test\Setting;
4*98a151baSAndreas Gohr
5*98a151baSAndreas Gohruse dokuwiki\plugin\config\core\Setting\Setting;
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 SettingTest extends AbstractSettingTest {
14*98a151baSAndreas Gohr
15*98a151baSAndreas Gohr    /**
16*98a151baSAndreas Gohr     * Dataprovider for test out
17*98a151baSAndreas Gohr     *
18*98a151baSAndreas Gohr     * @return array
19*98a151baSAndreas Gohr     */
20*98a151baSAndreas Gohr    public function dataOut() {
21*98a151baSAndreas Gohr        return [
22*98a151baSAndreas Gohr            ['bar', "\$conf['test'] = 'bar';\n"],
23*98a151baSAndreas Gohr            ["foo'bar", "\$conf['test'] = 'foo\\'bar';\n"],
24*98a151baSAndreas Gohr        ];
25*98a151baSAndreas Gohr    }
26*98a151baSAndreas Gohr
27*98a151baSAndreas Gohr    /**
28*98a151baSAndreas Gohr     * Check the output
29*98a151baSAndreas Gohr     *
30*98a151baSAndreas Gohr     * @param mixed $in The value to initialize the setting with
31*98a151baSAndreas Gohr     * @param string $out The expected output (for conf[test])
32*98a151baSAndreas Gohr     * @dataProvider dataOut
33*98a151baSAndreas Gohr     */
34*98a151baSAndreas Gohr    public function testOut($in, $out) {
35*98a151baSAndreas Gohr        /** @var Setting $setting */
36*98a151baSAndreas Gohr        #$setting = new $this->class('test');
37*98a151baSAndreas Gohr        $setting = new Setting('test');
38*98a151baSAndreas Gohr        $setting->initialize('ignore', $in);
39*98a151baSAndreas Gohr
40*98a151baSAndreas Gohr        $this->assertEquals($out, $setting->out('conf'));
41*98a151baSAndreas Gohr    }
42*98a151baSAndreas Gohr}
43