Search code examples
phpsymfonyphpunitcodeception

How to configure codeception for functional test with Symfony2?


I'm using this functional.suite.yml:

class_name: FunctionalTester
modules:
    enabled:
        - Symfony2
        - \Helper\Functional

I build and run tests and get:

Trying to Log in and see result (LoginCept)... PHP Fatal error:  Undefined class constant 'UNKNOWN' in phar:///usr/local/bin/codecept/vendor/phpunit/phpunit/src/Framework/TestResult.php on line 592
PHP Stack trace:
PHP   1. {main}() /usr/local/bin/codecept:0
PHP   2. require_once() /usr/local/bin/codecept:7
PHP   3. Symfony\Component\Console\Application->run() phar:///usr/local/bin/codecept/codecept:34
PHP   4. Symfony\Component\Console\Application->doRun() phar:///usr/local/bin/codecept/vendor/symfony/console/Application.php:123
PHP   5. Symfony\Component\Console\Application->doRunCommand() phar:///usr/local/bin/codecept/vendor/symfony/console/Application.php:192
PHP   6. Symfony\Component\Console\Command\Command->run() phar:///usr/local/bin/codecept/vendor/symfony/console/Application.php:844
PHP   7. Codeception\Command\Run->execute() phar:///usr/local/bin/codecept/vendor/symfony/console/Command/Command.php:259
PHP   8. Codeception\Command\Run->runSuites() phar:///usr/local/bin/codecept/src/Codeception/Command/Run.php:189
PHP   9. Codeception\Codecept->run() phar:///usr/local/bin/codecept/src/Codeception/Command/Run.php:262
PHP  10. Codeception\Codecept->runSuite() phar:///usr/local/bin/codecept/src/Codeception/Codecept.php:172
PHP  11. Codeception\SuiteManager->run() phar:///usr/local/bin/codecept/src/Codeception/Codecept.php:203
PHP  12. Codeception\PHPUnit\Runner->doEnhancedRun() phar:///usr/local/bin/codecept/src/Codeception/SuiteManager.php:153
PHP  13. PHPUnit_Framework_TestSuite->run() phar:///usr/local/bin/codecept/src/Codeception/PHPUnit/Runner.php:89
PHP  14. PHPUnit_Framework_TestCase->run() phar:///usr/local/bin/codecept/vendor/phpunit/phpunit/src/Framework/TestSuite.php:747
PHP  15. PHPUnit_Framework_TestResult->run() phar:///usr/local/bin/codecept/vendor/phpunit/phpunit/src/Framework/TestCase.php:724



FATAL ERROR. TESTS NOT FINISHED.
Undefined class constant 'UNKNOWN'

I have no idea how to make this runs. Any suggestions?


Solution

  • It looks like a usual version conflict between Codeception phar file and libraries installed by Composer.

    Codeception file is bundled with PHPUnit 4.8.23, but you have PHPUnit <4.7.0 installed in vendor directory and autoloader managed to load PHPUnit_Util_Test class from vendor directory.

    Uninstall PHPUnit from vendor or install Codeception with Composer instead.

    Link to relevant change in PHPUnit: https://github.com/sebastianbergmann/phpunit/commit/32feefd37c820d122acac70fff0ee25cf0764612#diff-d2b0b699e9f0cfd6bd35cb3338167223R37