1
我已經安裝了FosUserBundle,我想用PhpUnit進行測試以檢查用戶是否可以登錄,但我的代碼必須是錯誤的,因爲我無法重定向。如何測試用戶登錄頁面?
我的代碼:
public function testLogin()
{
$client = static::createClient();
$crawler = $client->request('GET', '/crm/login');
$buttonCrawlerNode = $crawler->selectButton('_submit');
$form = $buttonCrawlerNode->form();
$data = array('_username' => 'root','_password' => 'toor');
$client->submit($form,$data);
$crawler = $this->client->followRedirect();
$crawler = $client->request('GET', '/crm/home');
}
2種不同的情況下,也許你使用的是不同的客戶端實例? '$ this-> client-> followRedirect();' - >'$ client-> followRedirect();' – 1ed