当我对它执行phpunit测试时,我的symfony2应用程序的主页上出现'InvalidArgumentException:当前节点列表为空'。请帮忙。
路径是/学生。我可以在我的测试中访问/ student / 1 / edit和/ student / 1 / show,但不能访问/ student。
以下是测试:
public function testindexAction(){
$client = static::createClient();
$client->followRedirects(true);
$crawler = $client->request("GET","/student");
// echo $client->getRequest()->getUri();
// $this->assertRegExp('/\/student$/', $client->getRequest()->getUri());
$heading = $crawler->filter('h1')->eq(0)->text();
$this->assertEquals('Student list',$heading);
}
错误是: StudentBundle \测试\控制器\ StudentControllerTest :: testindexAction InvalidArgumentException:当前节点列表为空。
php app/console router:debug -e test | grep /student
student ANY ANY ANY /student/
student_show ANY ANY ANY /student/{id}/show
student_new ANY ANY ANY /student/new
student_create POST ANY ANY /student/create
student_edit ANY ANY ANY /student/{id}/edit
student_update POST|PUT ANY ANY /student/{id}/update
student_delete POST|DELETE ANY ANY /student/{id}/delete
答案 0 :(得分:0)
主页上是否有重定向?
尝试通过
进行调试var_dump($client->getResponse()->getContent());