2017-03-07 78 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