-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Description
What are you trying to achieve?
While writing functional tests I need to send POST ajax request. Example:
$I->amOnPage($homeUrl);
$tableCellXPath = '//*[@id="main"]/table/tbody/tr[1]/td[5]/div[1]';
$entityId = $I->grabAttributeFrom("{$tableCellXPath}/a[2]", "data-entity_id");
$I->sendAjaxRequest('POST', '/url', ['entityId' => $entityId]);I expect that ajax request will be send and status code 200 will be obtained.
What do you get instead?
Line:
$I->sendAjaxRequest('POST', '/url', ['entityId' => $entityId]);Produces request, BUT it could not be found by Symfony RequestMatcher, because the request is sent by GET and then by POST. The request produces 405 status code. (If Symfony controller has methods={"POST"} annotation and cache_router is enabled in Symfony Module configuration.
Proposition
Document section should be updated for better explanation of cache_router setting and its impact on tests behaviour. It could save some hours of our colleagues.
- Codeception version: 4.2.0
- PHP Version: 7.4
- Operating System: Ubuntu
modules:
enabled:
- Symfony:
app_path: 'src'
environment: 'test'
cache_router: true
- Doctrine2:
....Metadata
Metadata
Assignees
Labels
No labels