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