【问题标题】:Which version of PHPUnit is suitable to test code PHP version 5.5.9?哪个版本的PHPUnit适合测试PHP 5.5.9版本的代码?
【发布时间】:2019-09-06 19:24:12
【问题描述】:

我必须使用 PHPUnit 测试 php 代码版本 5.5.9。哪个版本适合这个目的?

我使用的是 PHPUnit 4.8,它需要 PHP 5.3,但测试时出现以下错误:

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*)

根据此 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 版本导致错误。

我在这里读到https://phpunit.de/manual/5.0/en/installation.html PHPUnit 5.0 版需要 PHP 5.6(所以对我来说不是一个好的选择)。

我应该安装哪个版本的 PHPUnit 来避免这个错误?

更新:由于我在 composer.json 中添加了这一行,因此不会出现错误:

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

谢谢

【问题讨论】:

  • 注意:“你到底为什么不在 php7 上工作”不是答案...谢谢

标签: php phpunit


【解决方案1】:

您可以找到您要查找的信息here

【讨论】:

    猜你喜欢
    • 2018-11-26
    • 1970-01-01
    • 2020-02-09
    • 1970-01-01
    • 2016-12-19
    • 1970-01-01
    • 2018-02-27
    • 2018-04-02
    • 2014-10-08
    相关资源
    最近更新 更多