‪TYPO3CMS  9.5
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 
28 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
29 
30 class ‪RequestBuilderTest extends FunctionalTestCase
31 {
36  {
37  $pageArguments = new ‪PageArguments(1, '0', ['tx_blog_example_blog' => 'not_an_array']);
38 
39  $serverRequest = new ‪ServerRequest(new ‪Uri(''));
40  $serverRequest = $serverRequest->withAttribute('routing', $pageArguments);
41  ‪$GLOBALS['TYPO3_REQUEST'] = $serverRequest;
42 
43  $extensionName = 'blog_example';
44  $pluginName = 'blog';
45 
46  ‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers'] = [
47  'ExtbaseTeam\BlogExample\Controller\BlogController' => [
48  'className' => 'ExtbaseTeam\BlogExample\Controller\BlogController',
49  'alias' => 'BlogController',
50  'actions' => [
51  'list', 'show'
52  ]
53  ]
54  ];
55 
56  $objectManager = GeneralUtility::makeInstance(ObjectManager::class);
57 
58  $configurationManager = $objectManager->get(ConfigurationManagerInterface::class);
59  $configurationManager->setConfiguration([
60  'extensionName' => $extensionName,
61  'pluginName' => $pluginName
62  ]);
63 
64  $requestBuilder = $objectManager->get(RequestBuilder::class);
65  $request = $requestBuilder->build();
66 
67  self::assertInstanceOf(RequestInterface::class, $request);
68  self::assertSame('list', $request->getControllerActionName());
69  }
70 }
‪TYPO3\CMS\Core\Routing\PageArguments
Definition: PageArguments.php:25
‪TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface
Definition: ConfigurationManagerInterface.php:22
‪TYPO3\CMS\Core\Http\Uri
Definition: Uri.php:27
‪TYPO3\CMS\Extbase\Tests\Functional\Mvc\Web\RequestBuilderTest\silentlyIgnoreInvalidParameterAndUseDefaultAction
‪silentlyIgnoreInvalidParameterAndUseDefaultAction()
Definition: RequestBuilderTest.php:35
‪TYPO3\CMS\Core\Http\ServerRequest
Definition: ServerRequest.php:35
‪TYPO3\CMS\Extbase\Mvc\RequestInterface
Definition: RequestInterface.php:21
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Extbase\Tests\Functional\Mvc\Web
Definition: RequestBuilderTest.php:18
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:45
‪TYPO3\CMS\Extbase\Object\ObjectManager
Definition: ObjectManager.php:25
‪TYPO3\CMS\Extbase\Tests\Functional\Mvc\Web\RequestBuilderTest
Definition: RequestBuilderTest.php:31
‪TYPO3\CMS\Extbase\Mvc\Web\RequestBuilder
Definition: RequestBuilder.php:29