当PHPUnit在我的本地机器上正常工作时,我很难让它在Travis上工作。我使用的是相同的PHP版本和PHPUnit版本。
我的代码库在https://github.com/lncd/OAuth2
Travis-CI输出在https://travis-ci.org/lncd/OAuth2。
从存储库的根处执行phpunit -c build/phpunit.xml在本地运行良好,测试按预期执行。
Travis的日志是:
$ cd ~/builds
$ git clone --branch=develop --depth=100 --quiet git://github.com/lncd/OAuth2.git lncd/OAuth2
$ cd lncd/OAuth2
$ git checkout -qf 1c3b319aa6c8f5521d5123f0e6affca94ee35010
$ phpenv global 5.3
$ php --version
PHP 5.3.19 (cli) (built: Dec 20 2012 09:57:38) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
    with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans
$ phpunit -c build/phpunit.xml
PHP Warning:  require_once(src/OAuth2/Authentication/Server.php): failed to open stream: No such file or directory in /home/travis/builds/lncd/OAuth2/tests/authentication/server_test.php on line 3
PHP Stack trace:
PHP   1. {main}() /home/travis/.phpenv/versions/5.3.19/bin/phpunit:0
PHP   2. PHPUnit_TextUI_Command::main() /home/travis/.phpenv/versions/5.3.19/bin/phpunit:46
PHP   3. PHPUnit_TextUI_Command->run() /home/travis/.phpenv/versions/5.3.19/share/pyrus/.pear/php/PHPUnit/TextUI/Command.php:129
PHP   4. PHPUnit_TextUI_Command->handleArguments() /home/travis/.phpenv/versions/5.3.19/share/pyrus/.pear/php/PHPUnit/TextUI/Command.php:138
PHP   5. PHPUnit_Util_Configuration->getTestSuiteConfiguration() /home/travis/.phpenv/versions/5.3.19/share/pyrus/.pear/php/PHPUnit/TextUI/Command.php:657
PHP   6. PHPUnit_Util_Configuration->getTestSuite() /home/travis/.phpenv/versions/5.3.19/share/pyrus/.pear/php/PHPUnit/Util/Configuration.php:784
PHP   7. PHPUnit_Framework_TestSuite->addTestFiles() /home/travis/.phpenv/versions/5.3.19/share/pyrus/.pear/php/PHPUnit/Util/Configuration.php:860
PHP   8. PHPUnit_Framework_TestSuite->addTestFile() /home/travis/.phpenv/versions/5.3.19/share/pyrus/.pear/php/PHPUnit/Framework/TestSuite.php:416
PHP   9. PHPUnit_Util_Fileloader::checkAndLoad() /home/travis/.phpenv/versions/5.3.19/share/pyrus/.pear/php/PHPUnit/Framework/TestSuite.php:355
PHP  10. PHPUnit_Util_Fileloader::load() /home/travis/.phpenv/versions/5.3.19/share/pyrus/.pear/php/PHPUnit/Util/Fileloader.php:76
PHP  11. include_once() /home/travis/.phpenv/versions/5.3.19/share/pyrus/.pear/php/PHPUnit/Util/Fileloader.php:92我曾经尝试过修改require_once以加载require_once '../../src/OAuth2/Authentication/Server.php';(即从执行文件中下来的两个目录),但这在Travis或我的本地设置上不起作用。
我做错了什么?或者是特拉维斯的窃听器?
谢谢
编辑:
为了澄清这一点,目录结构如下:
build
    /phpunit.xml
src
    /OAuth2
        /Authentication
            /Database.php
            /Server.php
        /Resource
            /Database.php
            /Server.php
tests
    /authentication
        /database_mock.php
        /server_test.php
    /resource
        /database_mock.php
        /server_test.php两个名为server_test.php的/tests目录下的文件都试图从/src目录中加载各自的Server.php和Database.php文件。
发布于 2013-01-02 21:54:55
正如我从您的存储库中看到的,您需要使用当前目录中的相关链接。因此,PHPUnit试图在放置测试的同一个目录中找到所需的文件,但没有找到任何文件。您需要将require_once的用法更改为../../src/OAuth2/Resource/Server.php或为PHPUnit添加bootstrap.php文件。
下面我复制粘贴了与PHPUnit和Composer一起使用的PHPUnit文件:
<?php
if (!@include __DIR__ . '/../vendor/autoload.php') {
    die('You must set up the project dependencies, run the following commands:
        wget http://getcomposer.org/composer.phar
        php composer.phar install');
}有关bootstrap.php文件的更多信息,您可以在这里找到:http://www.phpunit.de/manual/current/en/textui.html。
https://stackoverflow.com/questions/14129439
复制相似问题