gpt4 book ai didi

PHPUnit - 我可以为较低版本的 PHP 运行测试吗?

转载 作者:可可西里 更新时间:2023-11-01 01:15:35 24 4
gpt4 key购买 nike

如解释here我可以测试 PHP 版本是否至少为 5.3.0。

但是如果我想为低于 5.3.0 的 PHP 版本运行测试呢?

我这样写:

<file phpVersion="5.3.0" phpVersionOperator="<=">./tests/unit/test-file.php</file>

但是我收到这个错误

Unescaped '<' not allowed in attributes values

我该怎么做?

最佳答案

根据 version_compare 的文档功能:

The possible operators are: <, lt, <=, le, >, gt, >=, ge, ==, =, eq, !=, <>, ne respectively.

在phpunit核心中使用here ,您可以简单地将 lt 指定为值。例如:

<file phpVersion="5.3.0" phpVersionOperator="lt">./tests/unit/test-file.php</file>

希望对你有帮助

注意:

如果文件也包含在测试套件的另一个指令中,它将被执行,例如在这种情况下:

<testsuite name="Project Test Suite">
<directory>tests</directory> <!-- This line execute the test -->
<file phpVersion="5.3.0" phpVersionOperator="<=">./tests/unit/test-file.php</file>
</testsuite>

因此在测试套件定义中要有选择性。

关于PHPUnit - 我可以为较低版本的 PHP 运行测试吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39893435/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com