phpunit中的模拟http服务器
我为我的控制器写了一个测试,它需要$\u服务器[REQUEST\u URI],我如何模拟它并使它运行 我的控制器是phpunit中的模拟http服务器,php,unit-testing,phpunit,fuelphp,Php,Unit Testing,Phpunit,Fuelphp,我为我的控制器写了一个测试,它需要$\u服务器[REQUEST\u URI],我如何模拟它并使它运行 我的控制器是 public function action_index() { $presenter = Presenter::forge('www/php'); $this->template->content = $presenter; } 我的测试是 public function test_action_index() { $response = Request
public function action_index()
{
$presenter = Presenter::forge('www/php');
$this->template->content = $presenter;
}
我的测试是
public function test_action_index()
{
$response = Request::forge('www/php')
->set_method('GET')
->execute()
->response();
$this->assertContains(' List', $response->body->__toString());
Cli::write(__METHOD__ . " √ \n", 'green');
}
您的代码将取决于全局!不例如,使用请求对象获取uri。我认为测试控制器不是PhpUnit的事。我最好使用一些E2E测试