对于我正在经历的Laravel 4问题,我非常感谢.
我正在测试控制器路由,特别是负责路由问卷调查的控制器.我正在测试以下场景:用户试图跳过问题,用户请求不存在的问题......等等.
我为所有场景编写的测试到目前为止使用PHPunit按预期工作.我正在编写的测试涉及多个$this->call()或$this->client->request()执行,这就是事情发生的地方.如果我在一个测试方法中执行$this->call()或执行$this->client->request()太多次(特定于2或更多),我会在终端中获得ErrorException:
{"error":{"type":"ErrorException","message":"Undefined variable:header","file":"/ Volumes/Dev HD/dmh/app/views/layouts/steps.php","行":1}}
如果我减少的数量$this->call()或$this->client->request()测试方法一,工作上的事情,并没有显示异常.我一直在使用以下代码:
/**
* When the user skips questions they have not yet answered, the user
* should be redirected back to the first unanswered question.
*
* @return void
*/
public function testDiscoverSkipQuestions()
{
// Get the first question.
$domCrawler = $this->client->request('GET', 'style/discover');
// Answer the first question
$form = $domCrawler->selectButton("Next »")->form();
$form['question_1'] = 'A:0';
$response = $this->client->submit($form);
$this->assertRedirectedTo('style/discover/2'); …Run Code Online (Sandbox Code Playgroud)