2013-01-02 3 views
4

PHPUnit이 로컬 컴퓨터에서 제대로 작동하면 Travis-CI에서 작동하도록하는 데 문제가 있습니다. 동일한 PHP 버전과 PHPUnit 버전을 사용하고 있습니다.Travis-CI에서 PHPUnit이 실패하지만 로컬로 전달됩니다

내 코드베이스 출력이 저장소의 루트에서 phpunit -c build/phpunit.xml을 실행 https://travis-ci.org/lncd/OAuth2

에있다 https://github.com/lncd/OAuth2
트래비스-CI에서 것은 지역적으로 잘 작동하고 예상대로 테스트를 실행합니다.

트래비스의 로그는 다음과 같습니다

$ 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 '../../src/OAuth2/Authentication/Server.php'; (아래 실행 파일 즉, 두 개의 디렉토리를)로드 require_once을 변경하여 주위를 해본 적이 있지만 트래비스 또는 내 로컬에서 작동하지 않습니다 설정.

내가 뭘 잘못하고 있니? 아니면 트래비스와 관련된 버그입니까?

감사합니다

편집

:

이 디렉토리 구조입니다 명확히하려면 :

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라고는 각각의로드하려고 Server.phpDatabase.php/src 아래의 디렉토리에있는 파일

+0

'위해서 var_dump (에 getcwd(), get_include_path());' – zerkms

+0

'getcwd' :./홈/트래비스/구축/lncd/OAuth2를 'path'을 포함한다 :/홈/트래비스/.phpenv/버전/5.3.19/pear : /home/travis/.phpenv/versions/5.3.19/share/pyrus/.pear/php '__FILE__' :/home/travis/builds/lncd/OAuth2/tests/authentication/server_test .php '__DIR__' :/home/travis/builds/lncd/OAuth2/tests/authentication – alexbilbie

+0

모든 요구 사항을 설치하지 않은 것 같습니다. –

답변

4

저장소에서 보았 듯이 현재 디렉토리의 관련 링크에서 사용하는 파일이 필요합니다. 따라서 PHPUnit은 테스트를 수행하고 파일을 찾을 수없는 동일한 디렉토리에서 필요한 파일을 찾습니다. require_once의 사용을 ../../src/OAuth2/Resource/Server.php으로 변경하거나 PHPUnit 용 bootstrap.php 파일을 추가해야합니다. http://www.phpunit.de/manual/current/en/textui.html : 당신이 여기에서 찾을 수 있습니다 bootstrap.php 파일에 대한

<?php 
if ([email protected] __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'); 
} 

더 많은 정보 : 내가 phpunit을하고 작곡가와 함께 사용할 내 bootstrap.php 파일을 붙여 넣은 복사 아래

.

+0

나는 이미 그것을 시도했습니다 - https://travis-ci.org/lncd/OAuth2/jobs/3922238 - 여전히 고장 트래비스에서 로컬로 깨졌습니다. – alexbilbie

+0

bootstrap.php 파일을 추가하십시오. 테스트에서'require '를 사용하는 것은 좋은 접근 방법이 아닙니다. –

+0

고맙습니다. 나는 당신이 제안한 것을 오해했습니다. 이제 작동 중입니다. – alexbilbie

관련 문제