2017-03-07 39 views
0

如果我有一个功能测试,如:Symfony的测试获取表单错误

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? 
} 

如何使用crawler拿到表格错误并加以比较?

回答

1

我看你们两个可能的解决方案:

  1. 使用履带,以检查您的渲染HTML代码中的实际呈现形式的错误。
  2. 请使用Profiler和访问形式的数据采集器:http://symfony.com/doc/current/testing/profiling.html
+0

感谢您的 - 我会用1去,我想我将不得不使用'filter'而且也没有捷径? – Darkstarone

+1

是的,只要使用'filter()'就像你做的那样。 – xabbuh