[!!!][TASK] Extract testing framework for TYPO3
[Packages/TYPO3.CMS.git] / typo3 / sysext / extbase / Tests / Unit / Mvc / Web / RequestBuilderTest.php
1 <?php
2 namespace TYPO3\CMS\Extbase\Tests\Unit\Mvc\Web;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16 use TYPO3\CMS\Core\Error\Http\PageNotFoundException;
17 use TYPO3\CMS\Extbase\Mvc\Exception;
18 use TYPO3\CMS\Extbase\Mvc\Exception\InvalidActionNameException;
19 use TYPO3\CMS\Extbase\Mvc\Exception\InvalidControllerNameException;
20
21 /**
22 * Test case
23 */
24 class RequestBuilderTest extends \TYPO3\CMS\Components\TestingFramework\Core\UnitTestCase
25 {
26 /**
27 * @var \TYPO3\CMS\Extbase\Mvc\Web\RequestBuilder|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\CMS\Components\TestingFramework\Core\AccessibleObjectInterface
28 */
29 protected $requestBuilder;
30
31 /**
32 * @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface|\PHPUnit_Framework_MockObject_MockObject
33 */
34 protected $mockConfigurationManager;
35
36 /**
37 * @var array
38 */
39 protected $configuration;
40
41 /**
42 * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject
43 */
44 protected $mockObjectManager;
45
46 /**
47 * @var \TYPO3\CMS\Extbase\Service\ExtensionService|\PHPUnit_Framework_MockObject_MockObject
48 */
49 protected $mockExtensionService;
50
51 /**
52 * @var \TYPO3\CMS\Extbase\Service\EnvironmentService|\PHPUnit_Framework_MockObject_MockObject
53 */
54 protected $mockEnvironmentService;
55
56 /**
57 * @var \TYPO3\CMS\Extbase\Mvc\Web\Request|\PHPUnit_Framework_MockObject_MockObject
58 */
59 protected $mockRequest;
60
61 protected function setUp()
62 {
63 $this->requestBuilder = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Web\RequestBuilder::class, ['dummy']);
64 $this->configuration = [
65 'userFunc' => 'Tx_Extbase_Dispatcher->dispatch',
66 'pluginName' => 'Pi1',
67 'extensionName' => 'MyExtension',
68 'controller' => 'TheFirstController',
69 'action' => 'show',
70 'controllerConfiguration' => [
71 'TheFirstController' => [
72 'actions' => ['show', 'index', 'new', 'create', 'delete', 'edit', 'update', 'setup', 'test']
73 ],
74 'TheSecondController' => [
75 'actions' => ['show', 'index']
76 ],
77 'TheThirdController' => [
78 'actions' => ['delete', 'create', 'onlyInThirdController']
79 ]
80 ]
81 ];
82 $this->mockConfigurationManager = $this->createMock(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::class);
83 $this->mockRequest = $this->createMock(\TYPO3\CMS\Extbase\Mvc\Web\Request::class);
84 $this->mockObjectManager = $this->createMock(\TYPO3\CMS\Extbase\Object\ObjectManagerInterface::class);
85 $this->mockExtensionService = $this->createMock(\TYPO3\CMS\Extbase\Service\ExtensionService::class);
86 $this->mockEnvironmentService = $this->getMockBuilder(\TYPO3\CMS\Extbase\Service\EnvironmentService::class)
87 ->setMethods(['getServerRequestMethod'])
88 ->getMock();
89 }
90
91 /**
92 * @return void
93 */
94 protected function injectDependencies()
95 {
96 $this->mockConfigurationManager->expects($this->any())->method('getConfiguration')->will($this->returnValue($this->configuration));
97 $this->requestBuilder->_set('configurationManager', $this->mockConfigurationManager);
98 $this->mockObjectManager->expects($this->any())->method('get')->with(\TYPO3\CMS\Extbase\Mvc\Web\Request::class)->will($this->returnValue($this->mockRequest));
99 $this->requestBuilder->_set('objectManager', $this->mockObjectManager);
100 $pluginNamespace = 'tx_' . strtolower(($this->configuration['extensionName'] . '_' . $this->configuration['pluginName']));
101 $this->mockExtensionService->expects($this->any())->method('getPluginNamespace')->will($this->returnValue($pluginNamespace));
102 $this->requestBuilder->_set('extensionService', $this->mockExtensionService);
103 $this->mockEnvironmentService->expects($this->any())->method('getServerRequestMethod')->will($this->returnValue('GET'));
104 $this->requestBuilder->_set('environmentService', $this->mockEnvironmentService);
105 }
106
107 /**
108 * @test
109 */
110 public function buildReturnsAWebRequestObject()
111 {
112 $this->injectDependencies();
113 $request = $this->requestBuilder->build();
114 $this->assertSame($this->mockRequest, $request);
115 }
116
117 /**
118 * @test
119 */
120 public function buildSetsRequestPluginName()
121 {
122 $this->injectDependencies();
123 $this->mockRequest->expects($this->once())->method('setPluginName')->with('Pi1');
124 $this->requestBuilder->build();
125 }
126
127 /**
128 * @test
129 */
130 public function buildSetsRequestControllerExtensionName()
131 {
132 $this->injectDependencies();
133 $this->mockRequest->expects($this->once())->method('setControllerExtensionName')->with('MyExtension');
134 $this->requestBuilder->build();
135 }
136
137 /**
138 * @test
139 */
140 public function buildSetsRequestControllerName()
141 {
142 $this->injectDependencies();
143 $this->mockRequest->expects($this->once())->method('setControllerName')->with('TheFirstController');
144 $this->requestBuilder->build();
145 }
146
147 /**
148 * @test
149 */
150 public function buildSetsRequestControllerActionName()
151 {
152 $this->injectDependencies();
153 $this->mockRequest->expects($this->once())->method('setControllerActionName')->with('show');
154 $this->requestBuilder->build();
155 }
156
157 /**
158 * @test
159 */
160 public function buildSetsRequestRequestUri()
161 {
162 $this->injectDependencies();
163 $expectedRequestUri = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL');
164 $this->mockRequest->expects($this->once())->method('setRequestUri')->with($expectedRequestUri);
165 $this->requestBuilder->build();
166 }
167
168 /**
169 * @test
170 */
171 public function buildSetsRequestBaseUri()
172 {
173 $this->injectDependencies();
174 $expectedBaseUri = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL');
175 $this->mockRequest->expects($this->once())->method('setBaseUri')->with($expectedBaseUri);
176 $this->requestBuilder->build();
177 }
178
179 /**
180 * @test
181 */
182 public function buildSetsRequestMethod()
183 {
184 $this->injectDependencies();
185 $expectedMethod = 'SomeRequestMethod';
186 $mockEnvironmentService = $this->getMockBuilder(\TYPO3\CMS\Extbase\Service\EnvironmentService::class)
187 ->setMethods(['getServerRequestMethod'])
188 ->getMock();
189 $mockEnvironmentService->expects($this->once())->method('getServerRequestMethod')->will($this->returnValue($expectedMethod));
190 $this->requestBuilder->_set('environmentService', $mockEnvironmentService);
191 $this->mockRequest->expects($this->once())->method('setMethod')->with($expectedMethod);
192 $this->requestBuilder->build();
193 }
194
195 /**
196 * @test
197 */
198 public function buildSetsVendorNameIfConfigured()
199 {
200 $this->injectDependencies();
201 $expectedVendor = 'Vendor';
202 $this->configuration['vendorName'] = $expectedVendor;
203 $mockConfigurationManager = $this->createMock(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::class);
204 $mockConfigurationManager->expects($this->any())->method('getConfiguration')->will($this->returnValue($this->configuration));
205 $this->requestBuilder->_set('configurationManager', $mockConfigurationManager);
206 $this->requestBuilder->_set('extensionService', $this->mockExtensionService);
207 $this->mockRequest->expects($this->once())->method('setControllerVendorName')->with($expectedVendor);
208 $this->requestBuilder->build();
209 }
210
211 /**
212 * @test
213 */
214 public function buildDoesNotSetVendorNameIfNotConfiguredInSecondRequest()
215 {
216 $this->injectDependencies();
217 $expectedVendor = 'Vendor';
218 $this->configuration['vendorName'] = $expectedVendor;
219
220 $mockConfigurationManager = $this->createMock(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::class);
221 $mockConfigurationManager->expects($this->any())->method('getConfiguration')->will($this->returnValue($this->configuration));
222 $this->requestBuilder->_set('configurationManager', $mockConfigurationManager);
223 $this->mockRequest->expects($this->once())->method('setControllerVendorName')->with($expectedVendor);
224
225 $this->requestBuilder->build();
226
227 unset($this->configuration['vendorName']);
228 $mockConfigurationManager = $this->createMock(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::class);
229 $mockConfigurationManager->expects($this->any())->method('getConfiguration')->will($this->returnValue($this->configuration));
230 $this->requestBuilder->_set('configurationManager', $mockConfigurationManager);
231
232 $this->mockRequest->expects($this->never())->method('setControllerVendorName');
233 $this->requestBuilder->build();
234 }
235
236 /**
237 * @test
238 */
239 public function buildThrowsExceptionIfExtensionNameIsNotConfigured()
240 {
241 $this->expectException(Exception::class);
242 $this->expectExceptionCode(1289843275);
243 unset($this->configuration['extensionName']);
244 $mockConfigurationManager = $this->createMock(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::class);
245 $mockConfigurationManager->expects($this->any())->method('getConfiguration')->will($this->returnValue($this->configuration));
246 $this->requestBuilder->_set('configurationManager', $mockConfigurationManager);
247 $this->requestBuilder->build();
248 }
249
250 /**
251 * @test
252 */
253 public function buildThrowsExceptionIfPluginNameIsNotConfigured()
254 {
255 $this->expectException(Exception::class);
256 $this->expectExceptionCode(1289843277);
257 unset($this->configuration['pluginName']);
258 $mockConfigurationManager = $this->createMock(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::class);
259 $mockConfigurationManager->expects($this->any())->method('getConfiguration')->will($this->returnValue($this->configuration));
260 $this->requestBuilder->_set('configurationManager', $mockConfigurationManager);
261 $this->requestBuilder->_set('extensionService', $this->mockExtensionService);
262 $this->requestBuilder->build();
263 }
264
265 /**
266 * @test
267 */
268 public function buildThrowsExceptionIfControllerConfigurationIsEmptyOrNotSet()
269 {
270 $this->expectException(Exception::class);
271 $this->expectExceptionCode(1316104317);
272 $this->configuration['controllerConfiguration'] = [];
273 $this->mockConfigurationManager->expects($this->any())->method('getConfiguration')->will($this->returnValue($this->configuration));
274 $this->requestBuilder->_set('configurationManager', $this->mockConfigurationManager);
275 $this->requestBuilder->_set('extensionService', $this->mockExtensionService);
276 $this->requestBuilder->build();
277 }
278
279 /**
280 * @test
281 */
282 public function buildThrowsExceptionIfControllerConfigurationHasNoDefaultActionDefined()
283 {
284 $this->expectException(Exception::class);
285 $this->expectExceptionCode(1295479651);
286 $this->configuration['controllerConfiguration']['TheFirstController'] = [];
287 $this->mockConfigurationManager->expects($this->any())->method('getConfiguration')->will($this->returnValue($this->configuration));
288 $this->requestBuilder->_set('configurationManager', $this->mockConfigurationManager);
289 $this->requestBuilder->_set('extensionService', $this->mockExtensionService);
290 $this->requestBuilder->build();
291 }
292
293 /**
294 * @test
295 */
296 public function buildThrowsExceptionIfNoDefaultControllerCanBeResolved()
297 {
298 $this->expectException(Exception::class);
299 $this->expectExceptionCode(1316104317);
300 $this->configuration['controllerConfiguration'] = [
301 '' => [
302 'actions' => ['foo']
303 ]
304 ];
305 $this->mockConfigurationManager->expects($this->any())->method('getConfiguration')->will($this->returnValue($this->configuration));
306 $this->requestBuilder->_set('configurationManager', $this->mockConfigurationManager);
307 $this->requestBuilder->_set('extensionService', $this->mockExtensionService);
308 $this->requestBuilder->build();
309 }
310
311 /**
312 * @test
313 */
314 public function buildSetsParametersFromGetAndPostVariables()
315 {
316 $this->configuration['extensionName'] = 'SomeExtensionName';
317 $this->configuration['pluginName'] = 'SomePluginName';
318 $this->injectDependencies();
319 $_GET = [
320 'tx_someotherextensionname_somepluginname' => [
321 'foo' => 'bar'
322 ],
323 'tx_someextensionname_somepluginname' => [
324 'parameter1' => 'valueGetsOverwritten',
325 'parameter2' => [
326 'parameter3' => 'value3'
327 ]
328 ]
329 ];
330 $_POST = [
331 'tx_someextensionname_someotherpluginname' => [
332 'foo' => 'bar'
333 ],
334 'tx_someextensionname_somepluginname' => [
335 'parameter1' => 'value1',
336 'parameter2' => [
337 'parameter4' => 'value4'
338 ]
339 ]
340 ];
341 $this->mockRequest->expects($this->at(8))->method('setArgument')->with('parameter1', 'value1');
342 $this->mockRequest->expects($this->at(9))->method('setArgument')->with('parameter2', ['parameter3' => 'value3', 'parameter4' => 'value4']);
343 $this->requestBuilder->build();
344 }
345
346 /**
347 * @test
348 */
349 public function buildSetsFormatFromGetAndPostVariables()
350 {
351 $this->configuration['extensionName'] = 'SomeExtensionName';
352 $this->configuration['pluginName'] = 'SomePluginName';
353 $this->injectDependencies();
354 $_GET = [
355 'tx_someextensionname_somepluginname' => [
356 'format' => 'GET'
357 ]
358 ];
359 $_POST = [
360 'tx_someextensionname_somepluginname' => [
361 'format' => 'POST'
362 ]
363 ];
364 $this->mockRequest->expects($this->at(7))->method('setFormat')->with('POST');
365 $this->requestBuilder->build();
366 }
367
368 /**
369 * @test
370 */
371 public function buildCorrectlySetsAllowedControllerActions()
372 {
373 $this->injectDependencies();
374 $expectedResult = [
375 'TheFirstController' => [
376 'show',
377 'index',
378 'new',
379 'create',
380 'delete',
381 'edit',
382 'update',
383 'setup',
384 'test'
385 ],
386 'TheSecondController' => [
387 'show',
388 'index'
389 ],
390 'TheThirdController' => [
391 'delete',
392 'create',
393 'onlyInThirdController'
394 ]
395 ];
396 $this->requestBuilder->build();
397 $actualResult = $this->requestBuilder->_get('allowedControllerActions');
398 $this->assertEquals($expectedResult, $actualResult);
399 }
400
401 /**
402 * @test
403 */
404 public function buildThrowsExceptionIfDefaultControllerCantBeDetermined()
405 {
406 $this->expectException(Exception::class);
407 $this->expectExceptionCode(1316104317);
408 $this->configuration['controllerConfiguration'] = [];
409 $this->mockConfigurationManager->expects($this->any())->method('getConfiguration')->will($this->returnValue($this->configuration));
410 $this->requestBuilder->_set('configurationManager', $this->mockConfigurationManager);
411 $this->mockExtensionService->expects($this->any())->method('getPluginNamespace')->will($this->returnValue('tx_myextension_pi1'));
412 $this->requestBuilder->_set('extensionService', $this->mockExtensionService);
413 $this->requestBuilder->build();
414 }
415
416 /**
417 * @test
418 */
419 public function buildSetsDefaultControllerIfNoControllerIsSpecified()
420 {
421 $this->injectDependencies();
422 $_GET = [
423 'tx_myextension_pi1' => [
424 'foo' => 'bar'
425 ]
426 ];
427 $this->mockRequest->expects($this->once())->method('setControllerName')->with('TheFirstController');
428 $this->requestBuilder->build();
429 }
430
431 /**
432 * @test
433 */
434 public function buildCorrectlySetsSpecifiedControllerNameIfItsAllowedForTheCurrentPlugin()
435 {
436 $this->injectDependencies();
437 $_GET = [
438 'tx_myextension_pi1' => [
439 'controller' => 'TheSecondController'
440 ]
441 ];
442 $this->mockRequest->expects($this->once())->method('setControllerName')->with('TheSecondController');
443 $this->requestBuilder->build();
444 }
445
446 /**
447 * @test
448 */
449 public function buildThrowsInvalidControllerNameExceptionIfSpecifiedControllerIsNotAllowed()
450 {
451 $this->expectException(InvalidControllerNameException::class);
452 $this->expectExceptionCode(1313855173);
453 $this->mockConfigurationManager->expects($this->any())->method('getConfiguration')->will($this->returnValue($this->configuration));
454 $this->requestBuilder->_set('configurationManager', $this->mockConfigurationManager);
455 $this->mockExtensionService->expects($this->any())->method('getPluginNamespace')->will($this->returnValue('tx_myextension_pi1'));
456 $this->requestBuilder->_set('extensionService', $this->mockExtensionService);
457 $_GET = [
458 'tx_myextension_pi1' => [
459 'controller' => 'SomeInvalidController'
460 ]
461 ];
462 $this->requestBuilder->build();
463 }
464
465 /**
466 * @test
467 */
468 public function buildThrowsPageNotFoundExceptionIfEnabledAndSpecifiedControllerIsNotAllowed()
469 {
470 $this->expectException(PageNotFoundException::class);
471 $this->expectExceptionCode(1313857897);
472 $this->configuration['mvc']['throwPageNotFoundExceptionIfActionCantBeResolved'] = 1;
473 $this->mockConfigurationManager->expects($this->any())->method('getConfiguration')->will($this->returnValue($this->configuration));
474 $this->requestBuilder->_set('configurationManager', $this->mockConfigurationManager);
475 $this->mockExtensionService->expects($this->any())->method('getPluginNamespace')->will($this->returnValue('tx_myextension_pi1'));
476 $this->requestBuilder->_set('extensionService', $this->mockExtensionService);
477 $_GET = [
478 'tx_myextension_pi1' => [
479 'controller' => 'SomeInvalidController'
480 ]
481 ];
482 $this->requestBuilder->build();
483 }
484
485 /**
486 * @test
487 */
488 public function buildSetsDefaultControllerNameIfSpecifiedControllerIsNotAllowedAndCallDefaultActionIfActionCantBeResolvedIsSet()
489 {
490 $this->configuration['mvc']['callDefaultActionIfActionCantBeResolved'] = 1;
491 $this->injectDependencies();
492 $this->requestBuilder->_set('extensionService', $this->mockExtensionService);
493 $_GET = [
494 'tx_myextension_pi1' => [
495 'controller' => 'SomeInvalidController'
496 ]
497 ];
498 $this->mockRequest->expects($this->once())->method('setControllerName')->with('TheFirstController');
499 $this->requestBuilder->build();
500 }
501
502 /**
503 * @test
504 */
505 public function buildThrowsExceptionIfDefaultActionCantBeDetermined()
506 {
507 $this->expectException(Exception::class);
508 $this->expectExceptionCode(1316104317);
509 $this->configuration['controllerConfiguration'] = [];
510 $this->mockConfigurationManager->expects($this->any())->method('getConfiguration')->will($this->returnValue($this->configuration));
511 $this->requestBuilder->_set('configurationManager', $this->mockConfigurationManager);
512 $this->mockExtensionService->expects($this->any())->method('getPluginNamespace')->will($this->returnValue('tx_myextension_pi1'));
513 $this->requestBuilder->_set('extensionService', $this->mockExtensionService);
514 $this->requestBuilder->build();
515 }
516
517 /**
518 * @test
519 */
520 public function buildSetsDefaultActionOfTheCurrentControllerIfNoActionIsSpecified()
521 {
522 $this->injectDependencies();
523 $_GET = [
524 'tx_myextension_pi1' => [
525 'controller' => 'TheThirdController'
526 ]
527 ];
528 $this->mockRequest->expects($this->once())->method('setControllerActionName')->with('delete');
529 $this->requestBuilder->build();
530 }
531
532 /**
533 * @test
534 */
535 public function buildCorrectlySetsSpecifiedActionNameForTheDefaultControllerIfItsAllowedForTheCurrentPlugin()
536 {
537 $this->injectDependencies();
538 $_GET = [
539 'tx_myextension_pi1' => [
540 'action' => 'create'
541 ]
542 ];
543 $this->mockRequest->expects($this->once())->method('setControllerActionName')->with('create');
544 $this->requestBuilder->build();
545 }
546
547 /**
548 * @test
549 */
550 public function buildCorrectlySetsSpecifiedActionNameForTheSpecifiedControllerIfItsAllowedForTheCurrentPlugin()
551 {
552 $this->injectDependencies();
553 $_GET = [
554 'tx_myextension_pi1' => [
555 'controller' => 'TheThirdController',
556 'action' => 'onlyInThirdController'
557 ]
558 ];
559 $this->mockRequest->expects($this->once())->method('setControllerActionName')->with('onlyInThirdController');
560 $this->requestBuilder->build();
561 }
562
563 /**
564 * @test
565 */
566 public function buildThrowsInvalidActionNameExceptionIfSpecifiedActionIsNotAllowed()
567 {
568 $this->expectException(InvalidActionNameException::class);
569 $this->expectExceptionCode(1313855175);
570 $this->mockConfigurationManager->expects($this->any())->method('getConfiguration')->will($this->returnValue($this->configuration));
571 $this->requestBuilder->_set('configurationManager', $this->mockConfigurationManager);
572 $this->mockExtensionService->expects($this->any())->method('getPluginNamespace')->will($this->returnValue('tx_myextension_pi1'));
573 $this->requestBuilder->_set('extensionService', $this->mockExtensionService);
574 $_GET = [
575 'tx_myextension_pi1' => [
576 'action' => 'someInvalidAction'
577 ]
578 ];
579 $this->requestBuilder->build();
580 }
581
582 /**
583 * @test
584 */
585 public function buildThrowsPageNotFoundExceptionIfEnabledAndSpecifiedActionIsNotAllowed()
586 {
587 $this->expectException(PageNotFoundException::class);
588 $this->expectExceptionCode(1313857898);
589 $this->configuration['mvc']['throwPageNotFoundExceptionIfActionCantBeResolved'] = 1;
590 $this->mockConfigurationManager->expects($this->any())->method('getConfiguration')->will($this->returnValue($this->configuration));
591 $this->requestBuilder->_set('configurationManager', $this->mockConfigurationManager);
592 $this->mockExtensionService->expects($this->any())->method('getPluginNamespace')->will($this->returnValue('tx_myextension_pi1'));
593 $this->requestBuilder->_set('extensionService', $this->mockExtensionService);
594 $_GET = [
595 'tx_myextension_pi1' => [
596 'action' => 'someInvalidAction'
597 ]
598 ];
599 $this->requestBuilder->build();
600 }
601
602 /**
603 * @test
604 */
605 public function buildSetsDefaultActionNameIfSpecifiedActionIsNotAllowedAndCallDefaultActionIfActionCantBeResolvedIsSet()
606 {
607 $this->configuration['mvc']['callDefaultActionIfActionCantBeResolved'] = 1;
608 $this->injectDependencies();
609 $this->requestBuilder->_set('extensionService', $this->mockExtensionService);
610 $_GET = [
611 'tx_myextension_pi1' => [
612 'controller' => 'TheThirdController',
613 'action' => 'someInvalidAction'
614 ]
615 ];
616 $this->mockRequest->expects($this->once())->method('setControllerName')->with('TheThirdController');
617 $this->mockRequest->expects($this->once())->method('setControllerActionName')->with('delete');
618 $this->requestBuilder->build();
619 }
620
621 /**
622 * @test
623 * @see TYPO3\Flow\Tests\Unit\Utility\EnvironmentTest
624 */
625 public function untangleFilesArrayTransformsTheFilesSuperglobalIntoAManageableForm()
626 {
627 $convolutedFiles = [
628 'a0' => [
629 'name' => [
630 'a1' => 'a.txt'
631 ],
632 'type' => [
633 'a1' => 'text/plain'
634 ],
635 'tmp_name' => [
636 'a1' => '/private/var/tmp/phpbqXsYt'
637 ],
638 'error' => [
639 'a1' => 0
640 ],
641 'size' => [
642 'a1' => 100
643 ]
644 ],
645 'b0' => [
646 'name' => [
647 'b1' => 'b.txt'
648 ],
649 'type' => [
650 'b1' => 'text/plain'
651 ],
652 'tmp_name' => [
653 'b1' => '/private/var/tmp/phpvZ6oUD'
654 ],
655 'error' => [
656 'b1' => 0
657 ],
658 'size' => [
659 'b1' => 200
660 ]
661 ],
662 'c' => [
663 'name' => 'c.txt',
664 'type' => 'text/plain',
665 'tmp_name' => '/private/var/tmp/phpS9KMNw',
666 'error' => 0,
667 'size' => 300
668 ],
669 'd0' => [
670 'name' => [
671 'd1' => [
672 'd2' => [
673 'd3' => 'd.txt'
674 ]
675 ]
676 ],
677 'type' => [
678 'd1' => [
679 'd2' => [
680 'd3' => 'text/plain'
681 ]
682 ]
683 ],
684 'tmp_name' => [
685 'd1' => [
686 'd2' => [
687 'd3' => '/private/var/tmp/phprR3fax'
688 ]
689 ]
690 ],
691 'error' => [
692 'd1' => [
693 'd2' => [
694 'd3' => 0
695 ]
696 ]
697 ],
698 'size' => [
699 'd1' => [
700 'd2' => [
701 'd3' => 400
702 ]
703 ]
704 ]
705 ],
706 'e0' => [
707 'name' => [
708 'e1' => [
709 'e2' => [
710 0 => 'e_one.txt',
711 1 => 'e_two.txt'
712 ]
713 ]
714 ],
715 'type' => [
716 'e1' => [
717 'e2' => [
718 0 => 'text/plain',
719 1 => 'text/plain'
720 ]
721 ]
722 ],
723 'tmp_name' => [
724 'e1' => [
725 'e2' => [
726 0 => '/private/var/tmp/php01fitB',
727 1 => '/private/var/tmp/phpUUB2cv'
728 ]
729 ]
730 ],
731 'error' => [
732 'e1' => [
733 'e2' => [
734 0 => 0,
735 1 => 0
736 ]
737 ]
738 ],
739 'size' => [
740 'e1' => [
741 'e2' => [
742 0 => 510,
743 1 => 520
744 ]
745 ]
746 ]
747 ]
748 ];
749 $untangledFiles = [
750 'a0' => [
751 'a1' => [
752 'name' => 'a.txt',
753 'type' => 'text/plain',
754 'tmp_name' => '/private/var/tmp/phpbqXsYt',
755 'error' => 0,
756 'size' => 100
757 ]
758 ],
759 'b0' => [
760 'b1' => [
761 'name' => 'b.txt',
762 'type' => 'text/plain',
763 'tmp_name' => '/private/var/tmp/phpvZ6oUD',
764 'error' => 0,
765 'size' => 200
766 ]
767 ],
768 'c' => [
769 'name' => 'c.txt',
770 'type' => 'text/plain',
771 'tmp_name' => '/private/var/tmp/phpS9KMNw',
772 'error' => 0,
773 'size' => 300
774 ],
775 'd0' => [
776 'd1' => [
777 'd2' => [
778 'd3' => [
779 'name' => 'd.txt',
780 'type' => 'text/plain',
781 'tmp_name' => '/private/var/tmp/phprR3fax',
782 'error' => 0,
783 'size' => 400
784 ]
785 ]
786 ]
787 ],
788 'e0' => [
789 'e1' => [
790 'e2' => [
791 0 => [
792 'name' => 'e_one.txt',
793 'type' => 'text/plain',
794 'tmp_name' => '/private/var/tmp/php01fitB',
795 'error' => 0,
796 'size' => 510
797 ],
798 1 => [
799 'name' => 'e_two.txt',
800 'type' => 'text/plain',
801 'tmp_name' => '/private/var/tmp/phpUUB2cv',
802 'error' => 0,
803 'size' => 520
804 ]
805 ]
806 ]
807 ]
808 ];
809 $requestBuilder = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Mvc\Web\RequestBuilder::class, ['dummy'], [], '', false);
810 $result = $requestBuilder->_call('untangleFilesArray', $convolutedFiles);
811 $this->assertSame($untangledFiles, $result);
812 }
813 }