1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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());
}
}
|