Symfony functional tests for wildcard subdomains

Viewed 63

Do you know how to use wildcard subdomains (dynamic subdomains) in symfony functional tests? Here is my code:

$client = static::createClient();
$client->request('GET', '/');
$this->assertEquals(200, $client->getResponse()->getStatusCode());

This fails obviously because the home page of the app is always: someusername.mydomain.com. How can I specify the subdomain?

1 Answers

After diving into symfony source code I found the solution:

$client = static::createClient([], ['HTTP_HOST' => 'someusername.mydomain.com']);
Related