[TASK] Introduce functional test for RequestBuilder 80/62580/4
authorAlexander Schnitzler <git@alexanderschnitzler.de>
Sun, 8 Dec 2019 17:16:49 +0000 (18:16 +0100)
committerAnja Leichsenring <aleichsenring@ab-softlab.de>
Wed, 18 Dec 2019 13:00:04 +0000 (14:00 +0100)
The now introduced functional tests are a replacement
for the unit tests which were only possible by mocking
the hell out of the RequestBuilder.

Releases: master
Resolves: #89898
Change-Id: Iccbd768ab0842e29d4954755e8f34f62bdc564f1
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/62580
Tested-by: Michael Telgkamp <michael.telgkamp@mindscreen.de>
Tested-by: TYPO3com <noreply@typo3.com>
Tested-by: Daniel Goerz <daniel.goerz@posteo.de>
Tested-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
Reviewed-by: Michael Telgkamp <michael.telgkamp@mindscreen.de>
Reviewed-by: Anja Leichsenring <aleichsenring@ab-softlab.de>
typo3/sysext/extbase/Tests/Functional/Mvc/Web/RequestBuilderTest.php [new file with mode: 0644]
typo3/sysext/extbase/Tests/Unit/Mvc/Web/RequestBuilderTest.php [deleted file]

