Feature #78358
closed
Allow other HTTP verbs than GET in functional test
Added by Anja Leichsenring almost 8 years ago.
Updated over 7 years ago.
Description
Using the functional test framework, one can test frontend requests using the GET method. In order to prepare for full API requests, we need to allow and test other methods as well, like POST, PUT and DELETE. Those requests can even transfer payload.
As a testing playground, I created a class extending typo3/sysext/core/Classes/Tests/FunctionalTestCase.php
with a new function
protected function getFrontendResponseForTypenum(int $typeNum, string $apiRoute = '', string $requestMethod = 'GET', array $inputData = []): Response
{
$additionalParameter = '';
if (!empty($apiRoute)) {
$additionalParameter .= '&api=' . $apiRoute;
}
$arguments = array(
'documentRoot' => $this->instancePath,
'requestUrl' => 'http://localhost/?type=' . $typeNum . $additionalParameter,
'requestMethod' => $requestMethod,
'inputData' => json_encode($inputData),
);
... same as in getFrontendResponse() ...
return $response;
}
This serves my personal testing use case, but might serve as example what I do as well. This method is more or less copied from getFrontendResponse()
With this class I am able to send PUT and DELETE requests to my testing classes.
- Status changed from New to Under Review
- Description updated (diff)
- Target version changed from 8 LTS to 9.0
- Status changed from Under Review to Rejected
testing framework is no longer part of the core
Also available in: Atom
PDF