This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | namespace Redaxscript\Tests\Controller; |
||
3 | |||
4 | use org\bovigo\vfs\vfsStream as Stream; |
||
5 | use org\bovigo\vfs\vfsStreamFile as StreamFile; |
||
6 | use org\bovigo\vfs\vfsStreamWrapper as StreamWrapper; |
||
7 | use Redaxscript\Controller; |
||
8 | use Redaxscript\Tests\TestCaseAbstract; |
||
9 | |||
10 | /** |
||
11 | * InstallTest |
||
12 | * |
||
13 | * @since 3.0.0 |
||
14 | * |
||
15 | * @package Redaxscript |
||
16 | * @category Tests |
||
17 | * @author Henry Ruhs |
||
18 | * @author Balázs Szilágyi |
||
19 | * |
||
20 | * @covers Redaxscript\Controller\ControllerAbstract |
||
21 | * @covers Redaxscript\Controller\Install |
||
22 | * |
||
23 | * @requires OS Linux |
||
24 | */ |
||
25 | |||
26 | class InstallTest extends TestCaseAbstract |
||
27 | { |
||
28 | /** |
||
29 | * setUp |
||
30 | * |
||
31 | * @since 3.0.0 |
||
32 | */ |
||
33 | |||
34 | public function setUp() : void |
||
35 | { |
||
36 | parent::setUp(); |
||
37 | Stream::setup('root'); |
||
38 | $file = new StreamFile('config.php'); |
||
39 | StreamWrapper::getRoot()->addChild($file); |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * tearDown |
||
44 | * |
||
45 | * @since 3.1.0 |
||
46 | */ |
||
47 | |||
48 | public function tearDown() : void |
||
49 | { |
||
50 | $this->dropDatabase(); |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * testProcess |
||
55 | * |
||
56 | * @since 3.0.0 |
||
57 | * |
||
58 | * @param array $postArray |
||
59 | * @param string $method |
||
60 | * @param string $expect |
||
61 | * |
||
62 | * @dataProvider providerAutoloader |
||
63 | */ |
||
64 | |||
65 | public function testProcess(array $postArray = [], string $method = null, string $expect = null) : void |
||
66 | { |
||
67 | /* setup */ |
||
68 | |||
69 | $postArray['db-type'] = $postArray['db-type'] === '%CURRENT%' ? $this->_config->get('dbType') : $postArray['db-type']; |
||
70 | $postArray['db-host'] = $postArray['db-host'] === '%CURRENT%' ? $this->_config->get('dbHost') : $postArray['db-host']; |
||
71 | $postArray['db-name'] = $postArray['db-name'] === '%CURRENT%' ? $this->_config->get('dbName') : $postArray['db-name']; |
||
72 | $postArray['db-user'] = $postArray['db-user'] === '%CURRENT%' ? $this->_config->get('dbUser') : $postArray['db-user']; |
||
73 | $postArray['db-password'] = $postArray['db-password'] === '%CURRENT%' ? $this->_config->get('dbPassword') : $postArray['db-password']; |
||
74 | $postArray['db-prefix'] = $postArray['db-prefix'] === '%CURRENT%' ? $this->_config->get('dbPrefix') : $postArray['db-prefix']; |
||
75 | $this->_request->set('post', $postArray); |
||
76 | $this->_config->init(Stream::url('root' . DIRECTORY_SEPARATOR . 'config.php')); |
||
77 | if ($method) |
||
0 ignored issues
–
show
|
|||
78 | { |
||
79 | $installController = $this |
||
80 | ->getMockBuilder('Redaxscript\Controller\Install') |
||
81 | ->setConstructorArgs( |
||
82 | [ |
||
83 | $this->_registry, |
||
84 | $this->_request, |
||
85 | $this->_language, |
||
86 | $this->_config |
||
87 | ]) |
||
88 | ->setMethods( |
||
89 | [ |
||
90 | $method |
||
91 | ]) |
||
92 | ->getMock(); |
||
93 | |||
94 | /* override */ |
||
95 | |||
96 | $installController |
||
97 | ->expects($this->any()) |
||
98 | ->method($method); |
||
99 | } |
||
100 | else |
||
101 | { |
||
102 | $installController = new Controller\Install($this->_registry, $this->_request, $this->_language, $this->_config); |
||
103 | } |
||
104 | |||
105 | /* actual */ |
||
106 | |||
107 | $actual = $installController->process(); |
||
108 | |||
109 | /* compare */ |
||
110 | |||
111 | $this->assertEquals($expect, $actual); |
||
112 | } |
||
113 | |||
114 | /** |
||
115 | * testValidateDatabase |
||
116 | * |
||
117 | * @since 3.0.0 |
||
118 | * |
||
119 | * @param array $postArray |
||
120 | * @param array $expectArray |
||
121 | * |
||
122 | * @dataProvider providerAutoloader |
||
123 | */ |
||
124 | |||
125 | public function testValidateDatabase(array $postArray = [], array $expectArray = []) : void |
||
126 | { |
||
127 | /* setup */ |
||
128 | |||
129 | $installController = new Controller\Install($this->_registry, $this->_request, $this->_language, $this->_config); |
||
130 | |||
131 | /* actual */ |
||
132 | |||
133 | $actualArray = $this->callMethod($installController, '_validateDatabase', |
||
134 | [ |
||
135 | $postArray |
||
136 | ]); |
||
137 | |||
138 | /* compare */ |
||
139 | |||
140 | $this->assertEquals($expectArray, $actualArray); |
||
141 | } |
||
142 | |||
143 | /** |
||
144 | * testValidateAccount |
||
145 | * |
||
146 | * @since 3.0.0 |
||
147 | * |
||
148 | * @param array $postArray |
||
149 | * @param array $expectArray |
||
150 | * |
||
151 | * @dataProvider providerAutoloader |
||
152 | */ |
||
153 | |||
154 | public function testValidateAccount(array $postArray = [], array $expectArray = []) : void |
||
155 | { |
||
156 | /* setup */ |
||
157 | |||
158 | $installController = new Controller\Install($this->_registry, $this->_request, $this->_language, $this->_config); |
||
159 | |||
160 | /* actual */ |
||
161 | |||
162 | $actualArray = $this->callMethod($installController, '_validateAccount', |
||
163 | [ |
||
164 | $postArray |
||
165 | ]); |
||
166 | |||
167 | /* compare */ |
||
168 | |||
169 | $this->assertEquals($expectArray, $actualArray); |
||
170 | } |
||
171 | |||
172 | /** |
||
173 | * testInstall |
||
174 | * |
||
175 | * @since 3.0.0 |
||
176 | * |
||
177 | * @param array $installArray |
||
178 | * @param bool $expect |
||
179 | * |
||
180 | * @dataProvider providerAutoloader |
||
181 | */ |
||
182 | |||
183 | public function testInstall(array $installArray = [], bool $expect = null) : void |
||
184 | { |
||
185 | /* setup */ |
||
186 | |||
187 | $installController = new Controller\Install($this->_registry, $this->_request, $this->_language, $this->_config); |
||
188 | |||
189 | /* actual */ |
||
190 | |||
191 | $actual = $this->callMethod($installController, '_install', |
||
192 | [ |
||
193 | $installArray |
||
194 | ]); |
||
195 | |||
196 | /* compare */ |
||
197 | |||
198 | $this->assertEquals($expect, $actual); |
||
199 | } |
||
200 | } |
||
201 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: