当我阅读 symfony 文档https://symfony.com/doc/current/testing.html时,他们使用以下命令初始化客户端:
$client = static::createClient();
Run Code Online (Sandbox Code Playgroud)
他们可以使用相对路径发出请求
$client->request('GET', '/post/hello-world');
Run Code Online (Sandbox Code Playgroud)
我的项目中的问题是我生成了这个网址:http://localhost/api/users但我想要的是http://myproject.localhost/api/users
我如何根据我要启动测试的环境更改基本网址(因为在我的测试环境中,我将有http://myproject.test/api/users
感谢您的帮助
您应该能够将服务器信息作为 createClient 方法的第二个参数传递,例如:
$client = static::createClient(array(), array('HTTP_HOST' => 'localhost/myalias/app_dev.php')) ;
Run Code Online (Sandbox Code Playgroud)
希望这有帮助
归档时间: |
|
查看次数: |
2234 次 |
最近记录: |