简体   繁体   English

哪个版本的PHPUnit适合测试PHP版本5.5.9?

[英]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. 我必须使用PHPUnit测试PHP代码5.5.9。 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 5.3的PHPUnit 4.8,并得到以下错误进行测试:

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. 根据此问题, PHPUnit 3.6 PHP 5.2.7 PHP解析错误:语法错误,意外的T_FUNCTION,并期望第16行 PHPUnit版本中/ usr / local / bin / phpunit中的')'导致该错误。

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). 我在这里https://phpunit.de/manual/5.0/en/installation.html读到,PHPUnit版本5.0需要PHP 5.6(因此,对于我的情况而言,不是一个很好的选择)。

Which version of PHPUnit should I install to avoid this error? 我应该安装哪个版本的PHPUnit以避免此错误?

UPDATE: the error does not arise since I added this line in composer.json : 更新:由于我在composer.json中添加了以下行,因此不会出现错误:

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

Thank you 谢谢

您可以在此处找到所需的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM