我正在创建一些功能测试来测试我的控制器。我目前有2个功能。 1用于登录,1用于实体生命周期。PHPUnit当前节点列表为空
都应该正常运行(我猜)。然而,我收到以下错误:
The current node list is empty
我试图从测试类中删除所有我没有结果的代码。我也尝试添加一个空的方法,看看它是否也发生在那里。是的,它的确如此。该测试也崩溃。
所以我搜索了一个解决方案。我尝试了一些东西,比如:
($client = static::createClient(array(), array('HTTP_HOST' => 'symfony.dev'));)
var_dump($client->getResponse()->getContent());(其获得的页面,测试应该是)
$response = $this->render('CMSBundle:Front:test.html.twig',);
$response->headers->set('Content-Type', 'text/html');
return $response;
和其他一些东西。他们都没有工作。我似乎无法弄清楚问题所在。
有没有人对这个问题有任何建议?
我的测试代码:
public function testLogin()
{
$client = $this->client;
$crawler = $client->request('GET', '/admin/login');
$this->assertEquals(200, $client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /admin/login");
// Fill in the form and submit it
$form = $crawler->selectButton('Inloggen')->form(array(
'_username' => 'erik',
'_password' => 'erik'
));
$client->submit($form);
}
提前感谢!