diff --git a/typo3/sysext/extbase/Tests/Functional/Mvc/Web/RequestBuilderTest.php b/typo3/sysext/extbase/Tests/Functional/Mvc/Web/RequestBuilderTest.php
new file mode 100644 (file)
index 0000000..ee79c15
--- /dev/null
@@ -0,0 +1,720 @@
+<?php
+declare(strict_types = 1);
+
+namespace TYPO3\CMS\Extbase\Tests\Functional\Mvc\Web;
+
+/*
+ * This file is part of the TYPO3 CMS project.
+ *
+ * It is free software; you can redistribute it and/or modify it under
+ * the terms of the GNU General Public License, either version 2
+ * of the License, or any later version.
+ *
+ * For the full copyright and license information, please read the
+ * LICENSE.txt file that was distributed with this source code.
+ *
+ * The TYPO3 project - inspiring people to share!
+ */
+
+use TYPO3\CMS\Core\Error\Http\PageNotFoundException;
+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;
+use TYPO3\CMS\Extbase\Mvc\Exception;
+use TYPO3\CMS\Extbase\Mvc\RequestInterface;
+use TYPO3\CMS\Extbase\Mvc\Web\RequestBuilder;
+use TYPO3\CMS\Extbase\Object\ObjectManager;
+use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
+
+class RequestBuilderTest extends FunctionalTestCase
+{
+    /**
+     * @test
+     */
+    public function buildBuildsARequestInterfaceObject()
+    {
+        $extensionName = 'blog_example';
+        $pluginName = 'blog';
+
+        $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers']['ExtbaseTeam\BlogExample\Controller\BlogController'] = [
+            'className' => 'ExtbaseTeam\BlogExample\Controller\BlogController',
+            'alias' => 'BlogController',
+            'actions' => [
+                'list'
+            ]
+        ];
+
+        $configuration = [];
+        $configuration['extensionName'] = $extensionName;
+        $configuration['pluginName'] = $pluginName;
+
+        /** @var ConfigurationManagerInterface $configurationManager */
+        $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
+        $configurationManager->setConfiguration($configuration);
+
+        $requestBuilder = GeneralUtility::getContainer()->get(RequestBuilder::class);
+        $request = $requestBuilder->build();
+
+        self::assertInstanceOf(RequestInterface::class, $request);
+        self::assertSame('html', $request->getFormat());
+    }
+
+    /**
+     * @test
+     */
+    public function loadDefaultValuesOverridesFormatIfConfigured()
+    {
+        $extensionName = 'blog_example';
+        $pluginName = 'blog';
+
+        $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers']['ExtbaseTeam\BlogExample\Controller\BlogController'] = [
+            'className' => 'ExtbaseTeam\BlogExample\Controller\BlogController',
+            'alias' => 'BlogController',
+            'actions' => [
+                'list'
+            ]
+        ];
+
+        $configuration = [];
+        $configuration['extensionName'] = $extensionName;
+        $configuration['pluginName'] = $pluginName;
+        $configuration['format'] = 'json';
+
+        /** @var ConfigurationManagerInterface $configurationManager */
+        $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
+        $configurationManager->setConfiguration($configuration);
+
+        $requestBuilder = GeneralUtility::getContainer()->get(RequestBuilder::class);
+        $request = $requestBuilder->build();
+
+        self::assertInstanceOf(RequestInterface::class, $request);
+        self::assertSame('json', $request->getFormat());
+    }
+
+    /**
+     * @test
+     */
+    public function buildOverridesFormatIfSetInGetParameters()
+    {
+        $_GET['tx_blog_example_blog']['format'] = 'json';
+
+        $extensionName = 'blog_example';
+        $pluginName = 'blog';
+
+        $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers']['ExtbaseTeam\BlogExample\Controller\BlogController'] = [
+            'className' => 'ExtbaseTeam\BlogExample\Controller\BlogController',
+            'alias' => 'BlogController',
+            'actions' => [
+                'list'
+            ]
+        ];
+
+        $configuration = [];
+        $configuration['extensionName'] = $extensionName;
+        $configuration['pluginName'] = $pluginName;
+
+        /** @var ConfigurationManagerInterface $configurationManager */
+        $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
+        $configurationManager->setConfiguration($configuration);
+
+        $requestBuilder = GeneralUtility::getContainer()->get(RequestBuilder::class);
+        $request = $requestBuilder->build();
+
+        self::assertInstanceOf(RequestInterface::class, $request);
+        self::assertSame('json', $request->getFormat());
+    }
+
+    /**
+     * @test
+     */
+    public function loadDefaultValuesThrowsExceptionIfExtensionNameIsNotProperlyConfigured()
+    {
+        static::expectException(Exception::class);
+        static::expectExceptionCode(1289843275);
+        static::expectExceptionMessage('"extensionName" is not properly configured. Request can\'t be dispatched!');
+
+        $requestBuilder = GeneralUtility::getContainer()->get(RequestBuilder::class);
+        $requestBuilder->build();
+    }
+
+    /**
+     * @test
+     */
+    public function loadDefaultValuesThrowsExceptionIfPluginNameIsNotProperlyConfigured()
+    {
+        static::expectException(Exception::class);
+        static::expectExceptionCode(1289843277);
+        static::expectExceptionMessage('"pluginName" is not properly configured. Request can\'t be dispatched!');
+
+        /** @var ConfigurationManagerInterface $configurationManager */
+        $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
+        $configurationManager->setConfiguration(['extensionName' => 'blog_example']);
+
+        $requestBuilder = GeneralUtility::getContainer()->get(RequestBuilder::class);
+        $requestBuilder->build();
+    }
+
+    /**
+     * @test
+     */
+    public function untangleFilesArrayDetectsASingleUploadedFile()
+    {
+        $_FILES['tx_blog_example_blog'] = [
+            'name' => 'name.pdf',
+            'type' => 'application/pdf',
+            'tmp_name' => '/tmp/php/php1h4j1o',
+            'error' => UPLOAD_ERR_OK,
+            'size' => 98174,
+        ];
+
+        $extensionName = 'blog_example';
+        $pluginName = 'blog';
+
+        $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers']['ExtbaseTeam\BlogExample\Controller\BlogController'] = [
+            'className' => 'ExtbaseTeam\BlogExample\Controller\BlogController',
+            'alias' => 'BlogController',
+            'actions' => [
+                'list'
+            ]
+        ];
+
+        $configuration = [];
+        $configuration['extensionName'] = $extensionName;
+        $configuration['pluginName'] = $pluginName;
+
+        /** @var ConfigurationManagerInterface $configurationManager */
+        $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
+        $configurationManager->setConfiguration($configuration);
+
+        $requestBuilder = GeneralUtility::getContainer()->get(RequestBuilder::class);
+        $request = $requestBuilder->build();
+
+        self::assertInstanceOf(RequestInterface::class, $request);
+        self::assertSame('name.pdf', $request->getArgument('name'));
+        self::assertSame('application/pdf', $request->getArgument('type'));
+        self::assertSame('/tmp/php/php1h4j1o', $request->getArgument('tmp_name'));
+        self::assertSame(UPLOAD_ERR_OK, $request->getArgument('error'));
+        self::assertSame(98174, $request->getArgument('size'));
+    }
+
+    /**
+     * @test
+     */
+    public function untangleFilesArrayDetectsMultipleUploadedFile()
+    {
+        $_FILES['tx_blog_example_blog'] = [
+            'error' => [
+                'pdf' => UPLOAD_ERR_OK,
+                'jpg' => UPLOAD_ERR_OK,
+            ],
+            'name' => [
+                'pdf' => 'name.pdf',
+                'jpg' => 'name.jpg',
+            ],
+            'type' => [
+                'pdf' => 'application/pdf',
+                'jpg' => 'image/jpg',
+            ],
+            'tmp_name' => [
+                'pdf' => '/tmp/php/php1h4j1o',
+                'jpg' => '/tmp/php/php6hst32',
+            ],
+            'size' => [
+                'pdf' => 98174,
+            ],
+        ];
+
+        $extensionName = 'blog_example';
+        $pluginName = 'blog';
+
+        $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers']['ExtbaseTeam\BlogExample\Controller\BlogController'] = [
+            'className' => 'ExtbaseTeam\BlogExample\Controller\BlogController',
+            'alias' => 'BlogController',
+            'actions' => [
+                'list'
+            ]
+        ];
+
+        $configuration = [];
+        $configuration['extensionName'] = $extensionName;
+        $configuration['pluginName'] = $pluginName;
+
+        /** @var ConfigurationManagerInterface $configurationManager */
+        $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
+        $configurationManager->setConfiguration($configuration);
+
+        $requestBuilder = GeneralUtility::getContainer()->get(RequestBuilder::class);
+        $request = $requestBuilder->build();
+
+        self::assertInstanceOf(RequestInterface::class, $request);
+
+        $argument = $request->getArgument('pdf');
+        self::assertIsArray($argument);
+        self::assertSame('name.pdf', $argument['name']);
+        self::assertSame('application/pdf', $argument['type']);
+        self::assertSame('/tmp/php/php1h4j1o', $argument['tmp_name']);
+        self::assertSame(UPLOAD_ERR_OK, $argument['error']);
+        self::assertSame(98174, $argument['size']);
+
+        $argument = $request->getArgument('jpg');
+        self::assertIsArray($argument);
+        self::assertSame('name.jpg', $argument['name']);
+        self::assertSame('image/jpg', $argument['type']);
+        self::assertSame('/tmp/php/php6hst32', $argument['tmp_name']);
+        self::assertSame(UPLOAD_ERR_OK, $argument['error']);
+        self::assertTrue(!isset($argument['size']));
+    }
+
+    /**
+     * @test
+     */
+    public function resolveControllerClassNameThrowsInvalidControllerNameExceptionIfNonExistentControllerIsSetViaGetParameter()
+    {
+        static::expectException(Exception\InvalidControllerNameException::class);
+        static::expectExceptionCode(1313855173);
+        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.');
+
+        $_GET['tx_blog_example_blog']['controller'] = 'NonExistentController';
+
+        $extensionName = 'blog_example';
+        $pluginName = 'blog';
+
+        $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers']['ExtbaseTeam\BlogExample\Controller\BlogController'] = [
+            'className' => 'ExtbaseTeam\BlogExample\Controller\BlogController',
+            'alias' => 'BlogController',
+            'actions' => [
+                'list'
+            ]
+        ];
+
+        $configuration = [];
+        $configuration['extensionName'] = $extensionName;
+        $configuration['pluginName'] = $pluginName;
+
+        /** @var ConfigurationManagerInterface $configurationManager */
+        $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
+        $configurationManager->setConfiguration($configuration);
+
+        $requestBuilder = GeneralUtility::getContainer()->get(RequestBuilder::class);
+        $requestBuilder->build();
+    }
+
+    /**
+     * @test
+     */
+    public function resolveControllerClassNameThrowsPageNotFoundException()
+    {
+        static::expectException(PageNotFoundException::class);
+        static::expectExceptionCode(1313857897);
+        static::expectExceptionMessage('The requested resource was not found');
+
+        $_GET['tx_blog_example_blog']['controller'] = 'NonExistentController';
+
+        $extensionName = 'blog_example';
+        $pluginName = 'blog';
+
+        $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers']['ExtbaseTeam\BlogExample\Controller\BlogController'] = [
+            'className' => 'ExtbaseTeam\BlogExample\Controller\BlogController',
+            'alias' => 'BlogController',
+            'actions' => [
+                'list'
+            ]
+        ];
+
+        $configuration = [];
+        $configuration['extensionName'] = $extensionName;
+        $configuration['pluginName'] = $pluginName;
+        $configuration['mvc']['throwPageNotFoundExceptionIfActionCantBeResolved'] = true;
+
+        /** @var ConfigurationManagerInterface $configurationManager */
+        $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
+        $configurationManager->setConfiguration($configuration);
+
+        $requestBuilder = GeneralUtility::getContainer()->get(RequestBuilder::class);
+        $requestBuilder->build();
+    }
+
+    /**
+     * @test
+     */
+    public function resolveControllerClassNameThrowsAnExceptionIfTheDefaultControllerCannotBeDetermined()
+    {
+        static::expectException(Exception::class);
+        static::expectExceptionCode(1316104317);
+        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.');
+
+        $extensionName = 'blog_example';
+        $pluginName = 'blog';
+
+        $configuration = [];
+        $configuration['extensionName'] = $extensionName;
+        $configuration['pluginName'] = $pluginName;
+
+        /** @var ConfigurationManagerInterface $configurationManager */
+        $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
+        $configurationManager->setConfiguration($configuration);
+
+        $requestBuilder = GeneralUtility::getContainer()->get(RequestBuilder::class);
+        $requestBuilder->build();
+    }
+
+    /**
+     * @test
+     */
+    public function resolveControllerClassNameReturnsDefaultControllerIfCallDefaultActionIfActionCantBeResolvedIsConfigured()
+    {
+        $_GET['tx_blog_example_blog']['controller'] = 'NonExistentController';
+
+        $extensionName = 'blog_example';
+        $pluginName = 'blog';
+
+        $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers']['ExtbaseTeam\BlogExample\Controller\BlogController'] = [
+            'className' => 'ExtbaseTeam\BlogExample\Controller\BlogController',
+            'alias' => 'BlogController',
+            'actions' => [
+                'list'
+            ]
+        ];
+
+        $configuration = [];
+        $configuration['extensionName'] = $extensionName;
+        $configuration['pluginName'] = $pluginName;
+        $configuration['mvc']['callDefaultActionIfActionCantBeResolved'] = true;
+
+        /** @var ConfigurationManagerInterface $configurationManager */
+        $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
+        $configurationManager->setConfiguration($configuration);
+
+        $requestBuilder = GeneralUtility::getContainer()->get(RequestBuilder::class);
+        $request = $requestBuilder->build();
+
+        self::assertInstanceOf(RequestInterface::class, $request);
+        self::assertSame('BlogController', $request->getControllerName());
+    }
+
+    /**
+     * @test
+     */
+    public function resolveControllerClassNameReturnsControllerDefinedViaParametersIfControllerIsConfigured()
+    {
+        $_GET['tx_blog_example_blog']['controller'] = 'UserController';
+
+        $extensionName = 'blog_example';
+        $pluginName = 'blog';
+
+        $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers'] = [
+            'ExtbaseTeam\BlogExample\Controller\BlogController' => [
+                'className' =>  'ExtbaseTeam\BlogExample\Controller\BlogController',
+                'alias' => 'BlogController',
+                'actions' => [
+                    'list'
+                ]
+            ],
+            'ExtbaseTeam\BlogExample\Controller\UserController' => [
+                'className' =>  'ExtbaseTeam\BlogExample\Controller\UserController',
+                'alias' => 'UserController',
+                'actions' => [
+                    'list'
+                ]
+            ]
+        ];
+
+        $configuration = [];
+        $configuration['extensionName'] = $extensionName;
+        $configuration['pluginName'] = $pluginName;
+
+        /** @var ConfigurationManagerInterface $configurationManager */
+        $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
+        $configurationManager->setConfiguration($configuration);
+
+        $requestBuilder = GeneralUtility::getContainer()->get(RequestBuilder::class);
+        $request = $requestBuilder->build();
+
+        self::assertInstanceOf(RequestInterface::class, $request);
+        self::assertSame('UserController', $request->getControllerName());
+    }
+
+    /**
+     * @test
+     */
+    public function resolveActionNameThrowsInvalidActionNameExceptionIfNonExistentActionIsSetViaGetParameter()
+    {
+        static::expectException(Exception\InvalidActionNameException::class);
+        static::expectExceptionCode(1313855175);
+        static::expectExceptionMessage('The action "NonExistentAction" (controller "ExtbaseTeam\BlogExample\Controller\BlogController") is not allowed by this plugin. Please check TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin() in your ext_localconf.php.');
+
+        $_GET['tx_blog_example_blog']['action'] = 'NonExistentAction';
+
+        $extensionName = 'blog_example';
+        $pluginName = 'blog';
+
+        $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers']['ExtbaseTeam\BlogExample\Controller\BlogController'] = [
+            'className' => 'ExtbaseTeam\BlogExample\Controller\BlogController',
+            'alias' => 'BlogController',
+            'actions' => [
+                'list'
+            ]
+        ];
+
+        $configuration = [];
+        $configuration['extensionName'] = $extensionName;
+        $configuration['pluginName'] = $pluginName;
+
+        /** @var ConfigurationManagerInterface $configurationManager */
+        $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
+        $configurationManager->setConfiguration($configuration);
+
+        $requestBuilder = GeneralUtility::getContainer()->get(RequestBuilder::class);
+        $requestBuilder->build();
+    }
+
+    /**
+     * @test
+     */
+    public function resolveActionNameThrowsPageNotFoundException()
+    {
+        static::expectException(PageNotFoundException::class);
+        static::expectExceptionCode(1313857898);
+        static::expectExceptionMessage('The requested resource was not found');
+
+        $_GET['tx_blog_example_blog']['action'] = 'NonExistentAction';
+
+        $extensionName = 'blog_example';
+        $pluginName = 'blog';
+
+        $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers']['ExtbaseTeam\BlogExample\Controller\BlogController'] = [
+            'className' => 'ExtbaseTeam\BlogExample\Controller\BlogController',
+            'alias' => 'BlogController',
+            'actions' => [
+                'list'
+            ]
+        ];
+
+        $configuration = [];
+        $configuration['extensionName'] = $extensionName;
+        $configuration['pluginName'] = $pluginName;
+        $configuration['mvc']['throwPageNotFoundExceptionIfActionCantBeResolved'] = true;
+
+        /** @var ConfigurationManagerInterface $configurationManager */
+        $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
+        $configurationManager->setConfiguration($configuration);
+
+        $requestBuilder = GeneralUtility::getContainer()->get(RequestBuilder::class);
+        $requestBuilder->build();
+    }
+
+    /**
+     * @test
+     */
+    public function resolveActionNameReturnsDefaultActionIfCallDefaultActionIfActionCantBeResolvedIsConfigured()
+    {
+        $_GET['tx_blog_example_blog']['action'] = 'NonExistentAction';
+
+        $extensionName = 'blog_example';
+        $pluginName = 'blog';
+
+        $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers']['ExtbaseTeam\BlogExample\Controller\BlogController'] = [
+            'className' => 'ExtbaseTeam\BlogExample\Controller\BlogController',
+            'alias' => 'BlogController',
+            'actions' => [
+                'list'
+            ]
+        ];
+
+        $configuration = [];
+        $configuration['extensionName'] = $extensionName;
+        $configuration['pluginName'] = $pluginName;
+        $configuration['mvc']['callDefaultActionIfActionCantBeResolved'] = true;
+
+        /** @var ConfigurationManagerInterface $configurationManager */
+        $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
+        $configurationManager->setConfiguration($configuration);
+
+        $requestBuilder = GeneralUtility::getContainer()->get(RequestBuilder::class);
+        $request = $requestBuilder->build();
+
+        self::assertInstanceOf(RequestInterface::class, $request);
+        self::assertSame('list', $request->getControllerActionName());
+    }
+
+    /**
+     * @test
+     */
+    public function resolveActionNameReturnsActionDefinedViaParametersIfActionIsConfigured()
+    {
+        $_GET['tx_blog_example_blog']['action'] = 'show';
+
+        $extensionName = 'blog_example';
+        $pluginName = 'blog';
+
+        $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers'] = [
+            'ExtbaseTeam\BlogExample\Controller\BlogController' => [
+                'className' =>  'ExtbaseTeam\BlogExample\Controller\BlogController',
+                'alias' => 'BlogController',
+                'actions' => [
+                    'list', 'show'
+                ]
+            ]
+        ];
+
+        $configuration = [];
+        $configuration['extensionName'] = $extensionName;
+        $configuration['pluginName'] = $pluginName;
+
+        /** @var ConfigurationManagerInterface $configurationManager */
+        $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
+        $configurationManager->setConfiguration($configuration);
+
+        $requestBuilder = GeneralUtility::getContainer()->get(RequestBuilder::class);
+        $request = $requestBuilder->build();
+
+        self::assertInstanceOf(RequestInterface::class, $request);
+        self::assertSame('show', $request->getControllerActionName());
+    }
+
+    /**
+     * @test
+     */
+    public function resolveActionNameThrowsAnExceptionIfTheDefaultActionCannotBeDetermined()
+    {
+        static::expectException(Exception::class);
+        static::expectExceptionCode(1295479651);
+        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.');
+
+        $extensionName = 'blog_example';
+        $pluginName = 'blog';
+
+        $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers'] = [
+            'ExtbaseTeam\BlogExample\Controller\BlogController' => [
+                'className' =>  'ExtbaseTeam\BlogExample\Controller\BlogController',
+                'alias' => 'BlogController'
+            ]
+        ];
+
+        $configuration = [];
+        $configuration['extensionName'] = $extensionName;
+        $configuration['pluginName'] = $pluginName;
+
+        /** @var ConfigurationManagerInterface $configurationManager */
+        $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
+        $configurationManager->setConfiguration($configuration);
+
+        $requestBuilder = GeneralUtility::getContainer()->get(RequestBuilder::class);
+        $requestBuilder->build();
+    }
+
+    /**
+     * @test
+     */
+    public function resolveActionNameReturnsActionDefinedViaParametersOfServerRequest()
+    {
+        $serverRequest = new ServerRequest(new Uri(''));
+        $serverRequest = $serverRequest->withQueryParams(['tx_blog_example_blog' => ['action' => 'show']]);
+        $GLOBALS['TYPO3_REQUEST'] = $serverRequest;
+
+        $extensionName = 'blog_example';
+        $pluginName = 'blog';
+
+        $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers'] = [
+            'ExtbaseTeam\BlogExample\Controller\BlogController' => [
+                'className' =>  'ExtbaseTeam\BlogExample\Controller\BlogController',
+                'alias' => 'BlogController',
+                'actions' => [
+                    'list', 'show'
+                ]
+            ]
+        ];
+
+        $configuration = [];
+        $configuration['extensionName'] = $extensionName;
+        $configuration['pluginName'] = $pluginName;
+
+        /** @var ConfigurationManagerInterface $configurationManager */
+        $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
+        $configurationManager->setConfiguration($configuration);
+
+        $requestBuilder = GeneralUtility::getContainer()->get(RequestBuilder::class);
+        $request = $requestBuilder->build();
+
+        self::assertInstanceOf(RequestInterface::class, $request);
+        self::assertSame('show', $request->getControllerActionName());
+    }
+
+    /**
+     * @test
+     */
+    public function resolveActionNameReturnsActionDefinedViaPageArgumentOfServerRequest()
+    {
+        $pageArguments = new PageArguments(1, '0', ['tx_blog_example_blog' => ['action' => 'show']]);
+
+        $serverRequest = new ServerRequest(new Uri(''));
+        $serverRequest = $serverRequest->withAttribute('routing', $pageArguments);
+        $GLOBALS['TYPO3_REQUEST'] = $serverRequest;
+
+        $extensionName = 'blog_example';
+        $pluginName = 'blog';
+
+        $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers'] = [
+            'ExtbaseTeam\BlogExample\Controller\BlogController' => [
+                'className' =>  'ExtbaseTeam\BlogExample\Controller\BlogController',
+                'alias' => 'BlogController',
+                'actions' => [
+                    'list', 'show'
+                ]
+            ]
+        ];
+
+        $configuration = [];
+        $configuration['extensionName'] = $extensionName;
+        $configuration['pluginName'] = $pluginName;
+
+        /** @var ConfigurationManagerInterface $configurationManager */
+        $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
+        $configurationManager->setConfiguration($configuration);
+
+        $requestBuilder = GeneralUtility::getContainer()->get(RequestBuilder::class);
+        $request = $requestBuilder->build();
+
+        self::assertInstanceOf(RequestInterface::class, $request);
+        self::assertSame('show', $request->getControllerActionName());
+    }
+
+    /**
+     * @test
+     */
+    public function resolveActionNameReturnsActionDefinedViaParsedBodyOfServerRequest()
+    {
+        $serverRequest = new ServerRequest(new Uri(''));
+        $serverRequest = $serverRequest->withParsedBody(['tx_blog_example_blog' => ['action' => 'show']]);
+        $GLOBALS['TYPO3_REQUEST'] = $serverRequest;
+
+        $extensionName = 'blog_example';
+        $pluginName = 'blog';
+
+        $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['extbase']['extensions'][$extensionName]['modules'][$pluginName]['controllers'] = [
+            'ExtbaseTeam\BlogExample\Controller\BlogController' => [
+                'className' =>  'ExtbaseTeam\BlogExample\Controller\BlogController',
+                'alias' => 'BlogController',
+                'actions' => [
+                    'list', 'show'
+                ]
+            ]
+        ];
+
+        $configuration = [];
+        $configuration['extensionName'] = $extensionName;
+        $configuration['pluginName'] = $pluginName;
+
+        /** @var ConfigurationManagerInterface $configurationManager */
+        $configurationManager = GeneralUtility::makeInstance(ObjectManager::class)->get(ConfigurationManagerInterface::class);
+        $configurationManager->setConfiguration($configuration);
+
+        $requestBuilder = GeneralUtility::getContainer()->get(RequestBuilder::class);
+        $request = $requestBuilder->build();
+
+        self::assertInstanceOf(RequestInterface::class, $request);
+        self::assertSame('show', $request->getControllerActionName());
+    }
+}
diff --git a/typo3/sysext/extbase/Tests/Unit/Mvc/Web/RequestBuilderTest.php b/typo3/sysext/extbase/Tests/Unit/Mvc/Web/RequestBuilderTest.php
deleted file mode 100644 (file)
index 9d08a5e..0000000
+++ /dev/null
@@ -1,829 +0,0 @@
-<?php
-declare(strict_types = 1);
-
-namespace TYPO3\CMS\Extbase\Tests\Unit\Mvc\Web;
-
-/*
- * This file is part of the TYPO3 CMS project.
- *
- * It is free software; you can redistribute it and/or modify it under
- * the terms of the GNU General Public License, either version 2
- * of the License, or any later version.
- *
- * For the full copyright and license information, please read the
- * LICENSE.txt file that was distributed with this source code.
- *
- * The TYPO3 project - inspiring people to share!
- */
-use TYPO3\CMS\Core\Error\Http\PageNotFoundException;
-use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
-use TYPO3\CMS\Extbase\Mvc\Exception;
-use TYPO3\CMS\Extbase\Mvc\Exception\InvalidActionNameException;
-use TYPO3\CMS\Extbase\Mvc\Exception\InvalidControllerNameException;
-use TYPO3\CMS\Extbase\Mvc\Web\Request;
-use TYPO3\CMS\Extbase\Mvc\Web\RequestBuilder;
-use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
-use TYPO3\CMS\Extbase\Service\EnvironmentService;
-use TYPO3\CMS\Extbase\Service\ExtensionService;
-use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
-
-/**
- * Test case
- */
-class RequestBuilderTest extends UnitTestCase
-{
-    /**
-     * @var RequestBuilder|\PHPUnit\Framework\MockObject\MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface
-     */
-    protected $requestBuilder;
-
-    /**
-     * @var ConfigurationManagerInterface|\PHPUnit\Framework\MockObject\MockObject
-     */
-    protected $mockConfigurationManager;
-
-    /**
-     * @var array
-     */
-    protected $configuration;
-
-    /**
-     * @var ObjectManagerInterface|\PHPUnit\Framework\MockObject\MockObject
-     */
-    protected $mockObjectManager;
-
-    /**
-     * @var ExtensionService|\PHPUnit\Framework\MockObject\MockObject
-     */
-    protected $mockExtensionService;
-
-    /**
-     * @var EnvironmentService|\PHPUnit\Framework\MockObject\MockObject
-     */
-    protected $mockEnvironmentService;
-
-    /**
-     * @var Request|\PHPUnit\Framework\MockObject\MockObject
-     */
-    protected $mockRequest;
-
-    /**
-     * Set up
-     */
-    protected function setUp(): void
-    {
-        parent::setUp();
-        $this->requestBuilder = $this->getAccessibleMock(RequestBuilder::class, ['dummy']);
-        $this->configuration = [
-            'userFunc' => 'Tx_Extbase_Dispatcher->dispatch',
-            'pluginName' => 'Pi1',
-            'extensionName' => 'MyExtension',
-            'controller' => 'TheFirstController',
-            'action' => 'show',
-            'controllerConfiguration' => [
-                'MyExtension\Controller\TheFirstControllerController' => [
-                    'className' => 'MyExtension\Controller\TheFirstControllerController',
-                    'alias' => 'TheFirstController',
-                    'actions' => ['show', 'index', 'new', 'create', 'delete', 'edit', 'update', 'setup', 'test']
-                ],
-                'MyExtension\Controller\TheSecondControllerController' => [
-                    'className' => 'MyExtension\Controller\TheSecondControllerController',
-                    'alias' => 'TheSecondController',
-                    'actions' => ['show', 'index']
-                ],
-                'MyExtension\Controller\TheThirdControllerController' => [
-                    'className' => 'MyExtension\Controller\TheThirdControllerController',
-                    'alias' => 'TheThirdController',
-                    'actions' => ['delete', 'create', 'onlyInThirdController']
-                ]
-            ]
-        ];
-        $this->mockConfigurationManager = $this->createMock(ConfigurationManagerInterface::class);
-        $this->mockRequest = $this->createMock(Request::class);
-        $this->mockObjectManager = $this->createMock(ObjectManagerInterface::class);
-        $this->mockExtensionService = $this->createMock(ExtensionService::class);
-        $this->mockEnvironmentService = $this->getMockBuilder(EnvironmentService::class)
-            ->setMethods(['getServerRequestMethod', 'isEnvironmentInFrontendMode', 'isEnvironmentInBackendMode'])
-            ->getMock();
-        $this->mockEnvironmentService->expects(self::any())->method('isEnvironmentInFrontendMode')->willReturn(true);
-        $this->mockEnvironmentService->expects(self::any())->method('isEnvironmentInBackendMode')->willReturn(false);
-    }
-
-    protected function injectDependencies(): void
-    {
-        $this->mockConfigurationManager->expects(self::any())->method('getConfiguration')->willReturn($this->configuration);
-        $this->requestBuilder->_set('configurationManager', $this->mockConfigurationManager);
-        $this->mockObjectManager->expects(self::any())->method('get')->with(Request::class)->willReturn($this->mockRequest);
-        $this->requestBuilder->_set('objectManager', $this->mockObjectManager);
-        $pluginNamespace = 'tx_' . strtolower($this->configuration['extensionName'] . '_' . $this->configuration['pluginName']);
-        $this->mockExtensionService->expects(self::any())->method('getPluginNamespace')->willReturn($pluginNamespace);
-        $this->requestBuilder->_set('extensionService', $this->mockExtensionService);
-        $this->mockEnvironmentService->expects(self::any())->method('getServerRequestMethod')->willReturn('GET');
-        $this->requestBuilder->_set('environmentService', $this->mockEnvironmentService);
-    }
-
-    /**
-     * @test
-     */
-    public function buildReturnsAWebRequestObject(): void
-    {
-        $this->injectDependencies();
-        $request = $this->requestBuilder->build();
-        self::assertSame($this->mockRequest, $request);
-    }
-
-    /**
-     * @test
-     */
-    public function buildSetsRequestPluginName(): void
-    {
-        $this->injectDependencies();
-        $this->mockRequest->expects(self::once())->method('setPluginName')->with('Pi1');
-        $this->requestBuilder->build();
-    }
-
-    /**
-     * @test
-     */
-    public function buildSetsRequestControllerExtensionName(): void
-    {
-        $this->injectDependencies();
-        $this->mockRequest->expects(self::once())->method('setControllerExtensionName')->with('MyExtension');
-        $this->requestBuilder->build();
-    }
-
-    /**
-     * @test
-     */
-    public function buildSetsRequestControllerName(): void
-    {
-        $this->injectDependencies();
-        $this->mockRequest->expects(self::once())->method('setControllerName')->with('TheFirstController');
-        $this->requestBuilder->build();
-    }
-
-    /**
-     * @test
-     */
-    public function buildSetsRequestControllerActionName(): void
-    {
-        $this->injectDependencies();
-        $this->mockRequest->expects(self::once())->method('setControllerActionName')->with('show');
-        $this->requestBuilder->build();
-    }
-
-    /**
-     * @test
-     */
-    public function buildSetsRequestRequestUri(): void
-    {
-        $this->injectDependencies();
-        $expectedRequestUri = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_REQUEST_URL');
-        $this->mockRequest->expects(self::once())->method('setRequestUri')->with($expectedRequestUri);
-        $this->requestBuilder->build();
-    }
-
-    /**
-     * @test
-     */
-    public function buildSetsRequestBaseUri(): void
-    {
-        $this->injectDependencies();
-        $expectedBaseUri = \TYPO3\CMS\Core\Utility\GeneralUtility::getIndpEnv('TYPO3_SITE_URL');
-        $this->mockRequest->expects(self::once())->method('setBaseUri')->with($expectedBaseUri);
-        $this->requestBuilder->build();
-    }
-
-    /**
-     * @test
-     */
-    public function buildSetsRequestMethod(): void
-    {
-        $this->injectDependencies();
-        $expectedMethod = 'SomeRequestMethod';
-        $mockEnvironmentService = $this->getMockBuilder(EnvironmentService::class)
-            ->setMethods(['getServerRequestMethod'])
-            ->getMock();
-        $mockEnvironmentService->expects(self::once())->method('getServerRequestMethod')->willReturn($expectedMethod);
-        $this->requestBuilder->_set('environmentService', $mockEnvironmentService);
-        $this->mockRequest->expects(self::once())->method('setMethod')->with($expectedMethod);
-        $this->requestBuilder->build();
-    }
-
-    /**
-     * @test
-     */
-    public function buildThrowsExceptionIfExtensionNameIsNotConfigured(): void
-    {
-        $this->expectException(Exception::class);
-        $this->expectExceptionCode(1289843275);
-        unset($this->configuration['extensionName']);
-        $mockConfigurationManager = $this->createMock(ConfigurationManagerInterface::class);
-        $mockConfigurationManager->expects(self::any())->method('getConfiguration')->willReturn($this->configuration);
-        $this->requestBuilder->_set('configurationManager', $mockConfigurationManager);
-        $this->requestBuilder->build();
-    }
-
-    /**
-     * @test
-     */
-    public function buildThrowsExceptionIfPluginNameIsNotConfigured(): void
-    {
-        $this->expectException(Exception::class);
-        $this->expectExceptionCode(1289843277);
-        unset($this->configuration['pluginName']);
-        $mockConfigurationManager = $this->createMock(ConfigurationManagerInterface::class);
-        $mockConfigurationManager->expects(self::any())->method('getConfiguration')->willReturn($this->configuration);
-        $this->requestBuilder->_set('configurationManager', $mockConfigurationManager);
-        $this->requestBuilder->_set('extensionService', $this->mockExtensionService);
-        $this->requestBuilder->build();
-    }
-
-    /**
-     * @test
-     */
-    public function buildThrowsExceptionIfControllerConfigurationIsEmptyOrNotSet(): void
-    {
-        $this->expectException(Exception::class);
-        $this->expectExceptionCode(1316104317);
-        $this->configuration['controllerConfiguration'] = [];
-        $this->mockConfigurationManager->expects(self::any())->method('getConfiguration')->willReturn($this->configuration);
-        $this->requestBuilder->_set('configurationManager', $this->mockConfigurationManager);
-        $this->requestBuilder->_set('extensionService', $this->mockExtensionService);
-        $this->requestBuilder->build();
-    }
-
-    /**
-     * @test
-     */
-    public function buildThrowsExceptionIfControllerConfigurationHasNoDefaultActionDefined(): void
-    {
-        $this->expectException(Exception::class);
-        $this->expectExceptionCode(1295479651);
-        $this->configuration['controllerConfiguration']['MyExtension\Controller\TheFirstControllerController'] = [
-            'className' => 'MyExtension\Controller\TheFirstControllerController',
-            'alias' => 'TheFirstController',
-        ];
-        $this->mockConfigurationManager->expects(self::any())->method('getConfiguration')->willReturn($this->configuration);
-        $this->requestBuilder->_set('configurationManager', $this->mockConfigurationManager);
-        $this->requestBuilder->_set('extensionService', $this->mockExtensionService);
-        $this->requestBuilder->build();
-    }
-
-    /**
-     * @test
-     */
-    public function buildThrowsExceptionIfNoDefaultControllerCanBeResolved(): void
-    {
-        $this->expectException(Exception::class);
-        $this->expectExceptionCode(1316104317);
-        $this->configuration['controllerConfiguration'] = [
-            '' => [
-                'className' => '',
-                'alias' => '',
-                'actions' => ['foo']
-            ]
-        ];
-        $this->mockConfigurationManager->expects(self::any())->method('getConfiguration')->willReturn($this->configuration);
-        $this->requestBuilder->_set('configurationManager', $this->mockConfigurationManager);
-        $this->requestBuilder->_set('extensionService', $this->mockExtensionService);
-        $this->requestBuilder->build();
-    }
-
-    /**
-     * @test
-     */
-    public function buildSetsParametersFromGetAndPostVariables(): void
-    {
-        $this->configuration['extensionName'] = 'SomeExtensionName';
-        $this->configuration['pluginName'] = 'SomePluginName';
-        $this->injectDependencies();
-        $_GET = [
-            'tx_someotherextensionname_somepluginname' => [
-                'foo' => 'bar'
-            ],
-            'tx_someextensionname_somepluginname' => [
-                'parameter1' => 'valueGetsOverwritten',
-                'parameter2' => [
-                    'parameter3' => 'value3'
-                ]
-            ]
-        ];
-        $_POST = [
-            'tx_someextensionname_someotherpluginname' => [
-                'foo' => 'bar'
-            ],
-            'tx_someextensionname_somepluginname' => [
-                'parameter1' => 'value1',
-                'parameter2' => [
-                    'parameter4' => 'value4'
-                ]
-            ]
-        ];
-
-        // testing at which position something gets called is fishy.
-        // why not make this a functional test and test with an actual requestBuilder instance and check the arguments
-        // later on?
-        $this->mockRequest->expects(self::at(9))->method('setArgument')->with('parameter1', 'value1');
-        $this->mockRequest->expects(self::at(10))->method('setArgument')->with(
-            'parameter2',
-            ['parameter3' => 'value3', 'parameter4' => 'value4']
-        );
-        $this->requestBuilder->build();
-    }
-
-    /**
-     * @test
-     */
-    public function buildSetsFormatFromGetAndPostVariables(): void
-    {
-        $this->configuration['extensionName'] = 'SomeExtensionName';
-        $this->configuration['pluginName'] = 'SomePluginName';
-        $this->injectDependencies();
-        $_GET = [
-            'tx_someextensionname_somepluginname' => [
-                'format' => 'GET'
-            ]
-        ];
-        $_POST = [
-            'tx_someextensionname_somepluginname' => [
-                'format' => 'POST'
-            ]
-        ];
-        // phew! Shitty position tests. Who thought this was a good idea?
-        $this->mockRequest->expects(self::at(8))->method('setFormat')->with('POST');
-        $this->requestBuilder->build();
-    }
-
-    /**
-     * @test
-     */
-    public function buildCorrectlySetsAllowedControllerActions(): void
-    {
-        $this->injectDependencies();
-        $expectedResult = [
-            'MyExtension\Controller\TheFirstControllerController' => [
-                'show',
-                'index',
-                'new',
-                'create',
-                'delete',
-                'edit',
-                'update',
-                'setup',
-                'test'
-            ],
-            'MyExtension\Controller\TheSecondControllerController' => [
-                'show',
-                'index'
-            ],
-            'MyExtension\Controller\TheThirdControllerController' => [
-                'delete',
-                'create',
-                'onlyInThirdController'
-            ]
-        ];
-        $this->requestBuilder->build();
-        $actualResult = $this->requestBuilder->_get('allowedControllerActions');
-        self::assertEquals($expectedResult, $actualResult);
-    }
-
-    /**
-     * @test
-     */
-    public function buildThrowsExceptionIfDefaultControllerCantBeDetermined(): void
-    {
-        $this->expectException(Exception::class);
-        $this->expectExceptionCode(1316104317);
-        $this->configuration['controllerConfiguration'] = [];
-        $this->mockConfigurationManager->expects(self::any())->method('getConfiguration')->willReturn($this->configuration);
-        $this->requestBuilder->_set('configurationManager', $this->mockConfigurationManager);
-        $this->mockExtensionService->expects(self::any())->method('getPluginNamespace')->willReturn('tx_myextension_pi1');
-        $this->requestBuilder->_set('extensionService', $this->mockExtensionService);
-        $this->requestBuilder->build();
-    }
-
-    /**
-     * @test
-     */
-    public function buildSetsDefaultControllerIfNoControllerIsSpecified(): void
-    {
-        $this->injectDependencies();
-        $_GET = [
-            'tx_myextension_pi1' => [
-                'foo' => 'bar'
-            ]
-        ];
-        $this->mockRequest->expects(self::once())->method('setControllerName')->with('TheFirstController');
-        $this->requestBuilder->build();
-    }
-
-    /**
-     * @test
-     */
-    public function buildCorrectlySetsSpecifiedControllerNameIfItsAllowedForTheCurrentPlugin(): void
-    {
-        $this->injectDependencies();
-        $_GET = [
-            'tx_myextension_pi1' => [
-                'controller' => 'TheSecondController'
-            ]
-        ];
-        $this->mockRequest->expects(self::once())->method('setControllerName')->with('TheSecondController');
-        $this->requestBuilder->build();
-    }
-
-    /**
-     * @test
-     */
-    public function buildThrowsInvalidControllerNameExceptionIfSpecifiedControllerIsNotAllowed(): void
-    {
-        $this->expectException(InvalidControllerNameException::class);
-        $this->expectExceptionCode(1313855173);
-        $this->mockConfigurationManager->expects(self::any())->method('getConfiguration')->willReturn($this->configuration);
-        $this->requestBuilder->_set('configurationManager', $this->mockConfigurationManager);
-        $this->mockExtensionService->expects(self::any())->method('getPluginNamespace')->willReturn('tx_myextension_pi1');
-        $this->requestBuilder->_set('extensionService', $this->mockExtensionService);
-        $_GET = [
-            'tx_myextension_pi1' => [
-                'controller' => 'SomeInvalidController'
-            ]
-        ];
-        $this->requestBuilder->build();
-    }
-
-    /**
-     * @test
-     */
-    public function buildThrowsPageNotFoundExceptionIfEnabledAndSpecifiedControllerIsNotAllowed(): void
-    {
-        $this->expectException(PageNotFoundException::class);
-        $this->expectExceptionCode(1313857897);
-        $this->configuration['mvc']['throwPageNotFoundExceptionIfActionCantBeResolved'] = 1;
-        $this->mockConfigurationManager->expects(self::any())->method('getConfiguration')->willReturn($this->configuration);
-        $this->requestBuilder->_set('configurationManager', $this->mockConfigurationManager);
-        $this->mockExtensionService->expects(self::any())->method('getPluginNamespace')->willReturn('tx_myextension_pi1');
-        $this->requestBuilder->_set('extensionService', $this->mockExtensionService);
-        $_GET = [
-            'tx_myextension_pi1' => [
-                'controller' => 'SomeInvalidController'
-            ]
-        ];
-        $this->requestBuilder->build();
-    }
-
-    /**
-     * @test
-     */
-    public function buildSetsDefaultControllerNameIfSpecifiedControllerIsNotAllowedAndCallDefaultActionIfActionCantBeResolvedIsSet(): void
-    {
-        $this->configuration['mvc']['callDefaultActionIfActionCantBeResolved'] = 1;
-        $this->injectDependencies();
-        $this->requestBuilder->_set('extensionService', $this->mockExtensionService);
-        $_GET = [
-            'tx_myextension_pi1' => [
-                'controller' => 'SomeInvalidController'
-            ]
-        ];
-        $this->mockRequest->expects(self::once())->method('setControllerName')->with('TheFirstController');
-        $this->requestBuilder->build();
-    }
-
-    /**
-     * @test
-     */
-    public function buildThrowsExceptionIfDefaultActionCantBeDetermined(): void
-    {
-        $this->expectException(Exception::class);
-        $this->expectExceptionCode(1316104317);
-        $this->configuration['controllerConfiguration'] = [];
-        $this->mockConfigurationManager->expects(self::any())->method('getConfiguration')->willReturn($this->configuration);
-        $this->requestBuilder->_set('configurationManager', $this->mockConfigurationManager);
-        $this->mockExtensionService->expects(self::any())->method('getPluginNamespace')->willReturn('tx_myextension_pi1');
-        $this->requestBuilder->_set('extensionService', $this->mockExtensionService);
-        $this->requestBuilder->build();
-    }
-
-    /**
-     * @test
-     */
-    public function buildSetsDefaultActionOfTheCurrentControllerIfNoActionIsSpecified(): void
-    {
-        $this->injectDependencies();
-        $_GET = [
-            'tx_myextension_pi1' => [
-                'controller' => 'TheThirdController'
-            ]
-        ];
-        $this->mockRequest->expects(self::once())->method('setControllerActionName')->with('delete');
-        $this->requestBuilder->build();
-    }
-
-    /**
-     * @test
-     */
-    public function buildCorrectlySetsSpecifiedActionNameForTheDefaultControllerIfItsAllowedForTheCurrentPlugin(): void
-    {
-        $this->injectDependencies();
-        $_GET = [
-            'tx_myextension_pi1' => [
-                'action' => 'create'
-            ]
-        ];
-        $this->mockRequest->expects(self::once())->method('setControllerActionName')->with('create');
-        $this->requestBuilder->build();
-    }
-
-    /**
-     * @test
-     */
-    public function buildCorrectlySetsSpecifiedActionNameForTheSpecifiedControllerIfItsAllowedForTheCurrentPlugin(): void
-    {
-        $this->injectDependencies();
-        $_GET = [
-            'tx_myextension_pi1' => [
-                'controller' => 'TheThirdController',
-                'action' => 'onlyInThirdController'
-            ]
-        ];
-        $this->mockRequest->expects(self::once())->method('setControllerActionName')->with('onlyInThirdController');
-        $this->requestBuilder->build();
-    }
-
-    /**
-     * @test
-     */
-    public function buildThrowsInvalidActionNameExceptionIfSpecifiedActionIsNotAllowed(): void
-    {
-        $this->expectException(InvalidActionNameException::class);
-        $this->expectExceptionCode(1313855175);
-        $this->mockConfigurationManager->expects(self::any())->method('getConfiguration')->willReturn($this->configuration);
-        $this->requestBuilder->_set('configurationManager', $this->mockConfigurationManager);
-        $this->mockExtensionService->expects(self::any())->method('getPluginNamespace')->willReturn('tx_myextension_pi1');
-        $this->requestBuilder->_set('extensionService', $this->mockExtensionService);
-        $_GET = [
-            'tx_myextension_pi1' => [
-                'action' => 'someInvalidAction'
-            ]
-        ];
-        $this->requestBuilder->build();
-    }
-
-    /**
-     * @test
-     */
-    public function buildThrowsPageNotFoundExceptionIfEnabledAndSpecifiedActionIsNotAllowed(): void
-    {
-        $this->expectException(PageNotFoundException::class);
-        $this->expectExceptionCode(1313857898);
-        $this->configuration['mvc']['throwPageNotFoundExceptionIfActionCantBeResolved'] = 1;
-        $this->mockConfigurationManager->expects(self::any())->method('getConfiguration')->willReturn($this->configuration);
-        $this->requestBuilder->_set('configurationManager', $this->mockConfigurationManager);
-        $this->mockExtensionService->expects(self::any())->method('getPluginNamespace')->willReturn('tx_myextension_pi1');
-        $this->requestBuilder->_set('extensionService', $this->mockExtensionService);
-        $_GET = [
-            'tx_myextension_pi1' => [
-                'action' => 'someInvalidAction'
-            ]
-        ];
-        $this->requestBuilder->build();
-    }
-
-    /**
-     * @test
-     */
-    public function buildSetsDefaultActionNameIfSpecifiedActionIsNotAllowedAndCallDefaultActionIfActionCantBeResolvedIsSet(): void
-    {
-        $this->configuration['mvc']['callDefaultActionIfActionCantBeResolved'] = 1;
-        $this->injectDependencies();
-        $this->requestBuilder->_set('extensionService', $this->mockExtensionService);
-        $_GET = [
-            'tx_myextension_pi1' => [
-                'controller' => 'TheThirdController',
-                'action' => 'someInvalidAction'
-            ]
-        ];
-        $this->mockRequest->expects(self::once())->method('setControllerName')->with('TheThirdController');
-        $this->mockRequest->expects(self::once())->method('setControllerActionName')->with('delete');
-        $this->requestBuilder->build();
-    }
-
-    /**
-     * @test
-     * @see TYPO3\Flow\Tests\Unit\Utility\EnvironmentTest
-     */
-    public function untangleFilesArrayTransformsTheFilesSuperglobalIntoAManageableForm(): void
-    {
-        $convolutedFiles = [
-            'a0' => [
-                'name' => [
-                    'a1' => 'a.txt'
-                ],
-                'type' => [
-                    'a1' => 'text/plain'
-                ],
-                'tmp_name' => [
-                    'a1' => '/private/var/tmp/phpbqXsYt'
-                ],
-                'error' => [
-                    'a1' => 0
-                ],
-                'size' => [
-                    'a1' => 100
-                ]
-            ],
-            'b0' => [
-                'name' => [
-                    'b1' => 'b.txt'
-                ],
-                'type' => [
-                    'b1' => 'text/plain'
-                ],
-                'tmp_name' => [
-                    'b1' => '/private/var/tmp/phpvZ6oUD'
-                ],
-                'error' => [
-                    'b1' => 0
-                ],
-                'size' => [
-                    'b1' => 200
-                ]
-            ],
-            'c' => [
-                'name' => 'c.txt',
-                'type' => 'text/plain',
-                'tmp_name' => '/private/var/tmp/phpS9KMNw',
-                'error' => 0,
-                'size' => 300
-            ],
-            'd0' => [
-                'name' => [
-                    'd1' => [
-                        0 => 'd12.txt',
-                        'd2' => [
-                            'd3' => 'd.txt'
-                        ]
-                    ]
-                ],
-                'type' => [
-                    'd1' => [
-                        0 => 'text/plain',
-                        'd2' => [
-                            'd3' => 'text/plain'
-                        ]
-                    ]
-                ],
-                'tmp_name' => [
-                    'd1' => [
-                        0 => '/private/var/tmp/phpMf9Qx9',
-                        'd2' => [
-                            'd3' => '/private/var/tmp/phprR3fax'
-                        ]
-                    ]
-                ],
-                'error' => [
-                    'd1' => [
-                        0 => 0,
-                        'd2' => [
-                            'd3' => 0
-                        ]
-                    ]
-                ],
-                'size' => [
-                    'd1' => [
-                        0 => 200,
-                        'd2' => [
-                            'd3' => 400
-                        ]
-                    ]
-                ]
-            ],
-            'e0' => [
-                'name' => [
-                    'e1' => [
-                        'e2' => [
-                            0 => 'e_one.txt',
-                            1 => 'e_two.txt'
-                        ]
-                    ]
-                ],
-                'type' => [
-                    'e1' => [
-                        'e2' => [
-                            0 => 'text/plain',
-                            1 => 'text/plain'
-                        ]
-                    ]
-                ],
-                'tmp_name' => [
-                    'e1' => [
-                        'e2' => [
-                            0 => '/private/var/tmp/php01fitB',
-                            1 => '/private/var/tmp/phpUUB2cv'
-                        ]
-                    ]
-                ],
-                'error' => [
-                    'e1' => [
-                        'e2' => [
-                            0 => 0,
-                            1 => 0
-                        ]
-                    ]
-                ],
-                'size' => [
-                    'e1' => [
-                        'e2' => [
-                            0 => 510,
-                            1 => 520
-                        ]
-                    ]
-                ]
-            ],
-            'error' => [
-                'name' => 'error_file.txt',
-                'type' => 'text/plain',
-                'tmp_name' => '/private/var/tmp/phpADDu87fE',
-                'error' => 0,
-                'size' => 120
-            ]
-        ];
-        $untangledFiles = [
-            'a0' => [
-                'a1' => [
-                    'name' => 'a.txt',
-                    'type' => 'text/plain',
-                    'tmp_name' => '/private/var/tmp/phpbqXsYt',
-                    'error' => 0,
-                    'size' => 100
-                ]
-            ],
-            'b0' => [
-                'b1' => [
-                    'name' => 'b.txt',
-                    'type' => 'text/plain',
-                    'tmp_name' => '/private/var/tmp/phpvZ6oUD',
-                    'error' => 0,
-                    'size' => 200
-                ]
-            ],
-            'c' => [
-                'name' => 'c.txt',
-                'type' => 'text/plain',
-                'tmp_name' => '/private/var/tmp/phpS9KMNw',
-                'error' => 0,
-                'size' => 300
-            ],
-            'd0' => [
-                'd1' => [
-                    0 => [
-                        'name' => 'd12.txt',
-                        'type' => 'text/plain',
-                        'tmp_name' => '/private/var/tmp/phpMf9Qx9',
-                        'error' => 0,
-                        'size' => 200
-                    ],
-                    'd2' => [
-                        'd3' => [
-                            'name' => 'd.txt',
-                            'type' => 'text/plain',
-                            'tmp_name' => '/private/var/tmp/phprR3fax',
-                            'error' => 0,
-                            'size' => 400
-                        ]
-                    ]
-                ]
-            ],
-            'e0' => [
-                'e1' => [
-                    'e2' => [
-                        0 => [
-                            'name' => 'e_one.txt',
-                            'type' => 'text/plain',
-                            'tmp_name' => '/private/var/tmp/php01fitB',
-                            'error' => 0,
-                            'size' => 510
-                        ],
-                        1 => [
-                            'name' => 'e_two.txt',
-                            'type' => 'text/plain',
-                            'tmp_name' => '/private/var/tmp/phpUUB2cv',
-                            'error' => 0,
-                            'size' => 520
-                        ]
-                    ]
-                ]
-            ],
-            'error' => [
-                'name' => 'error_file.txt',
-                'type' => 'text/plain',
-                'tmp_name' => '/private/var/tmp/phpADDu87fE',
-                'error' => 0,
-                'size' => 120
-            ]
-        ];
-        $requestBuilder = $this->getAccessibleMock(RequestBuilder::class, ['dummy'], [], '', false);
-        $result = $requestBuilder->_call('untangleFilesArray', $convolutedFiles);
-        self::assertSame($untangledFiles, $result);
-    }
-}