Commit 0ecca871 authored by Benni Mack's avatar Benni Mack Committed by Georg Ringer

[TASK] Use native PSR-7 Request in Extbase Request building

Because the original PSR-7 request is now
handed into Extbase at any times, the RequestBuilder
can now utilize a PSR-7 request and does not need
to fall back to global GET/POST or getIndpEnv()
methods anymore.

The final logic in this part is to handle $_FILES,
which needs to be dealt with separately as a feature
toggle.

Resolves: #93853
Releases: master
Change-Id: I60d592e6adcd705397b0f753224ee53fdf16cc0c
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/67519Tested-by: default avatarTYPO3com <noreply@typo3.com>
Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Tested-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
Reviewed-by: Oliver Bartsch's avatarOliver Bartsch <bo@cedev.de>
Reviewed-by: Simon Gilli's avatarSimon Gilli <typo3@gilbertsoft.org>
Reviewed-by: Markus Klein's avatarMarkus Klein <markus.klein@typo3.org>
Reviewed-by: Georg Ringer's avatarGeorg Ringer <georg.ringer@gmail.com>
parent 90fa470e
......@@ -186,7 +186,7 @@ class Bootstrap
*/
protected function handleRequest(ServerRequestInterface $request): string
{
$extbaseRequest = $this->extbaseRequestBuilder->build();
$extbaseRequest = $this->extbaseRequestBuilder->build($request);
$requestHandler = $this->requestHandlerResolver->resolveRequestHandler($extbaseRequest);
$response = $requestHandler->handleRequest($extbaseRequest);
// If response is NULL after handling the request we need to stop
......@@ -233,7 +233,7 @@ class Bootstrap
$this->initialize($configuration);
$extbaseRequest = $this->extbaseRequestBuilder->build();
$extbaseRequest = $this->extbaseRequestBuilder->build($request);
$requestHandler = $this->requestHandlerResolver->resolveRequestHandler($extbaseRequest);
$response = $requestHandler->handleRequest($extbaseRequest);
......
......@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Extbase\Mvc\Web;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Error\Http\PageNotFoundException;
use TYPO3\CMS\Core\Http\NormalizedParams;
use TYPO3\CMS\Core\Routing\PageArguments;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\ArrayUtility;
......@@ -79,17 +80,17 @@ class RequestBuilder implements SingletonInterface
protected $allowedControllerActions = [];
/**
* @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface
* @var ConfigurationManagerInterface
*/
protected $configurationManager;
/**
* @var \TYPO3\CMS\Extbase\Service\ExtensionService
* @var ExtensionService
*/
protected $extensionService;
/**
* @var \TYPO3\CMS\Extbase\Service\EnvironmentService
* @var EnvironmentService
*/
protected $environmentService;
......@@ -109,7 +110,7 @@ class RequestBuilder implements SingletonInterface
private $allowedControllerAliases = [];
/**
* @param \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager
* @param ConfigurationManagerInterface $configurationManager
*/
public function injectConfigurationManager(ConfigurationManagerInterface $configurationManager)
{
......@@ -117,7 +118,7 @@ class RequestBuilder implements SingletonInterface
}
/**
* @param \TYPO3\CMS\Extbase\Service\ExtensionService $extensionService
* @param ExtensionService $extensionService
*/
public function injectExtensionService(ExtensionService $extensionService)
{
......@@ -125,7 +126,7 @@ class RequestBuilder implements SingletonInterface
}
/**
* @param \TYPO3\CMS\Extbase\Service\EnvironmentService $environmentService
* @param EnvironmentService $environmentService
*/
public function injectEnvironmentService(EnvironmentService $environmentService)
{
......@@ -167,26 +168,24 @@ class RequestBuilder implements SingletonInterface
/**
* Builds a web request object from the raw HTTP information and the configuration
*
* @return \TYPO3\CMS\Extbase\Mvc\Request The web request as an object
* @param ServerRequestInterface $mainRequest
* @return Request The web request as an object
*/
public function build()
public function build(ServerRequestInterface $mainRequest)
{
$this->loadDefaultValues();
$pluginNamespace = $this->extensionService->getPluginNamespace($this->extensionName, $this->pluginName);
/** @var \TYPO3\CMS\Core\Http\ServerRequest $typo3Request */
$typo3Request = $GLOBALS['TYPO3_REQUEST'] ?? null;
if ($typo3Request instanceof ServerRequestInterface) {
$queryArguments = $typo3Request->getAttribute('routing');
if ($queryArguments instanceof PageArguments) {
$getParameters = $queryArguments->get($pluginNamespace) ?? [];
} else {
$getParameters = $typo3Request->getQueryParams()[$pluginNamespace] ?? [];
}
$bodyParameters = $typo3Request->getParsedBody()[$pluginNamespace] ?? [];
$parameters = $getParameters;
ArrayUtility::mergeRecursiveWithOverrule($parameters, $bodyParameters);
/** @var NormalizedParams $normalizedParams */
$normalizedParams = $mainRequest->getAttribute('normalizedParams');
$queryArguments = $mainRequest->getAttribute('routing');
if ($queryArguments instanceof PageArguments) {
$parameters = $queryArguments->get($pluginNamespace) ?? [];
} else {
$parameters = GeneralUtility::_GPmerged($pluginNamespace);
$parameters = $mainRequest->getQueryParams()[$pluginNamespace] ?? [];
}
if ($mainRequest->getMethod() === 'POST') {
$postParameters = $mainRequest->getParsedBody()[$pluginNamespace] ?? [];
ArrayUtility::mergeRecursiveWithOverrule($parameters, $postParameters);
}
$files = $this->untangleFilesArray($_FILES);
......@@ -197,22 +196,20 @@ class RequestBuilder implements SingletonInterface
$controllerClassName = $this->resolveControllerClassName($parameters);
$actionName = $this->resolveActionName($controllerClassName, $parameters);
$baseUri = GeneralUtility::getIndpEnv('TYPO3_SITE_URL');
$baseUri = $normalizedParams->getSiteUrl();
if ($this->environmentService->isEnvironmentInBackendMode()) {
$baseUri .= TYPO3_mainDir;
}
/** @var \TYPO3\CMS\Extbase\Mvc\Request $request */
$request = GeneralUtility::makeInstance(Request::class);
$request->setPluginName($this->pluginName);
$request->setControllerExtensionName($this->extensionName);
$request->setControllerAliasToClassNameMapping($this->controllerAliasToClassMapping);
$request->setControllerName($this->controllerClassToAliasMapping[$controllerClassName]);
$request->setControllerActionName($actionName);
// @todo Use Environment
$request->setRequestUri(GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL'));
$request->setRequestUri($normalizedParams->getRequestUrl());
$request->setBaseUri($baseUri);
$request->setMethod($this->getServerRequestMethod($typo3Request));
$request->setMethod($mainRequest->getMethod());
if (isset($parameters['format']) && is_string($parameters['format']) && $parameters['format'] !== '') {
$request->setFormat(filter_var($parameters['format'], FILTER_SANITIZE_STRING));
} else {
......@@ -359,12 +356,4 @@ class RequestBuilder implements SingletonInterface
}
return $fieldPaths;
}
protected function getServerRequestMethod(?ServerRequestInterface $typo3Request): string
{
if ($typo3Request instanceof ServerRequestInterface) {
return $typo3Request->getMethod();
}
return isset($_SERVER['REQUEST_METHOD']) && is_string($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET';
}
}
......@@ -17,10 +17,11 @@ declare(strict_types=1);
namespace TYPO3\CMS\Extbase\Tests\Functional\Mvc\Web;
use Psr\Http\Message\ServerRequestInterface;
use TYPO3\CMS\Core\Core\SystemEnvironmentBuilder;
use TYPO3\CMS\Core\Error\Http\PageNotFoundException;
use TYPO3\CMS\Core\Http\NormalizedParams;
use TYPO3\CMS\Core\Http\ServerRequest;
use TYPO3\CMS\Core\Http\Uri;
use TYPO3\CMS\Core\Routing\PageArguments;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
......@@ -58,8 +59,9 @@ class RequestBuilderTest extends FunctionalTestCase
$configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
$configurationManager->setConfiguration($configuration);
$mainRequest = $this->prepareServerRequest('https://example.com/');
$requestBuilder = $this->getContainer()->get(RequestBuilder::class);
$request = $requestBuilder->build();
$request = $requestBuilder->build($mainRequest);
self::assertInstanceOf(RequestInterface::class, $request);
self::assertSame('html', $request->getFormat());
......@@ -90,8 +92,9 @@ class RequestBuilderTest extends FunctionalTestCase
$configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
$configurationManager->setConfiguration($configuration);
$mainRequest = $this->prepareServerRequest('https://example.com/');
$requestBuilder = $this->getContainer()->get(RequestBuilder::class);
$request = $requestBuilder->build();
$request = $requestBuilder->build($mainRequest);
self::assertInstanceOf(RequestInterface::class, $request);
self::assertSame('json', $request->getFormat());
......@@ -102,8 +105,6 @@ class RequestBuilderTest extends FunctionalTestCase
*/
public function buildOverridesFormatIfSetInGetParameters()
{
$_GET['tx_blog_example_blog']['format'] = 'json';
$extensionName = 'blog_example';
$pluginName = 'blog';
......@@ -123,8 +124,10 @@ class RequestBuilderTest extends FunctionalTestCase
$configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
$configurationManager->setConfiguration($configuration);
$mainRequest = $this->prepareServerRequest('https://example.com/');
$mainRequest = $mainRequest->withQueryParams(['tx_blog_example_blog' => ['format' => 'json']]);
$requestBuilder = $this->getContainer()->get(RequestBuilder::class);
$request = $requestBuilder->build();
$request = $requestBuilder->build($mainRequest);
self::assertInstanceOf(RequestInterface::class, $request);
self::assertSame('json', $request->getFormat());
......@@ -139,8 +142,9 @@ class RequestBuilderTest extends FunctionalTestCase
static::expectExceptionCode(1289843275);
static::expectExceptionMessage('"extensionName" is not properly configured. Request can\'t be dispatched!');
$mainRequest = $this->prepareServerRequest('https://example.com/');
$requestBuilder = $this->getContainer()->get(RequestBuilder::class);
$requestBuilder->build();
$requestBuilder->build($mainRequest);
}
/**
......@@ -156,8 +160,9 @@ class RequestBuilderTest extends FunctionalTestCase
$configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
$configurationManager->setConfiguration(['extensionName' => 'blog_example']);
$mainRequest = $this->prepareServerRequest('https://example.com/');
$requestBuilder = $this->getContainer()->get(RequestBuilder::class);
$requestBuilder->build();
$requestBuilder->build($mainRequest);
}
/**
......@@ -192,8 +197,9 @@ class RequestBuilderTest extends FunctionalTestCase
$configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
$configurationManager->setConfiguration($configuration);
$mainRequest = $this->prepareServerRequest('https://example.com/', 'POST');
$requestBuilder = $this->getContainer()->get(RequestBuilder::class);
$request = $requestBuilder->build();
$request = $requestBuilder->build($mainRequest);
self::assertInstanceOf(RequestInterface::class, $request);
self::assertSame('name.pdf', $request->getArgument('name'));
......@@ -249,8 +255,9 @@ class RequestBuilderTest extends FunctionalTestCase
$configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
$configurationManager->setConfiguration($configuration);
$mainRequest = $this->prepareServerRequest('https://example.com/', 'POST');
$requestBuilder = $this->getContainer()->get(RequestBuilder::class);
$request = $requestBuilder->build();
$request = $requestBuilder->build($mainRequest);
self::assertInstanceOf(RequestInterface::class, $request);
......@@ -301,8 +308,10 @@ class RequestBuilderTest extends FunctionalTestCase
$configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
$configurationManager->setConfiguration($configuration);
$mainRequest = $this->prepareServerRequest('https://example.com/');
$mainRequest = $mainRequest->withQueryParams(['tx_blog_example_blog' => ['controller' => 'NonExistentController']]);
$requestBuilder = $this->getContainer()->get(RequestBuilder::class);
$requestBuilder->build();
$requestBuilder->build($mainRequest);
}
/**
......@@ -314,8 +323,6 @@ class RequestBuilderTest extends FunctionalTestCase
static::expectExceptionCode(1313857897);
static::expectExceptionMessage('The requested resource was not found');
$_GET['tx_blog_example_blog']['controller'] = 'NonExistentController';
$extensionName = 'blog_example';
$pluginName = 'blog';
......@@ -336,8 +343,10 @@ class RequestBuilderTest extends FunctionalTestCase
$configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
$configurationManager->setConfiguration($configuration);
$mainRequest = $this->prepareServerRequest('https://example.com/');
$mainRequest = $mainRequest->withQueryParams(['tx_blog_example_blog' => ['controller' => 'NonExistentController']]);
$requestBuilder = $this->getContainer()->get(RequestBuilder::class);
$requestBuilder->build();
$requestBuilder->build($mainRequest);
}
/**
......@@ -360,8 +369,9 @@ class RequestBuilderTest extends FunctionalTestCase
$configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
$configurationManager->setConfiguration($configuration);
$mainRequest = $this->prepareServerRequest('https://example.com/');
$requestBuilder = $this->getContainer()->get(RequestBuilder::class);
$requestBuilder->build();
$requestBuilder->build($mainRequest);
}
/**
......@@ -369,8 +379,6 @@ class RequestBuilderTest extends FunctionalTestCase
*/
public function resolveControllerClassNameReturnsDefaultControllerIfCallDefaultActionIfActionCantBeResolvedIsConfigured()
{
$_GET['tx_blog_example_blog']['controller'] = 'NonExistentController';
$extensionName = 'blog_example';
$pluginName = 'blog';
......@@ -391,8 +399,10 @@ class RequestBuilderTest extends FunctionalTestCase
$configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
$configurationManager->setConfiguration($configuration);
$mainRequest = $this->prepareServerRequest('https://example.com/');
$mainRequest = $mainRequest->withQueryParams(['tx_blog_example_blog' => ['controller' => 'NonExistentController']]);
$requestBuilder = $this->getContainer()->get(RequestBuilder::class);
$request = $requestBuilder->build();
$request = $requestBuilder->build($mainRequest);
self::assertInstanceOf(RequestInterface::class, $request);
self::assertSame('BlogController', $request->getControllerName());
......@@ -403,8 +413,6 @@ class RequestBuilderTest extends FunctionalTestCase
*/
public function resolveControllerClassNameReturnsControllerDefinedViaParametersIfControllerIsConfigured()
{
$_GET['tx_blog_example_blog']['controller'] = 'UserController';
$extensionName = 'blog_example';
$pluginName = 'blog';
......@@ -433,8 +441,10 @@ class RequestBuilderTest extends FunctionalTestCase
$configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
$configurationManager->setConfiguration($configuration);
$mainRequest = $this->prepareServerRequest('https://example.com/');
$mainRequest = $mainRequest->withQueryParams(['tx_blog_example_blog' => ['controller' => 'UserController']]);
$requestBuilder = $this->getContainer()->get(RequestBuilder::class);
$request = $requestBuilder->build();
$request = $requestBuilder->build($mainRequest);
self::assertInstanceOf(RequestInterface::class, $request);
self::assertSame('UserController', $request->getControllerName());
......@@ -449,8 +459,6 @@ class RequestBuilderTest extends FunctionalTestCase
static::expectExceptionCode(1313855175);
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.');
$_GET['tx_blog_example_blog']['action'] = 'NonExistentAction';
$extensionName = 'blog_example';
$pluginName = 'blog';
......@@ -470,8 +478,10 @@ class RequestBuilderTest extends FunctionalTestCase
$configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
$configurationManager->setConfiguration($configuration);
$mainRequest = $this->prepareServerRequest('https://example.com/');
$mainRequest = $mainRequest->withQueryParams(['tx_blog_example_blog' => ['action' => 'NonExistentAction']]);
$requestBuilder = $this->getContainer()->get(RequestBuilder::class);
$requestBuilder->build();
$requestBuilder->build($mainRequest);
}
/**
......@@ -483,8 +493,6 @@ class RequestBuilderTest extends FunctionalTestCase
static::expectExceptionCode(1313857898);
static::expectExceptionMessage('The requested resource was not found');
$_GET['tx_blog_example_blog']['action'] = 'NonExistentAction';
$extensionName = 'blog_example';
$pluginName = 'blog';
......@@ -505,8 +513,10 @@ class RequestBuilderTest extends FunctionalTestCase
$configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
$configurationManager->setConfiguration($configuration);
$mainRequest = $this->prepareServerRequest('https://example.com/');
$mainRequest = $mainRequest->withQueryParams(['tx_blog_example_blog' => ['action' => 'NonExistentAction']]);
$requestBuilder = $this->getContainer()->get(RequestBuilder::class);
$requestBuilder->build();
$requestBuilder->build($mainRequest);
}
/**
......@@ -514,8 +524,6 @@ class RequestBuilderTest extends FunctionalTestCase
*/
public function resolveActionNameReturnsDefaultActionIfCallDefaultActionIfActionCantBeResolvedIsConfigured()
{
$_GET['tx_blog_example_blog']['action'] = 'NonExistentAction';
$extensionName = 'blog_example';
$pluginName = 'blog';
......@@ -536,8 +544,10 @@ class RequestBuilderTest extends FunctionalTestCase
$configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
$configurationManager->setConfiguration($configuration);
$mainRequest = $this->prepareServerRequest('https://example.com/');
$mainRequest = $mainRequest->withQueryParams(['tx_blog_example_blog' => ['action' => 'NonExistentAction']]);
$requestBuilder = $this->getContainer()->get(RequestBuilder::class);
$request = $requestBuilder->build();
$request = $requestBuilder->build($mainRequest);
self::assertInstanceOf(RequestInterface::class, $request);
self::assertSame('list', $request->getControllerActionName());
......@@ -548,8 +558,6 @@ class RequestBuilderTest extends FunctionalTestCase
*/
public function resolveActionNameReturnsActionDefinedViaParametersIfActionIsConfigured()
{
$_GET['tx_blog_example_blog']['action'] = 'show';
$extensionName = 'blog_example';
$pluginName = 'blog';
......@@ -571,8 +579,10 @@ class RequestBuilderTest extends FunctionalTestCase
$configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
$configurationManager->setConfiguration($configuration);
$mainRequest = $this->prepareServerRequest('https://example.com/');
$mainRequest = $mainRequest->withQueryParams(['tx_blog_example_blog' => ['action' => 'show']]);
$requestBuilder = $this->getContainer()->get(RequestBuilder::class);
$request = $requestBuilder->build();
$request = $requestBuilder->build($mainRequest);
self::assertInstanceOf(RequestInterface::class, $request);
self::assertSame('show', $request->getControllerActionName());
......@@ -605,8 +615,9 @@ class RequestBuilderTest extends FunctionalTestCase
$configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
$configurationManager->setConfiguration($configuration);
$mainRequest = $this->prepareServerRequest('https://example.com/');
$requestBuilder = $this->getContainer()->get(RequestBuilder::class);
$requestBuilder->build();
$requestBuilder->build($mainRequest);
}
/**
......@@ -614,11 +625,10 @@ class RequestBuilderTest extends FunctionalTestCase
*/
public function resolveActionNameReturnsActionDefinedViaParametersOfServerRequest()
{
$serverRequest = new ServerRequest(new Uri(''));
$serverRequest = $serverRequest
$mainRequest = $this->prepareServerRequest('https://example.com/');
$mainRequest = $mainRequest
->withQueryParams(['tx_blog_example_blog' => ['action' => 'show']])
->withAttribute('applicationType', SystemEnvironmentBuilder::REQUESTTYPE_BE);
$GLOBALS['TYPO3_REQUEST'] = $serverRequest;
$extensionName = 'blog_example';
$pluginName = 'blog';
......@@ -642,7 +652,7 @@ class RequestBuilderTest extends FunctionalTestCase
$configurationManager->setConfiguration($configuration);
$requestBuilder = $this->getContainer()->get(RequestBuilder::class);
$request = $requestBuilder->build();
$request = $requestBuilder->build($mainRequest);
self::assertInstanceOf(RequestInterface::class, $request);
self::assertSame('show', $request->getControllerActionName());
......@@ -655,11 +665,10 @@ class RequestBuilderTest extends FunctionalTestCase
{
$pageArguments = new PageArguments(1, '0', ['tx_blog_example_blog' => ['action' => 'show']]);
$serverRequest = new ServerRequest(new Uri(''));
$serverRequest = $serverRequest
$mainRequest = $this->prepareServerRequest('https://example.com/');
$mainRequest = $mainRequest
->withAttribute('routing', $pageArguments)
->withAttribute('applicationType', SystemEnvironmentBuilder::REQUESTTYPE_BE);
$GLOBALS['TYPO3_REQUEST'] = $serverRequest;
$extensionName = 'blog_example';
$pluginName = 'blog';
......@@ -683,7 +692,7 @@ class RequestBuilderTest extends FunctionalTestCase
$configurationManager->setConfiguration($configuration);
$requestBuilder = $this->getContainer()->get(RequestBuilder::class);
$request = $requestBuilder->build();
$request = $requestBuilder->build($mainRequest);
self::assertInstanceOf(RequestInterface::class, $request);
self::assertSame('show', $request->getControllerActionName());
......@@ -694,11 +703,10 @@ class RequestBuilderTest extends FunctionalTestCase
*/
public function resolveActionNameReturnsActionDefinedViaParsedBodyOfServerRequest()
{
$serverRequest = new ServerRequest(new Uri(''));
$serverRequest = $serverRequest
$mainRequest = $this->prepareServerRequest('https://example.com/', 'POST');
$mainRequest = $mainRequest
->withParsedBody(['tx_blog_example_blog' => ['action' => 'show']])
->withAttribute('applicationType', SystemEnvironmentBuilder::REQUESTTYPE_BE);
$GLOBALS['TYPO3_REQUEST'] = $serverRequest;
$extensionName = 'blog_example';
$pluginName = 'blog';
......@@ -722,9 +730,16 @@ class RequestBuilderTest extends FunctionalTestCase
$configurationManager->setConfiguration($configuration);
$requestBuilder = $this->getContainer()->get(RequestBuilder::class);
$request = $requestBuilder->build();
$request = $requestBuilder->build($mainRequest);
self::assertInstanceOf(RequestInterface::class, $request);
self::assertSame('show', $request->getControllerActionName());
}
protected function prepareServerRequest(string $url, $method = 'GET'): ServerRequestInterface
{
$request = new ServerRequest($url, $method);
$normalizedParams = NormalizedParams::createFromRequest($request);
return $request->withAttribute('normalizedParams', $normalizedParams);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment