Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Documentation Invalid for Testing Host Matched Routes #6421

Closed
@tomchkk

Description

@tomchkk

The section Testing your Controllers in the How to Match a Route Based on the Host document no longer appears to be valid from Symfony 2.8.

The documentation indicates to set the Host HTTP header on the request:

$crawler = $client->request(
    'GET',
    '/homepage',
    array(),
    array(),
    array('HTTP_HOST' => 'm.' . $client->getContainer()->getParameter('domain'))
);

After recently updating my application from 2.7 to 2.8, I found that this technique no longer works, and seems to have been invalided by the fix for issue #15398.

As per the amended test class src/Symfony/Component/BrowserKit/Tests/ClientTest.php the correct method now appears to be to provide the full uri to the $client->request() method.

The updated test request might instead look like this:

$uri = 'm.' . $client->getContainer()->getParameter('domain')) . '/homepage';
$crawler = $client->request('GET', $uri);

Metadata

Metadata

Assignees

No one assigned

    Labels

    TestingactionableClear and specific issues ready for anyone to take them.bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions