为什么 PHPUnit 9 不期望 logging phpunit.xml.dist 的 log 子元素

Why Doesn't PHPUnit 9 expect the log child element of logging phpunit.xml.dist

我目前正在努力将旧的 PHP 应用程序(超过 10 年)过渡到 PHP 7.4,我们目前正在 PHP 7.4 分支上实施持续集成的应用程序。我们决定ci决定使用 PHP 当前稳定版本支持的 PHPUnit 版本。因此,我们将 PHP 7.4 分支的 ci 测试作业升级到 PHPUnit 9.3。

我们根据文档进行了所有必要的更改,但是我们被一个警告阻止了,我们不知道如何修复(假设测试已执行并且报告已在正确的位置发布) 警告 - 配置文件未通过验证!

  The following problems have been detected:

  Line 38:
  - Element 'log': This element is not expected..

我在下面分享我们的 PHP 单元配置和我们用来启动它的命令,有人能发现它有什么问题吗?

phpunit -c phpunit.xml.dist


<?xml version="1.0" encoding="UTF-8"?>
<phpunit
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/9.3/phpunit.xsd"
         colors                      = "true"
         bootstrap                   = "tests/bootstrap.php"
         >

    <testsuites>
        <testsuite name="Unit Tests">
            <directory>tests/</directory>
        </testsuite>
    </testsuites>
    <coverage>
        <include>
            <directory suffix=".php">api</directory>
        </include>
    </coverage>
    <logging>
        <log type="junit" target="build/unit_report.xml"/>
    </logging>
</phpunit>

<log> 元素在 PHPUnit 9.3 中也有 changed

你需要改变

<logging>
  <log type="junit" target="build/unit_report.xml"/>
</logging>

<logging>
  <junit outputFile="build/unit_report.xml"/>
</logging>

也就是说,我强烈建议使用 PHPUnit 的 --migrate-configuration CLI 选项自动将您的配置文件转换为新格式。