无法解析Laravel别名以生成代码覆盖率

时间:2013-05-31 07:35:08

标签: php jenkins laravel laravel-4

我有一个新的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>

1 个答案:

答案 0 :(得分:1)

没关系,这只是在没有执行任何测试时发生的错误。我用$this->assertTrue(true)添加了一个测试,一切正常。