我正在創建一些功能測試來測試我的控制器。我目前有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);
}
提前感謝!