Phpunit Symfony测试获取表单错误
如果我有一个功能测试,比如:Phpunit Symfony测试获取表单错误,phpunit,symfony,Phpunit,Symfony,如果我有一个功能测试,比如: public function testCreate() { $client = $this->makeClient(); $crawler = $client->request('POST', "/post/new"); $form = $crawler->selectButton("Create Post")->form(); $values = $form->getPhpValues();
public function testCreate()
{
$client = $this->makeClient();
$crawler = $client->request('POST', "/post/new");
$form = $crawler->selectButton("Create Post")->form();
$values = $form->getPhpValues();
$values['post']['title'] = 'test';
$values['post']['content'] = null; // Should fail because it isn't a string.
$crawler = $client->request($form->getMethod(), $form->getUri(), $values,
$form->getPhpFiles());
assertEquals() // What goes here?
}
如何使用
爬虫
获取表单错误并进行比较?我为您提供了两种可能的解决方案:
谢谢-我会选择1,我想我必须使用
filter
,而且没有捷径?是的,就像你用其他方法一样使用filter()
。