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\Html; |
||
3 | |||
4 | use Redaxscript\Html; |
||
5 | use Redaxscript\Tests\TestCaseAbstract; |
||
6 | |||
7 | /** |
||
8 | * FormTest |
||
9 | * |
||
10 | * @since 2.6.0 |
||
11 | * |
||
12 | * @package Redaxscript |
||
13 | * @category Tests |
||
14 | * @author Henry Ruhs |
||
15 | * |
||
16 | * @covers Redaxscript\Html\Form |
||
17 | */ |
||
18 | |||
19 | class FormTest extends TestCaseAbstract |
||
20 | { |
||
21 | /** |
||
22 | * setUp |
||
23 | * |
||
24 | * @since 3.1.0 |
||
25 | */ |
||
26 | |||
27 | public function setUp() : void |
||
28 | { |
||
29 | parent::setUp(); |
||
30 | $optionArray = $this->getOptionArray(); |
||
0 ignored issues
–
show
|
|||
31 | $installer = $this->installerFactory(); |
||
0 ignored issues
–
show
The method
installerFactory() does not seem to exist on object<Redaxscript\Tests\Html\FormTest> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
32 | $installer->init(); |
||
33 | $installer->rawCreate(); |
||
34 | $installer->insertSettings($optionArray); |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * tearDown |
||
39 | * |
||
40 | * @since 3.1.0 |
||
41 | */ |
||
42 | |||
43 | public function tearDown() : void |
||
44 | { |
||
45 | $this->dropDatabase(); |
||
0 ignored issues
–
show
The method
dropDatabase() does not seem to exist on object<Redaxscript\Tests\Html\FormTest> .
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed.
Loading history...
|
|||
46 | } |
||
47 | |||
48 | /** |
||
49 | * testCreate |
||
50 | * |
||
51 | * @since 2.6.0 |
||
52 | * |
||
53 | * @param array $attributeArray |
||
54 | * @param array $optionArray |
||
55 | * @param string $expect |
||
56 | * |
||
57 | * @dataProvider providerAutoloader |
||
58 | */ |
||
59 | |||
60 | public function testCreate(array $attributeArray = [], array $optionArray = [], string $expect = null) : void |
||
61 | { |
||
62 | /* setup */ |
||
63 | |||
64 | $form = new Html\Form($this->_registry, $this->_language); |
||
65 | $form->init($attributeArray, $optionArray); |
||
66 | |||
67 | /* actual */ |
||
68 | |||
69 | $actual = $form; |
||
70 | |||
71 | /* compare */ |
||
72 | |||
73 | $this->assertEquals($expect, $actual); |
||
74 | } |
||
75 | |||
76 | /** |
||
77 | * testLegend |
||
78 | * |
||
79 | * @since 2.6.0 |
||
80 | * |
||
81 | * @param string $text |
||
82 | * @param array $attributeArray |
||
83 | * @param string $expect |
||
84 | * |
||
85 | * @dataProvider providerAutoloader |
||
86 | */ |
||
87 | |||
88 | public function testLegend(string $text = null, ?array $attributeArray = [], string $expect = null) : void |
||
89 | { |
||
90 | /* setup */ |
||
91 | |||
92 | $form = new Html\Form($this->_registry, $this->_language); |
||
93 | $form->init(); |
||
94 | $form->legend($text, $attributeArray); |
||
95 | |||
96 | /* actual */ |
||
97 | |||
98 | $actual = $form; |
||
99 | |||
100 | /* compare */ |
||
101 | |||
102 | $this->assertEquals($expect, $actual); |
||
103 | } |
||
104 | |||
105 | /** |
||
106 | * testLabel |
||
107 | * |
||
108 | * @since 2.6.0 |
||
109 | * |
||
110 | * @param string $text |
||
111 | * @param array $attributeArray |
||
112 | * @param string $expect |
||
113 | * |
||
114 | * @dataProvider providerAutoloader |
||
115 | */ |
||
116 | |||
117 | public function testLabel(string $text = null, ?array $attributeArray = [], string $expect = null) : void |
||
118 | { |
||
119 | /* setup */ |
||
120 | |||
121 | $form = new Html\Form($this->_registry, $this->_language); |
||
122 | $form->init(); |
||
123 | $form->label($text, $attributeArray); |
||
124 | |||
125 | /* actual */ |
||
126 | |||
127 | $actual = $form; |
||
128 | |||
129 | /* compare */ |
||
130 | |||
131 | $this->assertEquals($expect, $actual); |
||
132 | } |
||
133 | |||
134 | /** |
||
135 | * testInput |
||
136 | * |
||
137 | * @since 2.6.0 |
||
138 | * |
||
139 | * @param string $method |
||
140 | * @param array $attributeArray |
||
141 | * @param string $expect |
||
142 | * |
||
143 | * @dataProvider providerAutoloader |
||
144 | */ |
||
145 | |||
146 | public function testInput(string $method = null, ?array $attributeArray = [], string $expect = null) : void |
||
147 | { |
||
148 | /* setup */ |
||
149 | |||
150 | $form = new Html\Form($this->_registry, $this->_language); |
||
151 | $form->init(); |
||
152 | $form->$method($attributeArray); |
||
153 | |||
154 | /* actual */ |
||
155 | |||
156 | $actual = $form->render(); |
||
157 | |||
158 | /* compare */ |
||
159 | |||
160 | $this->assertEquals($expect, $actual); |
||
161 | } |
||
162 | |||
163 | /** |
||
164 | * testTextarea |
||
165 | * |
||
166 | * @since 2.6.0 |
||
167 | * |
||
168 | * @param array $attributeArray |
||
169 | * @param string $expect |
||
170 | * |
||
171 | * @dataProvider providerAutoloader |
||
172 | */ |
||
173 | |||
174 | public function testTextarea(?array $attributeArray = [], string $expect = null) : void |
||
175 | { |
||
176 | /* setup */ |
||
177 | |||
178 | $form = new Html\Form($this->_registry, $this->_language); |
||
179 | $form->init(); |
||
180 | $form->textarea($attributeArray); |
||
181 | |||
182 | /* actual */ |
||
183 | |||
184 | $actual = $form; |
||
185 | |||
186 | /* compare */ |
||
187 | |||
188 | $this->assertEquals($expect, $actual); |
||
189 | } |
||
190 | |||
191 | /** |
||
192 | * testSelect |
||
193 | * |
||
194 | * @since 3.1.0 |
||
195 | * |
||
196 | * @param array $optionArray |
||
197 | * @param array $selectArray |
||
198 | * @param array|null $attributeArray |
||
199 | * @param string $expect |
||
200 | * |
||
201 | * @dataProvider providerAutoloader |
||
202 | */ |
||
203 | |||
204 | public function testSelect(array $optionArray = [], array $selectArray = [], ?array $attributeArray = [], string $expect = null) : void |
||
205 | { |
||
206 | /* setup */ |
||
207 | |||
208 | $form = new Html\Form($this->_registry, $this->_language); |
||
209 | $form->init(); |
||
210 | $form->select($optionArray, $selectArray, $attributeArray); |
||
211 | |||
212 | /* actual */ |
||
213 | |||
214 | $actual = $form; |
||
215 | |||
216 | /* compare */ |
||
217 | |||
218 | $this->assertEquals($expect, $actual); |
||
219 | } |
||
220 | |||
221 | /** |
||
222 | * testSelectRange |
||
223 | * |
||
224 | * @since 3.0.0 |
||
225 | * |
||
226 | * @param array $rangeArray |
||
227 | * @param array $selectArray |
||
228 | * @param array|null $attributeArray |
||
229 | * @param string $expect |
||
230 | * |
||
231 | * @dataProvider providerAutoloader |
||
232 | |||
233 | */ |
||
234 | |||
235 | public function testSelectRange(array $rangeArray = [], array $selectArray = [], ?array $attributeArray = [], string $expect = null) : void |
||
236 | { |
||
237 | /* setup */ |
||
238 | |||
239 | $form = new Html\Form($this->_registry, $this->_language); |
||
240 | $form->init(); |
||
241 | $form->selectRange($rangeArray, $selectArray, $attributeArray); |
||
242 | |||
243 | /* actual */ |
||
244 | |||
245 | $actual = $form; |
||
246 | |||
247 | /* compare */ |
||
248 | |||
249 | $this->assertEquals($expect, $actual); |
||
250 | } |
||
251 | |||
252 | /** |
||
253 | * testCaptcha |
||
254 | * |
||
255 | * @since 3.0.0 |
||
256 | * |
||
257 | * @param array $expectArray |
||
258 | * |
||
259 | * @dataProvider providerAutoloader |
||
260 | */ |
||
261 | |||
262 | public function testCaptcha(array $expectArray = []) : void |
||
263 | { |
||
264 | /* setup */ |
||
265 | |||
266 | $form = new Html\Form($this->_registry, $this->_language); |
||
267 | $form->init([], |
||
268 | [ |
||
269 | 'captcha' => true |
||
270 | ]); |
||
271 | $form->captcha($expectArray['type']); |
||
272 | |||
273 | /* actual */ |
||
274 | |||
275 | $actual = $form->render(); |
||
276 | |||
277 | /* compare */ |
||
278 | |||
279 | $this->assertStringStartsWith($expectArray['start'], $actual); |
||
280 | $this->assertStringEndsWith($expectArray['end'], $actual); |
||
281 | } |
||
282 | |||
283 | /** |
||
284 | * testToken |
||
285 | * |
||
286 | * @since 3.0.0 |
||
287 | * |
||
288 | * @param array $registryArray |
||
289 | * @param string $expect |
||
290 | * |
||
291 | * @dataProvider providerAutoloader |
||
292 | */ |
||
293 | |||
294 | public function testToken(array $registryArray = [], string $expect = null) : void |
||
295 | { |
||
296 | /* setup */ |
||
297 | |||
298 | $this->_registry->init($registryArray); |
||
299 | $form = new Html\Form($this->_registry, $this->_language); |
||
300 | $form->init(); |
||
301 | $form->token(); |
||
302 | |||
303 | /* actual */ |
||
304 | |||
305 | $actual = $form; |
||
306 | |||
307 | /* compare */ |
||
308 | |||
309 | $this->assertEquals($expect, $actual); |
||
310 | } |
||
311 | |||
312 | /** |
||
313 | * testButton |
||
314 | * |
||
315 | * @since 2.6.0 |
||
316 | * |
||
317 | * @param string $method |
||
318 | * @param string $text |
||
319 | * @param array|null $attributeArray |
||
320 | * @param string $expect |
||
321 | * |
||
322 | * @dataProvider providerAutoloader |
||
323 | */ |
||
324 | |||
325 | public function testButton(string $method = null, string $text = null, ?array $attributeArray = [], string $expect = null) : void |
||
326 | { |
||
327 | /* setup */ |
||
328 | |||
329 | $form = new Html\Form($this->_registry, $this->_language); |
||
330 | $form->init(); |
||
331 | $form->$method($text, $attributeArray); |
||
332 | |||
333 | /* actual */ |
||
334 | |||
335 | $actual = $form; |
||
336 | |||
337 | /* compare */ |
||
338 | |||
339 | $this->assertEquals($expect, $actual); |
||
340 | } |
||
341 | |||
342 | /** |
||
343 | * testLink |
||
344 | * |
||
345 | * @since 3.0.0 |
||
346 | * |
||
347 | * @param string $method |
||
348 | * @param string $text |
||
349 | * @param array|null $attributeArray |
||
350 | * @param string $expect |
||
351 | * |
||
352 | * @dataProvider providerAutoloader |
||
353 | */ |
||
354 | |||
355 | public function testLink(string $method = null, string $text = null, ?array $attributeArray = [], string $expect = null) : void |
||
356 | { |
||
357 | /* setup */ |
||
358 | |||
359 | $form = new Html\Form($this->_registry, $this->_language); |
||
360 | $form->init(); |
||
361 | $form->$method($text, $attributeArray); |
||
362 | |||
363 | /* actual */ |
||
364 | |||
365 | $actual = $form; |
||
366 | |||
367 | /* compare */ |
||
368 | |||
369 | $this->assertEquals($expect, $actual); |
||
370 | } |
||
371 | } |
||
372 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.