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; |
||
3 | |||
4 | use PHPUnitProviderAutoloader; |
||
5 | use Redaxscript\Config; |
||
6 | use Redaxscript\Db; |
||
7 | use Redaxscript\Installer; |
||
8 | use Redaxscript\Language; |
||
9 | use Redaxscript\Model; |
||
10 | use Redaxscript\Modules\TestDummy; |
||
11 | use Redaxscript\Registry; |
||
12 | use Redaxscript\Request; |
||
13 | use ReflectionClass; |
||
14 | use function chr; |
||
15 | use function file_exists; |
||
16 | use function file_get_contents; |
||
17 | use function function_exists; |
||
18 | use function json_decode; |
||
19 | use function str_replace; |
||
20 | use function xdebug_get_headers; |
||
21 | |||
22 | /** |
||
23 | * TestCaseAbstract |
||
24 | * |
||
25 | * @since 2.2.0 |
||
26 | * |
||
27 | * @package Redaxscript |
||
28 | * @category Tests |
||
29 | * @author Henry Ruhs |
||
30 | */ |
||
31 | |||
32 | abstract class TestCaseAbstract extends PHPUnitProviderAutoloader\TestCaseAbstract |
||
33 | { |
||
34 | /** |
||
35 | * instance of the registry class |
||
36 | * |
||
37 | * @var Registry |
||
38 | */ |
||
39 | |||
40 | protected Registry $_registry; |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
41 | |||
42 | /** |
||
43 | * instance of the request class |
||
44 | * |
||
45 | * @var Request |
||
46 | */ |
||
47 | |||
48 | protected Request $_request; |
||
49 | |||
50 | /** |
||
51 | * instance of the language class |
||
52 | * |
||
53 | * @var Language |
||
54 | */ |
||
55 | |||
56 | protected Language $_language; |
||
57 | |||
58 | /** |
||
59 | * instance of the config class |
||
60 | * |
||
61 | * @var Config |
||
62 | */ |
||
63 | |||
64 | protected Config $_config; |
||
65 | |||
66 | /** |
||
67 | * directory of the provider |
||
68 | * |
||
69 | * @var string |
||
70 | */ |
||
71 | |||
72 | protected $_providerDirectory = 'tests' . DIRECTORY_SEPARATOR . 'unit-provider'; |
||
73 | |||
74 | /** |
||
75 | * namespace of the testing suite |
||
76 | * |
||
77 | * @var string |
||
78 | */ |
||
79 | |||
80 | protected $_testNamespace = __NAMESPACE__; |
||
81 | |||
82 | /** |
||
83 | * setUp |
||
84 | * |
||
85 | * @since 3.1.0 |
||
86 | */ |
||
87 | |||
88 | public function setUp() : void |
||
89 | { |
||
90 | Db::clearCache(); |
||
91 | $this->_registry = Registry::getInstance(); |
||
92 | $this->_request = Request::getInstance(); |
||
93 | $this->_language = Language::getInstance(); |
||
94 | $this->_config = Config::getInstance(); |
||
95 | } |
||
96 | |||
97 | /** |
||
98 | * installerFactory |
||
99 | * |
||
100 | * @since 3.1.0 |
||
101 | * |
||
102 | * @return Installer |
||
103 | */ |
||
104 | |||
105 | public function installerFactory() : Installer |
||
106 | { |
||
107 | return new Installer($this->_registry, $this->_request, $this->_language, $this->_config); |
||
108 | } |
||
109 | |||
110 | /** |
||
111 | * settingFactory |
||
112 | * |
||
113 | * @since 3.3.0 |
||
114 | * |
||
115 | * @return Model\Setting |
||
116 | */ |
||
117 | |||
118 | public function settingFactory() : Model\Setting |
||
119 | { |
||
120 | return new Model\Setting(); |
||
121 | } |
||
122 | |||
123 | /** |
||
124 | * createDatabase |
||
125 | * |
||
126 | * @since 4.0.0 |
||
127 | */ |
||
128 | |||
129 | public function createDatabase() : void |
||
130 | { |
||
131 | $installer = $this->installerFactory(); |
||
132 | $installer->init(); |
||
133 | $installer->rawCreate(); |
||
134 | } |
||
135 | |||
136 | /** |
||
137 | * dropDatabase |
||
138 | * |
||
139 | * @since 4.0.0 |
||
140 | */ |
||
141 | |||
142 | public function dropDatabase() : void |
||
143 | { |
||
144 | $installer = $this->installerFactory(); |
||
145 | $installer->init(); |
||
146 | $installer->rawDrop(); |
||
147 | } |
||
148 | /** |
||
149 | * getOptionArray |
||
150 | * |
||
151 | * @since 4.1.0 |
||
152 | */ |
||
153 | |||
154 | public function getOptionArray() : array |
||
155 | { |
||
156 | return |
||
157 | [ |
||
158 | 'adminName' => 'Test', |
||
159 | 'adminUser' => 'test', |
||
160 | 'adminPassword' => 'aaAA00AAaa', |
||
161 | 'adminEmail' => '[email protected]' |
||
162 | ]; |
||
163 | } |
||
164 | |||
165 | /** |
||
166 | * installTestDummy |
||
167 | * |
||
168 | * @since 4.0.0 |
||
169 | */ |
||
170 | |||
171 | public function installTestDummy() : void |
||
172 | { |
||
173 | $testDummy = new TestDummy\TestDummy($this->_registry, $this->_request, $this->_language, $this->_config); |
||
174 | $testDummy->install(); |
||
175 | } |
||
176 | |||
177 | /** |
||
178 | * uninstallTestDummy |
||
179 | * |
||
180 | * @since 4.0.0 |
||
181 | */ |
||
182 | |||
183 | public function uninstallTestDummy() : void |
||
184 | { |
||
185 | $testDummy = new TestDummy\TestDummy($this->_registry, $this->_request, $this->_language, $this->_config); |
||
186 | $testDummy->clearNotification('success'); |
||
187 | $testDummy->clearNotification('warning'); |
||
188 | $testDummy->clearNotification('error'); |
||
189 | $testDummy->clearNotification('info'); |
||
190 | $testDummy->uninstall(); |
||
191 | } |
||
192 | |||
193 | /** |
||
194 | * getJSON |
||
195 | * |
||
196 | * @since 4.0.0 |
||
197 | * |
||
198 | * @param string $file |
||
199 | * |
||
200 | * @return array|null |
||
201 | */ |
||
202 | |||
203 | public function getJSON(string $file = null) : ?array |
||
204 | { |
||
205 | if (file_exists($file)) |
||
206 | { |
||
207 | $content = file_get_contents($file); |
||
208 | return json_decode($content, true); |
||
209 | } |
||
210 | } |
||
211 | |||
212 | /** |
||
213 | * getProperty |
||
214 | * |
||
215 | * @since 3.0.0 |
||
216 | * |
||
217 | * @param object $object |
||
218 | * @param string $property |
||
219 | * |
||
220 | * @return array|object |
||
221 | */ |
||
222 | |||
223 | public function getProperty(object $object = null, string $property = null) |
||
224 | { |
||
225 | $reflection = new ReflectionClass($object); |
||
226 | $reflectionProperty = $reflection->getProperty($property); |
||
227 | $reflectionProperty->setAccessible(true); |
||
228 | return $reflectionProperty->getValue($object); |
||
229 | } |
||
230 | |||
231 | /** |
||
232 | * callMethod |
||
233 | * |
||
234 | * @since 3.0.0 |
||
235 | * |
||
236 | * @param object $object |
||
237 | * @param string $method |
||
238 | * @param array $argumentArray |
||
239 | * |
||
240 | * @return array|object |
||
241 | */ |
||
242 | |||
243 | public function callMethod(object $object = null, string $method = null, array $argumentArray = []) |
||
244 | { |
||
245 | $reflection = new ReflectionClass($object); |
||
246 | $reflectionMethod = $reflection->getMethod($method); |
||
247 | $reflectionMethod->setAccessible(true); |
||
248 | return $reflectionMethod->invokeArgs($object, $argumentArray); |
||
249 | } |
||
250 | |||
251 | /** |
||
252 | * normalizeSeparator |
||
253 | * |
||
254 | * @since 3.2.0 |
||
255 | * |
||
256 | * @param string $actual |
||
257 | * |
||
258 | * @return string |
||
259 | */ |
||
260 | |||
261 | public function normalizeSeparator(string $actual = null) : string |
||
262 | { |
||
263 | return str_replace(DIRECTORY_SEPARATOR, chr(47), $actual); |
||
264 | } |
||
265 | |||
266 | /** |
||
267 | * normalizeNewline |
||
268 | * |
||
269 | * @since 3.0.0 |
||
270 | * |
||
271 | * @param string $actual |
||
272 | * |
||
273 | * @return string |
||
274 | */ |
||
275 | |||
276 | public function normalizeNewline(string $actual = null) : string |
||
277 | { |
||
278 | return str_replace(PHP_EOL, chr(10), $actual); |
||
279 | } |
||
280 | |||
281 | /** |
||
282 | * getHeaderArray |
||
283 | * |
||
284 | * @since 3.0.0 |
||
285 | * |
||
286 | * @return array|null |
||
287 | */ |
||
288 | |||
289 | public function getHeaderArray() : ?array |
||
290 | { |
||
291 | if (function_exists('xdebug_get_headers')) |
||
292 | { |
||
293 | return xdebug_get_headers(); |
||
294 | } |
||
295 | $this->markTestSkipped(); |
||
296 | return null; |
||
297 | } |
||
298 | } |
||
299 |