Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TravisCI PHPUnit Fatal Error - Call to undefined method PHPUnit_Util_Configuration::getTestdoxGroupConfiguration()

My TravisCI build is failing due to a fatal error referencing PHPUnit_Util_Configuration::getTestdoxGroupConfiguration() even though PHPUnit runs without issue locally. I've verified that Composer on TravisCI is installing the same version of PHPUnit as what I've installed locally.

I noticed that a recent patch references testdox groups configuration specifically, but I can't figure out why that change might have broken PHPUnit within TravisCI but not my local version.

Here's the Composer from TravisCI:

- Installing phpunit/phpunit (5.7.6) Downloading: 100%

And here's the fatal error and stack trace from TravisCI:

PHP Fatal error:  Call to undefined method PHPUnit_Util_Configuration::getTestdoxGroupConfiguration() in /home/travis/build/twistofreality/dilmun/vendor/phpunit/phpunit/src/TextUI/TestRunner.php on line 1042
PHP Stack trace:
PHP   1. {main}() /home/travis/.phpenv/versions/5.6.5/bin/phpunit:0
PHP   2. PHPUnit_TextUI_Command::main() /home/travis/.phpenv/versions/5.6.5/bin/phpunit:722
PHP   3. PHPUnit_TextUI_Command->run() phar:///home/travis/.phpenv/versions/5.6.5/bin/phpunit/phpunit/TextUI/Command.php:104
PHP   4. PHPUnit_TextUI_TestRunner->doRun() phar:///home/travis/.phpenv/versions/5.6.5/bin/phpunit/phpunit/TextUI/Command.php:152
PHP   5. PHPUnit_TextUI_TestRunner->handleConfiguration() /home/travis/build/twistofreality/dilmun/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:163
like image 460
Derek Avatar asked Jan 27 '17 02:01

Derek


2 Answers

The problem is a version mismatch between the global TravisCI version of PHPUnit and what Composer is installing. Note the last two lines of the stack trace:

PHP   4. PHPUnit_TextUI_TestRunner->doRun() phar:///home/travis/.phpenv/versions/5.6.5/bin/phpunit/phpunit/TextUI/Command.php:152
PHP   5. PHPUnit_TextUI_TestRunner->handleConfiguration() /home/travis/build/twistofreality/dilmun/vendor/phpunit/phpunit/src/TextUI/TestRunner.php:163

The last line references vendor/phpunit (in this case, version 5.7.6, per the Composer output), whereas the second to last line references TravisCI's global bin/phpunit (version 5.6.5). It's likely the patch in the more recent version breaks something when trying to call something in the global version.

Updating .travis.yml to use vendor/bin/phpunit (plus whatever flags) to use the version installed by Composer fixes the issue. Specifically, adding this line to .travis.yml (or, as in my case, modifying the existing phpunit line), will do the trick:

script:
    - vendor/bin/phpunit [phpunit flags here]
like image 200
Derek Avatar answered Nov 04 '22 19:11

Derek


Simply add

script:
  - vendor/bin/phpunit

to your travis.yml file

like image 41
Nenad Avatar answered Nov 04 '22 21:11

Nenad