1
|
|
|
<?php |
2
|
|
|
namespace Redaxscript\Tests\Admin\Controller; |
3
|
|
|
|
4
|
|
|
use Redaxscript\Admin; |
5
|
|
|
use Redaxscript\Tests\TestCaseAbstract; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* SettingTest |
9
|
|
|
* |
10
|
|
|
* @since 4.1.0 |
11
|
|
|
* |
12
|
|
|
* @package Redaxscript |
13
|
|
|
* @category Tests |
14
|
|
|
* @author Henry Ruhs |
15
|
|
|
* |
16
|
|
|
* @covers Redaxscript\Admin\Controller\Setting |
17
|
|
|
* @covers Redaxscript\Admin\Controller\ControllerAbstract |
18
|
|
|
*/ |
19
|
|
|
|
20
|
|
|
class SettingTest extends TestCaseAbstract |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* setUp |
24
|
|
|
* |
25
|
|
|
* @since 4.1.0 |
26
|
|
|
*/ |
27
|
|
|
|
28
|
|
|
public function setUp() : void |
29
|
|
|
{ |
30
|
|
|
parent::setUp(); |
31
|
|
|
$optionArray = $this->getOptionArray(); |
32
|
|
|
$installer = $this->installerFactory(); |
33
|
|
|
$installer->init(); |
34
|
|
|
$installer->rawCreate(); |
35
|
|
|
$installer->insertSettings($optionArray); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* tearDown |
40
|
|
|
* |
41
|
|
|
* @since 4.1.0 |
42
|
|
|
*/ |
43
|
|
|
|
44
|
|
|
public function tearDown() : void |
45
|
|
|
{ |
46
|
|
|
$this->dropDatabase(); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
/** |
50
|
|
|
* testUpdate |
51
|
|
|
* |
52
|
|
|
* @since 4.1.0 |
53
|
|
|
* |
54
|
|
|
* @param array $registryArray |
55
|
|
|
* @param array $postArray |
56
|
|
|
* @param string $expect |
57
|
|
|
* |
58
|
|
|
* @dataProvider providerAutoloader |
59
|
|
|
*/ |
60
|
|
|
|
61
|
|
|
public function testUpdate(array $registryArray = [], array $postArray = [], string $expect = null) : void |
62
|
|
|
{ |
63
|
|
|
/* setup */ |
64
|
|
|
|
65
|
|
|
$this->_registry->init($registryArray); |
66
|
|
|
$this->_request->set('post', $postArray); |
67
|
|
|
$settingController = new Admin\Controller\Setting($this->_registry, $this->_request, $this->_language, $this->_config); |
68
|
|
|
|
69
|
|
|
/* actual */ |
70
|
|
|
|
71
|
|
|
$actual = $settingController->process('update'); |
72
|
|
|
|
73
|
|
|
/* compare */ |
74
|
|
|
|
75
|
|
|
$this->assertEquals($expect, $actual); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* testInvalid |
80
|
|
|
* |
81
|
|
|
* @since 4.1.0 |
82
|
|
|
* |
83
|
|
|
* @param array $registryArray |
84
|
|
|
* @param array $postArray |
85
|
|
|
* @param string $expect |
86
|
|
|
* |
87
|
|
|
* @dataProvider providerAutoloader |
88
|
|
|
*/ |
89
|
|
|
|
90
|
|
|
public function testInvalid(array $registryArray = [], array $postArray = [], string $expect = null) : void |
91
|
|
|
{ |
92
|
|
|
/* setup */ |
93
|
|
|
|
94
|
|
|
$this->_registry->init($registryArray); |
95
|
|
|
$this->_request->set('post', $postArray); |
96
|
|
|
$settingController = new Admin\Controller\Setting($this->_registry, $this->_request, $this->_language, $this->_config); |
97
|
|
|
|
98
|
|
|
/* actual */ |
99
|
|
|
|
100
|
|
|
$actual = $settingController->process('invalid'); |
101
|
|
|
|
102
|
|
|
/* compare */ |
103
|
|
|
|
104
|
|
|
$this->assertEquals($expect, $actual); |
105
|
|
|
} |
106
|
|
|
} |
107
|
|
|
|