php - Travis 自动加载器 PhpUnit

标签 php phpunit travis-ci

这是我的 PHPUnit 配置文件。出于某种原因,它适用于我的本地环境,但是当我尝试使用 travis 时,它说由于某种原因它找不到类。

并且 bootstrap="./vendor/autoload.php"在 Travis 机器上没有找到

   <?xml version="1.0" encoding="UTF-8"?>
    <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
             xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.2/phpunit.xsd"
             backupGlobals="false"
             verbose="true"
             bootstrap="./vendor/autoload.php">
        <testsuite name="aaaa">
            <directory suffix="Test.php">tests</directory>
        </testsuite>

        <logging>
            <log type="coverage-html" target="build/coverage"/>
        </logging>

        <filter>
            <whitelist processUncoveredFilesFromWhitelist="true">
                <directory suffix=".php">src</directory>
            </whitelist>
        </filter>
    </phpunit>

最佳答案

如果您使用的是 composer,它会将自动加载器和任何依赖项安装到 vendor 目录。通常将 vendor 目录放入您的 .gitignore 文件中。

这意味着当 travis check out 你的项目时,它不会有 vendor 目录。在运行测试之前,您需要运行 composer 来安装依赖项 和自动加载器。

确保提交您的 composer.jsoncomposer.lock 文件并将其放入您的 .travis.yml:

install: composer install

关于php - Travis 自动加载器 PhpUnit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27139723/

相关文章:

php静态函数

PHPUnit:assertFileEquals() 失败

php - Laravel 5 单元测试。无法设置请求对象的 JSON

PHPUnit 确保特征满足接口(interface)

django - 在 travis 构建中选择正确的 postgresql 版本

php - 如何让浏览器在使用后退按钮时重新发布表单数据?

php - 递归函数将数组返回为 NULL,而返回前的 var_dump 有效

go - 特拉维斯 CI + 去 : can't build

php - 在 Travis 上使用 php-imagick 阅读 pdf 文件

php - 如何使用 jQuery 在模式弹出窗口中传递值