Reputation: 1569
When i read symfony documentation https://symfony.com/doc/current/testing.html, they initialize the client with this command :
$client = static::createClient();
And they can do a request with a relative path
$client->request('GET', '/post/hello-world');
The problem in my project is that i got this url being generated : http://localhost/api/users but what i want is http://myproject.localhost/api/users
How can i change the base url depending on the environment i am going to launch tehe tests (besause in my test environment, i will have http://myproject.test/api/users
Thanks for your help
Upvotes: 5
Views: 2554
Reputation: 51
Also you can try to set manually:
$client = static::createClient();
$client->setServerParameter('HTTP_HOST', 'myproject.localhost');
Upvotes: 4
Reputation: 39380
You should be able to pass server info as second argument of the createClient method, as example:
$client = static::createClient(array(), array('HTTP_HOST' => 'localhost/myalias/app_dev.php')) ;
Hope this help
Upvotes: 4