如何使用Symfony2为功能测试配置代码?

时间:2016-03-22 09:06:54

标签: php symfony phpunit codeception

我正在使用这个functional.suite.yml:

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

我构建并运行测试并得到:

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'

我不知道如何进行此次运行。有什么建议吗?

1 个答案:

答案 0 :(得分:2)

它看起来像Codeception phar文件和Composer安装的库之间的通常版本冲突。

Codeception文件与PHPUnit 4.8.23捆绑在一起,但您在供应商目录中安装了PHPUnit< 4.7.0,并且自动加载器设法从供应商目录加载PHPUnit_Util_Test类。

从供应商处卸载PHPUnit或使用Composer安装Codeception。

链接到PHPUnit中的相关更改: https://github.com/sebastianbergmann/phpunit/commit/32feefd37c820d122acac70fff0ee25cf0764612#diff-d2b0b699e9f0cfd6bd35cb3338167223R37