【发布时间】:2017-05-16 10:21:58
【问题描述】:
我的测试中有语法错误。例如:
/** @test **/
public function show_should_return_a_valid_book()
{
$this
->get('/books/1')
->seeStatusCode(200)
->seeJson([
'id' => 1,
'title' => 'War of the Worlds',
'description' => 'A science fiction masterpiece about martians invading London',
'author' => 'H. G. Wells'
]);
$data = json_decode($this->response->getContent(), true);
$this-> assertArrayHasKey('created_at'), $data);
$this-> assertArrayHasKey('updated_at'), $data);
}
这里我忘了把左括号放在最后两行。
如果我在 Laravel 中这样做,我会收到以下消息:
C:\phpcode\shopcart>phpunit PHP 解析错误:语法错误,C:\phpcode\shopcart\tests\Test 中的意外 ',' 第 33 行的 Test.php
解析错误:语法错误,C:\phpcode\shopcart\tests\TestTest 中出现意外的 ','。 第33行的php
这很好,因为我可以看到错误发生在哪里。
但说到 Lumen,我看到的只是:
C:\phpcode\lumenbook>phpunit
[Symfony\Component\Debug\Exception\FatalThrowableError] 解析错误:语法错误,意外','
如何在 Lumen 中获得更详细的内容?
【问题讨论】:
-
你试过
phpunit -vvv吗? -
是但无济于事。阅读 phpunit 文档是我尝试的第一件事。