‪TYPO3CMS  10.4
RequestBuilderTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
33 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
34 
35 class ‪RequestBuilderTest extends FunctionalTestCase
36 {
41  {
42  $extensionName = 'blog_example';
43  $pluginName = 'blog';
44 
45  ‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers']['ExtbaseTeam\BlogExample\Controller\BlogController'] = [
46  'className' => 'ExtbaseTeam\BlogExample\Controller\BlogController',
47  'alias' => 'BlogController',
48  'actions' => [
49  'list'
50  ]
51  ];
52 
53  $configuration = [];
54  $configuration['extensionName'] = $extensionName;
55  $configuration['pluginName'] = $pluginName;
56 
58  $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
59  $configurationManager->setConfiguration($configuration);
60 
61  $requestBuilder = $this->getContainer()->get(RequestBuilder::class);
62  $request = $requestBuilder->build();
63 
64  self::assertInstanceOf(RequestInterface::class, $request);
65  self::assertSame('html', $request->getFormat());
66  }
67 
72  {
73  $extensionName = 'blog_example';
74  $pluginName = 'blog';
75 
76  ‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers']['ExtbaseTeam\BlogExample\Controller\BlogController'] = [
77  'className' => 'ExtbaseTeam\BlogExample\Controller\BlogController',
78  'alias' => 'BlogController',
79  'actions' => [
80  'list'
81  ]
82  ];
83 
84  $configuration = [];
85  $configuration['extensionName'] = $extensionName;
86  $configuration['pluginName'] = $pluginName;
87  $configuration['format'] = 'json';
88 
90  $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
91  $configurationManager->setConfiguration($configuration);
92 
93  $requestBuilder = $this->getContainer()->get(RequestBuilder::class);
94  $request = $requestBuilder->build();
95 
96  self::assertInstanceOf(RequestInterface::class, $request);
97  self::assertSame('json', $request->getFormat());
98  }
99 
104  {
105  $_GET['tx_blog_example_blog']['format'] = 'json';
106 
107  $extensionName = 'blog_example';
108  $pluginName = 'blog';
109 
110  ‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers']['ExtbaseTeam\BlogExample\Controller\BlogController'] = [
111  'className' => 'ExtbaseTeam\BlogExample\Controller\BlogController',
112  'alias' => 'BlogController',
113  'actions' => [
114  'list'
115  ]
116  ];
117 
118  $configuration = [];
119  $configuration['extensionName'] = $extensionName;
120  $configuration['pluginName'] = $pluginName;
121 
123  $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
124  $configurationManager->setConfiguration($configuration);
125 
126  $requestBuilder = $this->getContainer()->get(RequestBuilder::class);
127  $request = $requestBuilder->build();
128 
129  self::assertInstanceOf(RequestInterface::class, $request);
130  self::assertSame('json', $request->getFormat());
131  }
132 
137  {
138  static::expectException(Exception::class);
139  static::expectExceptionCode(1289843275);
140  static::expectExceptionMessage('"extensionName" is not properly configured. Request can\'t be dispatched!');
141 
142  $requestBuilder = $this->getContainer()->get(RequestBuilder::class);
143  $requestBuilder->build();
144  }
145 
150  {
151  static::expectException(Exception::class);
152  static::expectExceptionCode(1289843277);
153  static::expectExceptionMessage('"pluginName" is not properly configured. Request can\'t be dispatched!');
154 
156  $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
157  $configurationManager->setConfiguration(['extensionName' => 'blog_example']);
158 
159  $requestBuilder = $this->getContainer()->get(RequestBuilder::class);
160  $requestBuilder->build();
161  }
162 
167  {
168  $_FILES['tx_blog_example_blog'] = [
169  'name' => 'name.pdf',
170  'type' => 'application/pdf',
171  'tmp_name' => '/tmp/php/php1h4j1o',
172  'error' => UPLOAD_ERR_OK,
173  'size' => 98174,
174  ];
175 
176  $extensionName = 'blog_example';
177  $pluginName = 'blog';
178 
179  ‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers']['ExtbaseTeam\BlogExample\Controller\BlogController'] = [
180  'className' => 'ExtbaseTeam\BlogExample\Controller\BlogController',
181  'alias' => 'BlogController',
182  'actions' => [
183  'list'
184  ]
185  ];
186 
187  $configuration = [];
188  $configuration['extensionName'] = $extensionName;
189  $configuration['pluginName'] = $pluginName;
190 
192  $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
193  $configurationManager->setConfiguration($configuration);
194 
195  $requestBuilder = $this->getContainer()->get(RequestBuilder::class);
196  $request = $requestBuilder->build();
197 
198  self::assertInstanceOf(RequestInterface::class, $request);
199  self::assertSame('name.pdf', $request->getArgument('name'));
200  self::assertSame('application/pdf', $request->getArgument('type'));
201  self::assertSame('/tmp/php/php1h4j1o', $request->getArgument('tmp_name'));
202  self::assertSame(UPLOAD_ERR_OK, $request->getArgument('error'));
203  self::assertSame(98174, $request->getArgument('size'));
204  }
205 
210  {
211  $_FILES['tx_blog_example_blog'] = [
212  'error' => [
213  'pdf' => UPLOAD_ERR_OK,
214  'jpg' => UPLOAD_ERR_OK,
215  ],
216  'name' => [
217  'pdf' => 'name.pdf',
218  'jpg' => 'name.jpg',
219  ],
220  'type' => [
221  'pdf' => 'application/pdf',
222  'jpg' => 'image/jpg',
223  ],
224  'tmp_name' => [
225  'pdf' => '/tmp/php/php1h4j1o',
226  'jpg' => '/tmp/php/php6hst32',
227  ],
228  'size' => [
229  'pdf' => 98174,
230  ],
231  ];
232 
233  $extensionName = 'blog_example';
234  $pluginName = 'blog';
235 
236  ‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers']['ExtbaseTeam\BlogExample\Controller\BlogController'] = [
237  'className' => 'ExtbaseTeam\BlogExample\Controller\BlogController',
238  'alias' => 'BlogController',
239  'actions' => [
240  'list'
241  ]
242  ];
243 
244  $configuration = [];
245  $configuration['extensionName'] = $extensionName;
246  $configuration['pluginName'] = $pluginName;
247 
249  $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
250  $configurationManager->setConfiguration($configuration);
251 
252  $requestBuilder = $this->getContainer()->get(RequestBuilder::class);
253  $request = $requestBuilder->build();
254 
255  self::assertInstanceOf(RequestInterface::class, $request);
256 
257  $argument = $request->getArgument('pdf');
258  self::assertIsArray($argument);
259  self::assertSame('name.pdf', $argument['name']);
260  self::assertSame('application/pdf', $argument['type']);
261  self::assertSame('/tmp/php/php1h4j1o', $argument['tmp_name']);
262  self::assertSame(UPLOAD_ERR_OK, $argument['error']);
263  self::assertSame(98174, $argument['size']);
264 
265  $argument = $request->getArgument('jpg');
266  self::assertIsArray($argument);
267  self::assertSame('name.jpg', $argument['name']);
268  self::assertSame('image/jpg', $argument['type']);
269  self::assertSame('/tmp/php/php6hst32', $argument['tmp_name']);
270  self::assertSame(UPLOAD_ERR_OK, $argument['error']);
271  self::assertTrue(!isset($argument['size']));
272  }
273 
278  {
279  static::expectException(InvalidControllerNameException::class);
280  static::expectExceptionCode(1313855173);
281  static::expectExceptionMessage('The controller "NonExistentController" is not allowed by plugin "blog". Please check for TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin() in your ext_localconf.php.');
282 
283  $_GET['tx_blog_example_blog']['controller'] = 'NonExistentController';
284 
285  $extensionName = 'blog_example';
286  $pluginName = 'blog';
287 
288  ‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers']['ExtbaseTeam\BlogExample\Controller\BlogController'] = [
289  'className' => 'ExtbaseTeam\BlogExample\Controller\BlogController',
290  'alias' => 'BlogController',
291  'actions' => [
292  'list'
293  ]
294  ];
295 
296  $configuration = [];
297  $configuration['extensionName'] = $extensionName;
298  $configuration['pluginName'] = $pluginName;
299 
301  $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
302  $configurationManager->setConfiguration($configuration);
303 
304  $requestBuilder = $this->getContainer()->get(RequestBuilder::class);
305  $requestBuilder->build();
306  }
307 
312  {
313  static::expectException(PageNotFoundException::class);
314  static::expectExceptionCode(1313857897);
315  static::expectExceptionMessage('The requested resource was not found');
316 
317  $_GET['tx_blog_example_blog']['controller'] = 'NonExistentController';
318 
319  $extensionName = 'blog_example';
320  $pluginName = 'blog';
321 
322  ‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers']['ExtbaseTeam\BlogExample\Controller\BlogController'] = [
323  'className' => 'ExtbaseTeam\BlogExample\Controller\BlogController',
324  'alias' => 'BlogController',
325  'actions' => [
326  'list'
327  ]
328  ];
329 
330  $configuration = [];
331  $configuration['extensionName'] = $extensionName;
332  $configuration['pluginName'] = $pluginName;
333  $configuration['mvc']['throwPageNotFoundExceptionIfActionCantBeResolved'] = true;
334 
336  $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
337  $configurationManager->setConfiguration($configuration);
338 
339  $requestBuilder = $this->getContainer()->get(RequestBuilder::class);
340  $requestBuilder->build();
341  }
342 
347  {
348  static::expectException(Exception::class);
349  static::expectExceptionCode(1316104317);
350  static::expectExceptionMessage('The default controller for extension "blog_example" and plugin "blog" can not be determined. Please check for TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin() in your ext_localconf.php.');
351 
352  $extensionName = 'blog_example';
353  $pluginName = 'blog';
354 
355  $configuration = [];
356  $configuration['extensionName'] = $extensionName;
357  $configuration['pluginName'] = $pluginName;
358 
360  $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
361  $configurationManager->setConfiguration($configuration);
362 
363  $requestBuilder = $this->getContainer()->get(RequestBuilder::class);
364  $requestBuilder->build();
365  }
366 
371  {
372  $_GET['tx_blog_example_blog']['controller'] = 'NonExistentController';
373 
374  $extensionName = 'blog_example';
375  $pluginName = 'blog';
376 
377  ‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers']['ExtbaseTeam\BlogExample\Controller\BlogController'] = [
378  'className' => 'ExtbaseTeam\BlogExample\Controller\BlogController',
379  'alias' => 'BlogController',
380  'actions' => [
381  'list'
382  ]
383  ];
384 
385  $configuration = [];
386  $configuration['extensionName'] = $extensionName;
387  $configuration['pluginName'] = $pluginName;
388  $configuration['mvc']['callDefaultActionIfActionCantBeResolved'] = true;
389 
391  $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
392  $configurationManager->setConfiguration($configuration);
393 
394  $requestBuilder = $this->getContainer()->get(RequestBuilder::class);
395  $request = $requestBuilder->build();
396 
397  self::assertInstanceOf(RequestInterface::class, $request);
398  self::assertSame('BlogController', $request->getControllerName());
399  }
400 
405  {
406  $_GET['tx_blog_example_blog']['controller'] = 'UserController';
407 
408  $extensionName = 'blog_example';
409  $pluginName = 'blog';
410 
411  ‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers'] = [
412  'ExtbaseTeam\BlogExample\Controller\BlogController' => [
413  'className' => 'ExtbaseTeam\BlogExample\Controller\BlogController',
414  'alias' => 'BlogController',
415  'actions' => [
416  'list'
417  ]
418  ],
419  'ExtbaseTeam\BlogExample\Controller\UserController' => [
420  'className' => 'ExtbaseTeam\BlogExample\Controller\UserController',
421  'alias' => 'UserController',
422  'actions' => [
423  'list'
424  ]
425  ]
426  ];
427 
428  $configuration = [];
429  $configuration['extensionName'] = $extensionName;
430  $configuration['pluginName'] = $pluginName;
431 
433  $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
434  $configurationManager->setConfiguration($configuration);
435 
436  $requestBuilder = $this->getContainer()->get(RequestBuilder::class);
437  $request = $requestBuilder->build();
438 
439  self::assertInstanceOf(RequestInterface::class, $request);
440  self::assertSame('UserController', $request->getControllerName());
441  }
442 
447  {
448  static::expectException(InvalidActionNameException::class);
449  static::expectExceptionCode(1313855175);
450  static::expectExceptionMessage('The action "NonExistentAction" (controller "ExtbaseTeam\BlogExample\Controller\BlogController") is not allowed by this plugin / module. Please check TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin() in your ext_localconf.php / TYPO3\CMS\Extbase\Utility\ExtensionUtility::configureModule() in your ext_tables.php.');
451 
452  $_GET['tx_blog_example_blog']['action'] = 'NonExistentAction';
453 
454  $extensionName = 'blog_example';
455  $pluginName = 'blog';
456 
457  ‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers']['ExtbaseTeam\BlogExample\Controller\BlogController'] = [
458  'className' => 'ExtbaseTeam\BlogExample\Controller\BlogController',
459  'alias' => 'BlogController',
460  'actions' => [
461  'list'
462  ]
463  ];
464 
465  $configuration = [];
466  $configuration['extensionName'] = $extensionName;
467  $configuration['pluginName'] = $pluginName;
468 
470  $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
471  $configurationManager->setConfiguration($configuration);
472 
473  $requestBuilder = $this->getContainer()->get(RequestBuilder::class);
474  $requestBuilder->build();
475  }
476 
481  {
482  static::expectException(PageNotFoundException::class);
483  static::expectExceptionCode(1313857898);
484  static::expectExceptionMessage('The requested resource was not found');
485 
486  $_GET['tx_blog_example_blog']['action'] = 'NonExistentAction';
487 
488  $extensionName = 'blog_example';
489  $pluginName = 'blog';
490 
491  ‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers']['ExtbaseTeam\BlogExample\Controller\BlogController'] = [
492  'className' => 'ExtbaseTeam\BlogExample\Controller\BlogController',
493  'alias' => 'BlogController',
494  'actions' => [
495  'list'
496  ]
497  ];
498 
499  $configuration = [];
500  $configuration['extensionName'] = $extensionName;
501  $configuration['pluginName'] = $pluginName;
502  $configuration['mvc']['throwPageNotFoundExceptionIfActionCantBeResolved'] = true;
503 
505  $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
506  $configurationManager->setConfiguration($configuration);
507 
508  $requestBuilder = $this->getContainer()->get(RequestBuilder::class);
509  $requestBuilder->build();
510  }
511 
516  {
517  $_GET['tx_blog_example_blog']['action'] = 'NonExistentAction';
518 
519  $extensionName = 'blog_example';
520  $pluginName = 'blog';
521 
522  ‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers']['ExtbaseTeam\BlogExample\Controller\BlogController'] = [
523  'className' => 'ExtbaseTeam\BlogExample\Controller\BlogController',
524  'alias' => 'BlogController',
525  'actions' => [
526  'list'
527  ]
528  ];
529 
530  $configuration = [];
531  $configuration['extensionName'] = $extensionName;
532  $configuration['pluginName'] = $pluginName;
533  $configuration['mvc']['callDefaultActionIfActionCantBeResolved'] = true;
534 
536  $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
537  $configurationManager->setConfiguration($configuration);
538 
539  $requestBuilder = $this->getContainer()->get(RequestBuilder::class);
540  $request = $requestBuilder->build();
541 
542  self::assertInstanceOf(RequestInterface::class, $request);
543  self::assertSame('list', $request->getControllerActionName());
544  }
545 
550  {
551  $_GET['tx_blog_example_blog']['action'] = 'show';
552 
553  $extensionName = 'blog_example';
554  $pluginName = 'blog';
555 
556  ‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers'] = [
557  'ExtbaseTeam\BlogExample\Controller\BlogController' => [
558  'className' => 'ExtbaseTeam\BlogExample\Controller\BlogController',
559  'alias' => 'BlogController',
560  'actions' => [
561  'list', 'show'
562  ]
563  ]
564  ];
565 
566  $configuration = [];
567  $configuration['extensionName'] = $extensionName;
568  $configuration['pluginName'] = $pluginName;
569 
571  $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
572  $configurationManager->setConfiguration($configuration);
573 
574  $requestBuilder = $this->getContainer()->get(RequestBuilder::class);
575  $request = $requestBuilder->build();
576 
577  self::assertInstanceOf(RequestInterface::class, $request);
578  self::assertSame('show', $request->getControllerActionName());
579  }
580 
585  {
586  static::expectException(Exception::class);
587  static::expectExceptionCode(1295479651);
588  static::expectExceptionMessage('The default action can not be determined for controller "ExtbaseTeam\BlogExample\Controller\BlogController". Please check TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin() in your ext_localconf.php.');
589 
590  $extensionName = 'blog_example';
591  $pluginName = 'blog';
592 
593  ‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers'] = [
594  'ExtbaseTeam\BlogExample\Controller\BlogController' => [
595  'className' => 'ExtbaseTeam\BlogExample\Controller\BlogController',
596  'alias' => 'BlogController'
597  ]
598  ];
599 
600  $configuration = [];
601  $configuration['extensionName'] = $extensionName;
602  $configuration['pluginName'] = $pluginName;
603 
605  $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
606  $configurationManager->setConfiguration($configuration);
607 
608  $requestBuilder = $this->getContainer()->get(RequestBuilder::class);
609  $requestBuilder->build();
610  }
611 
616  {
617  $serverRequest = new ‪ServerRequest(new ‪Uri(''));
618  $serverRequest = $serverRequest->withQueryParams(['tx_blog_example_blog' => ['action' => 'show']]);
619  ‪$GLOBALS['TYPO3_REQUEST'] = $serverRequest;
620 
621  $extensionName = 'blog_example';
622  $pluginName = 'blog';
623 
624  ‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers'] = [
625  'ExtbaseTeam\BlogExample\Controller\BlogController' => [
626  'className' => 'ExtbaseTeam\BlogExample\Controller\BlogController',
627  'alias' => 'BlogController',
628  'actions' => [
629  'list', 'show'
630  ]
631  ]
632  ];
633 
634  $configuration = [];
635  $configuration['extensionName'] = $extensionName;
636  $configuration['pluginName'] = $pluginName;
637 
639  $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
640  $configurationManager->setConfiguration($configuration);
641 
642  $requestBuilder = $this->getContainer()->get(RequestBuilder::class);
643  $request = $requestBuilder->build();
644 
645  self::assertInstanceOf(RequestInterface::class, $request);
646  self::assertSame('show', $request->getControllerActionName());
647  }
648 
653  {
654  $pageArguments = new ‪PageArguments(1, '0', ['tx_blog_example_blog' => ['action' => 'show']]);
655 
656  $serverRequest = new ‪ServerRequest(new ‪Uri(''));
657  $serverRequest = $serverRequest->withAttribute('routing', $pageArguments);
658  ‪$GLOBALS['TYPO3_REQUEST'] = $serverRequest;
659 
660  $extensionName = 'blog_example';
661  $pluginName = 'blog';
662 
663  ‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers'] = [
664  'ExtbaseTeam\BlogExample\Controller\BlogController' => [
665  'className' => 'ExtbaseTeam\BlogExample\Controller\BlogController',
666  'alias' => 'BlogController',
667  'actions' => [
668  'list', 'show'
669  ]
670  ]
671  ];
672 
673  $configuration = [];
674  $configuration['extensionName'] = $extensionName;
675  $configuration['pluginName'] = $pluginName;
676 
678  $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
679  $configurationManager->setConfiguration($configuration);
680 
681  $requestBuilder = $this->getContainer()->get(RequestBuilder::class);
682  $request = $requestBuilder->build();
683 
684  self::assertInstanceOf(RequestInterface::class, $request);
685  self::assertSame('show', $request->getControllerActionName());
686  }
687 
692  {
693  $serverRequest = new ‪ServerRequest(new ‪Uri(''));
694  $serverRequest = $serverRequest->withParsedBody(['tx_blog_example_blog' => ['action' => 'show']]);
695  ‪$GLOBALS['TYPO3_REQUEST'] = $serverRequest;
696 
697  $extensionName = 'blog_example';
698  $pluginName = 'blog';
699 
700  ‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers'] = [
701  'ExtbaseTeam\BlogExample\Controller\BlogController' => [
702  'className' => 'ExtbaseTeam\BlogExample\Controller\BlogController',
703  'alias' => 'BlogController',
704  'actions' => [
705  'list', 'show'
706  ]
707  ]
708  ];
709 
710  $configuration = [];
711  $configuration['extensionName'] = $extensionName;
712  $configuration['pluginName'] = $pluginName;
713 
715  $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
716  $configurationManager->setConfiguration($configuration);
717 
718  $requestBuilder = $this->getContainer()->get(RequestBuilder::class);
719  $request = $requestBuilder->build();
720 
721  self::assertInstanceOf(RequestInterface::class, $request);
722  self::assertSame('show', $request->getControllerActionName());
723  }
724 
728  public function ‪silentlyIgnoreInvalidParameter(): void
729  {
730  $pageArguments = new ‪PageArguments(1, '0', ['tx_blog_example_blog' => 'not_an_array']);
731 
732  $serverRequest = new ‪ServerRequest(new ‪Uri('https://example.com/'));
733  $serverRequest = $serverRequest->withAttribute('routing', $pageArguments);
734  ‪$GLOBALS['TYPO3_REQUEST'] = $serverRequest;
735 
736  $extensionName = 'blog_example';
737  $pluginName = 'blog';
738 
739  ‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers'] = [
740  'ExtbaseTeam\BlogExample\Controller\BlogController' => [
741  'className' => 'ExtbaseTeam\BlogExample\Controller\BlogController',
742  'alias' => 'BlogController',
743  'actions' => [
744  'list', 'show'
745  ]
746  ]
747  ];
748 
749  $configuration = [];
750  $configuration['extensionName'] = $extensionName;
751  $configuration['pluginName'] = $pluginName;
752 
753  $configurationManager = $this->getContainer()->get(ConfigurationManager::class);
754  $configurationManager->setConfiguration($configuration);
755 
756  $requestBuilder = $this->getContainer()->get(RequestBuilder::class);
757  $request = $requestBuilder->build();
758 
759  self::assertInstanceOf(RequestInterface::class, $request);
760  self::assertSame('list', $request->getControllerActionName());
761  }
762 }
‪TYPO3\CMS\Core\Routing\PageArguments
Definition: PageArguments.php:26
‪TYPO3\CMS\Extbase\Tests\Functional\Mvc\Web\RequestBuilderTest\resolveActionNameReturnsActionDefinedViaParametersOfServerRequest
‪resolveActionNameReturnsActionDefinedViaParametersOfServerRequest()
Definition: RequestBuilderTest.php:615
‪TYPO3\CMS\Extbase\Tests\Functional\Mvc\Web\RequestBuilderTest\loadDefaultValuesThrowsExceptionIfExtensionNameIsNotProperlyConfigured
‪loadDefaultValuesThrowsExceptionIfExtensionNameIsNotProperlyConfigured()
Definition: RequestBuilderTest.php:136
‪TYPO3\CMS\Extbase\Tests\Functional\Mvc\Web\RequestBuilderTest\resolveActionNameThrowsInvalidActionNameExceptionIfNonExistentActionIsSetViaGetParameter
‪resolveActionNameThrowsInvalidActionNameExceptionIfNonExistentActionIsSetViaGetParameter()
Definition: RequestBuilderTest.php:446
‪TYPO3\CMS\Extbase\Tests\Functional\Mvc\Web\RequestBuilderTest\resolveControllerClassNameThrowsInvalidControllerNameExceptionIfNonExistentControllerIsSetViaGetParameter
‪resolveControllerClassNameThrowsInvalidControllerNameExceptionIfNonExistentControllerIsSetViaGetParameter()
Definition: RequestBuilderTest.php:277
‪TYPO3\CMS\Extbase\Mvc\Exception\InvalidControllerNameException
Definition: InvalidControllerNameException.php:26
‪TYPO3\CMS\Extbase\Tests\Functional\Mvc\Web\RequestBuilderTest\resolveControllerClassNameThrowsPageNotFoundException
‪resolveControllerClassNameThrowsPageNotFoundException()
Definition: RequestBuilderTest.php:311
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface
Definition: ConfigurationManagerInterface.php:28
‪TYPO3\CMS\Extbase\Tests\Functional\Mvc\Web\RequestBuilderTest\buildBuildsARequestInterfaceObject
‪buildBuildsARequestInterfaceObject()
Definition: RequestBuilderTest.php:40
‪TYPO3\CMS\Extbase\Tests\Functional\Mvc\Web\RequestBuilderTest\resolveActionNameThrowsAnExceptionIfTheDefaultActionCannotBeDetermined
‪resolveActionNameThrowsAnExceptionIfTheDefaultActionCannotBeDetermined()
Definition: RequestBuilderTest.php:584
‪TYPO3\CMS\Extbase\Tests\Functional\Mvc\Web\RequestBuilderTest\resolveControllerClassNameReturnsControllerDefinedViaParametersIfControllerIsConfigured
‪resolveControllerClassNameReturnsControllerDefinedViaParametersIfControllerIsConfigured()
Definition: RequestBuilderTest.php:404
‪TYPO3\CMS\Extbase\Tests\Functional\Mvc\Web\RequestBuilderTest\untangleFilesArrayDetectsMultipleUploadedFile
‪untangleFilesArrayDetectsMultipleUploadedFile()
Definition: RequestBuilderTest.php:209
‪TYPO3\CMS\Core\Http\Uri
Definition: Uri.php:29
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManager
Definition: ConfigurationManager.php:33
‪TYPO3\CMS\Core\Error\Http\PageNotFoundException
Definition: PageNotFoundException.php:24
‪TYPO3\CMS\Extbase\Tests\Functional\Mvc\Web\RequestBuilderTest\resolveActionNameReturnsDefaultActionIfCallDefaultActionIfActionCantBeResolvedIsConfigured
‪resolveActionNameReturnsDefaultActionIfCallDefaultActionIfActionCantBeResolvedIsConfigured()
Definition: RequestBuilderTest.php:515
‪TYPO3\CMS\Core\Http\ServerRequest
Definition: ServerRequest.php:37
‪TYPO3\CMS\Extbase\Tests\Functional\Mvc\Web\RequestBuilderTest\untangleFilesArrayDetectsASingleUploadedFile
‪untangleFilesArrayDetectsASingleUploadedFile()
Definition: RequestBuilderTest.php:166
‪TYPO3\CMS\Extbase\Mvc\Exception
Definition: InfiniteLoopException.php:18
‪TYPO3\CMS\Extbase\Tests\Functional\Mvc\Web\RequestBuilderTest\silentlyIgnoreInvalidParameter
‪silentlyIgnoreInvalidParameter()
Definition: RequestBuilderTest.php:728
‪TYPO3\CMS\Extbase\Tests\Functional\Mvc\Web\RequestBuilderTest\resolveActionNameReturnsActionDefinedViaParametersIfActionIsConfigured
‪resolveActionNameReturnsActionDefinedViaParametersIfActionIsConfigured()
Definition: RequestBuilderTest.php:549
‪TYPO3\CMS\Extbase\Mvc\RequestInterface
Definition: RequestInterface.php:22
‪TYPO3\CMS\Extbase\Tests\Functional\Mvc\Web\RequestBuilderTest\resolveActionNameReturnsActionDefinedViaParsedBodyOfServerRequest
‪resolveActionNameReturnsActionDefinedViaParsedBodyOfServerRequest()
Definition: RequestBuilderTest.php:691
‪TYPO3\CMS\Extbase\Tests\Functional\Mvc\Web\RequestBuilderTest\resolveActionNameThrowsPageNotFoundException
‪resolveActionNameThrowsPageNotFoundException()
Definition: RequestBuilderTest.php:480
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Extbase\Mvc\Exception\InvalidActionNameException
Definition: InvalidActionNameException.php:26
‪TYPO3\CMS\Extbase\Tests\Functional\Mvc\Web\RequestBuilderTest\resolveActionNameReturnsActionDefinedViaPageArgumentOfServerRequest
‪resolveActionNameReturnsActionDefinedViaPageArgumentOfServerRequest()
Definition: RequestBuilderTest.php:652
‪TYPO3\CMS\Extbase\Tests\Functional\Mvc\Web
Definition: RequestBuilderTest.php:18
‪TYPO3\CMS\Extbase\Tests\Functional\Mvc\Web\RequestBuilderTest\loadDefaultValuesThrowsExceptionIfPluginNameIsNotProperlyConfigured
‪loadDefaultValuesThrowsExceptionIfPluginNameIsNotProperlyConfigured()
Definition: RequestBuilderTest.php:149
‪TYPO3\CMS\Extbase\Tests\Functional\Mvc\Web\RequestBuilderTest\resolveControllerClassNameThrowsAnExceptionIfTheDefaultControllerCannotBeDetermined
‪resolveControllerClassNameThrowsAnExceptionIfTheDefaultControllerCannotBeDetermined()
Definition: RequestBuilderTest.php:346
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Extbase\Tests\Functional\Mvc\Web\RequestBuilderTest\resolveControllerClassNameReturnsDefaultControllerIfCallDefaultActionIfActionCantBeResolvedIsConfigured
‪resolveControllerClassNameReturnsDefaultControllerIfCallDefaultActionIfActionCantBeResolvedIsConfigured()
Definition: RequestBuilderTest.php:370
‪TYPO3\CMS\Extbase\Tests\Functional\Mvc\Web\RequestBuilderTest\loadDefaultValuesOverridesFormatIfConfigured
‪loadDefaultValuesOverridesFormatIfConfigured()
Definition: RequestBuilderTest.php:71
‪TYPO3\CMS\Extbase\Object\ObjectManager
Definition: ObjectManager.php:28
‪TYPO3\CMS\Extbase\Tests\Functional\Mvc\Web\RequestBuilderTest\buildOverridesFormatIfSetInGetParameters
‪buildOverridesFormatIfSetInGetParameters()
Definition: RequestBuilderTest.php:103
‪TYPO3\CMS\Extbase\Tests\Functional\Mvc\Web\RequestBuilderTest
Definition: RequestBuilderTest.php:36
‪TYPO3\CMS\Extbase\Mvc\Web\RequestBuilder
Definition: RequestBuilder.php:38