我正在尝试在symfony 4中运行几个单元测试。实际上,我正在尝试测试表单提交。
这是我的单元测试,
public function testAccountCreation() {
$this->logIn();
$crawler = $this->client->request('GET', '/admin/account');
$form = $crawler->selectButton('admin_user[save]')->form();
$form['admin_user[displayName]'] = 'Vim';
$form['admin_user[username]'] = 'user5@user.com';
$form['admin_user[password]'] = 'P3ssword';
$form['admin_user[phoneNumber]'] = '1234789';
$form['admin_user[roles][]'] = 'ROLE_ADMIN';
$crawler = $this->client->submit($form);
$this->assertContains(
'Your changes were saved!', $this->client->getResponse()->getContent()
);
}
但是我遇到这个错误,
App \ Tests \ AdminControllerTest :: testAccountCreation InvalidArgumentException:无法访问的字段“”
如果有人可以帮助,那就太好了。