yauh / php-ci

An automated installation routine for setting up Jenkins CI for PHP projects
35 stars 29 forks source link

Failing to run unit tests #8

Open miogalang opened 9 years ago

miogalang commented 9 years ago

I tried using ansible to make this work. Had a few edits but I finally got it running. I now run into this error as it tries to build the sample project.

Any Ideas?

phpunit:
    [exec] PHP Warning:  require_once(PHPUnit/Runner/Version.php): failed to open stream: No such file or directory in /var/www/yii-1.1.14.f0fee9/framework/test/CTestCase.php on line 11
    [exec] PHP Stack trace:
    [exec] PHP   1. {main}() /usr/bin/phpunit:0
    [exec] PHP   2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:583
    [exec] PHP   3. PHPUnit_TextUI_Command->run() phar:///usr/bin/phpunit/phpunit/TextUI/Command.php:132
    [exec] PHP   4. PHPUnit_Runner_BaseTestRunner->getTest() phar:///usr/bin/phpunit/phpunit/TextUI/Command.php:153
    [exec] PHP   5. PHPUnit_Framework_TestSuite->addTestFiles() phar:///usr/bin/phpunit/phpunit/Runner/BaseTestRunner.php:97
    [exec] PHP   6. PHPUnit_Framework_TestSuite->addTestFile() phar:///usr/bin/phpunit/phpunit/Framework/TestSuite.php:411
    [exec] PHP   7. PHPUnit_Util_Fileloader::checkAndLoad() phar:///usr/bin/phpunit/phpunit/Framework/TestSuite.php:358
    [exec] PHP   8. PHPUnit_Util_Fileloader::load() phar:///usr/bin/phpunit/phpunit/Util/Fileloader.php:77
    [exec] PHP   9. include_once() phar:///usr/bin/phpunit/phpunit/Util/Fileloader.php:93
    [exec] PHP  10. YiiBase::autoload() /var/www/yii-1.1.14.f0fee9/framework/YiiBase.php:0
    [exec] PHP  11. include() /var/www/yii-1.1.14.f0fee9/framework/YiiBase.php:401
    [exec] PHP Fatal error:  require_once(): Failed opening required 'PHPUnit/Runner/Version.php' (include_path='.:/var/lib/jenkins/jobs/yii-sample-project/workspace/src/protected/components:/var/lib/jenkins/jobs/yii-sample-project/workspace/src/protected/models:/usr/share/php:/usr/share/pear') in /var/www/yii-1.1.14.f0fee9/framework/test/CTestCase.php on line 11
    [exec] PHP Stack trace:
    [exec] PHP   1. {main}() /usr/bin/phpunit:0
    [exec] PHP   2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:583
    [exec] PHP   3. PHPUnit_TextUI_Command->run() phar:///usr/bin/phpunit/phpunit/TextUI/Command.php:132
    [exec] PHP   4. PHPUnit_Runner_BaseTestRunner->getTest() phar:///usr/bin/phpunit/phpunit/TextUI/Command.php:153
    [exec] PHP   5. PHPUnit_Framework_TestSuite->addTestFiles() phar:///usr/bin/phpunit/phpunit/Runner/BaseTestRunner.php:97
    [exec] PHP   6. PHPUnit_Framework_TestSuite->addTestFile() phar:///usr/bin/phpunit/phpunit/Framework/TestSuite.php:411
    [exec] PHP   7. PHPUnit_Util_Fileloader::checkAndLoad() phar:///usr/bin/phpunit/phpunit/Framework/TestSuite.php:358
    [exec] PHP   8. PHPUnit_Util_Fileloader::load() phar:///usr/bin/phpunit/phpunit/Util/Fileloader.php:77
    [exec] PHP   9. include_once() phar:///usr/bin/phpunit/phpunit/Util/Fileloader.php:93
    [exec] PHP  10. YiiBase::autoload() /var/www/yii-1.1.14.f0fee9/framework/YiiBase.php:0
    [exec] PHP  11. include() /var/www/yii-1.1.14.f0fee9/framework/YiiBase.php:401
yauh commented 9 years ago

Off the top of my hat - the Yii framework is available in the /var/www folder? No such file or directory in /var/www/yii-1.1.14.f0fee9/framework/test/CTestCase.php

miogalang commented 9 years ago

Yes it is available.

    mio@jenkins:/var/www$ ls -lta
    total 20
    drwxr-xr-x  4 root root  4096 Oct  2 13:10 .
    drwxr-xr-x 13 root root  4096 Oct  1 19:01 ..
    lrwxrwxrwx  1 root root    26 Oct  1 18:05 yii -> /var/www/yii-1.1.14.f0fee9
    -rw-r--r--  1 root root   177 Oct  1 14:48 index.html
    drwxr-xr-x  5  501 staff 4096 Aug 12  2013 yii-1.1.14.f0fee9

I am trying a few more stuff I found stackoverflow. Including updating Yii, and installing PHPUnit_CodeCoverage. Will come back with results.

miogalang commented 9 years ago

Ok it seems phpunit does not want itself installed using pear anymore

see: https://github.com/sebastianbergmann/phpunit/issues/1173

miogalang commented 9 years ago

@yauh Just an update I was able to make it work by installing the phpunit stuff via composer. I will find some time to clean it up over the weekend and send a pull request if you are interested.

yauh commented 9 years ago

Great, love to see your pull request. Thanks for investigating!