当 PHPUnit 在我的本地机器上正常工作时,我在让 PHPUnit 在 Travis-CI 上工作时遇到了一些麻烦。我使用的是相同的 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
在 /tests 目录下调用的两个文件server_test.php
都试图从 /src 下的目录加载相应Server.php
的文件Database.php