Skip to content

Symfony module: documentation improvement #6763

@rtwent

Description

@rtwent

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

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions