Wil*_*mes 1 php phpunit vagrant
我正在开发一个 vagrant box,它是为达到目的而定制的。我的 PHPUnit5.2.12版本是5.2.22.
当我执行phpunit命令时,出现以下错误:
PHPUnit_Framework_Exception: PHPUnit_Framework_TestCase::$name must not be null.
Run Code Online (Sandbox Code Playgroud)
代码
下面是我的 phpunit.xml 内容:
<?xml version="1.0" encoding="UTF-8"?>
<phpunit backupGlobals="false"
backupStaticAttributes="false"
bootstrap="bootstrap/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="true"
stopOnFailure="false"
stderr="true">
<testsuites>
<testsuite name="Application Test Suite">
<directory>./tests/</directory>
</testsuite>
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">app/</directory>
</whitelist>
</filter>
<php>
<env name="APP_ENV" value="testing"/>
<env name="CACHE_DRIVER" value="array"/>
<env name="SESSION_DRIVER" value="array"/>
<env name="QUEUE_DRIVER" value="sync"/>
</php>
</phpunit>
Run Code Online (Sandbox Code Playgroud)
所以基本上问题出在被覆盖的__construct方法上:
class TestCase extends Illuminate\Foundation\Testing\TestCase
{
public function __construct()
{
//some code which should not be there
}
}
Run Code Online (Sandbox Code Playgroud)
删除构造函数后异常消失了。