首页 > 解决方案 > Which version of PHPUnit is suitable to test code PHP version 5.5.9?

问题描述

I have to test php code version 5.5.9 with PHPUnit. Which version is suitable for this purpose?

I'm using PHPUnit 4.8, that require PHP 5.3, and get the following error for a test:

PHP Parse error:  syntax error, unexpected 'function' (T_FUNCTION), expecting identifier (T_STRING) or \\ (T_NS_SEPARATOR)

PHP Stack trace:
PHP   1. {main}() /home/foo/.phpstorm_helpers/phpunit.php:0
PHP   2. IDE_Base_PHPUnit_TextUI_Command::main($exit = *uninitialized*)

According to this Q/A PHPUnit 3.6 PHP 5.2.7 PHP Parse error: syntax error, unexpected T_FUNCTION, expecting ')' in /usr/local/bin/phpunit on line 16 PHPUnit version cause the error.

I read here https://phpunit.de/manual/5.0/en/installation.html that PHPUnit version 5.0 require PHP 5.6 (so not a good choice for my case).

Which version of PHPUnit should I install to avoid this error?

UPDATE: the error does not arise since I added this line in composer.json :

"require-dev": {
    "phpunit/phpunit": "^4"
}

Thank you

标签: phpphpunit

解决方案


You can find the information you are looking for here.


推荐阅读