我有一个全新的 Laravel 4 设置,没有测试。我正在尝试为我们的 CI 服务器(运行 Jenkins)设置它,所以我想要代码覆盖率。当它试图生成三叶草报告时会出现问题,因为 Laravel 使用类的别名。
错误信息
Generating code coverage report in Clover XML format ...
PHP Fatal error: Class 'Eloquent' not found in <path>/app/models/User.php on line 6
如果我将用户模型更改为扩展Illuminate\Database\Eloquent\Model
而不仅仅是Eloquent
(别名),我不会收到此错误。我更喜欢使用别名,如果有人对此有解决方案,我将不胜感激。
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="false"
stopOnFailure="false"
syntaxCheck="false"
>
<testsuites>
<testsuite name="Test suite">
<directory>./app/tests/</directory>
</testsuite>
</testsuites>
<logging>
<log type="coverage-html" target="build/coverage" title="coverage"
charset="UTF-8" yui="true" highlight="true"
lowUpperBound="35" highLowerBound="70"/>
<log type="coverage-clover" target="build/logs/clover.xml"/>
<log type="junit" target="build/logs/junit.xml" logIncompleteSkipped="false"/>
</logging>
<filter>
<blacklist>
<directory suffix=".php">/usr/local/</directory>
<directory suffix=".php">/usr/share/</directory>
<directory suffix=".php">vendor</directory>
</blacklist>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./app/models</directory>
<directory suffix=".php">./app/controllers</directory>
</whitelist>
</filter>
</phpunit>