2016-04-06 33 views
2

我有一個簡單的PHPUnit/Symfony WebTestCase,用於測試我們網站的登錄表單。PHPUnit + Symfony:Crawler關注重定向SegFault

$form = $crawler->filter("#register")->form(); 

// set form values 

$crawler = $this->client->submit($form); 

表單將提交給/register,然後重定向到/registered成功(和200/OK回到/register失敗)。

如果我使用$this->client->followRedirects();之前的塊或$this->client->followRedirect();提交後,我得到一個段錯誤。真的沒有跡象表明段錯在哪裏發生。

其他注意事項:如果我運行JUST測試在這個測試父類(2測試),即使用--filter [THE CLASS]它運行良好。如果我嘗試運行這個測試,以及全套(〜15測試),我會得到段錯誤。

我試過給phpunit更多內存使用-d標誌,但這並沒有真正的幫助。

回答

2

該問題可以在控制器與其他組件結合使用。

我建議您使用Process Isolation in PHPUnit,以便您可以在單獨的PHP進程中運行關鍵測試。作爲例子,你可以使用下面的註解:

Indicates that all tests in a test class should be run in a separate PHP process:

/** 
* @runTestsInSeparateProcesses 
*/ 
class MyTest extends PHPUnit_Framework_TestCase 
{ 
    // ... 
} 

Indicates that a test should be run in a separate PHP process:

class MyTest extends PHPUnit_Framework_TestCase 
{ 
    /** 
    * @runInSeparateProcess 
    */ 
    public function testInSeparateProcess() 
    { 
     // ... 
    } 
} 

希望這有助於

+0

酷感謝,我給一個去。 –

+0

看起來像它的工作,謝謝! –

+0

不錯的一個。爲我解決了seg錯誤:)謝謝:) – Sharpy35