I am working on transitioning a PHP application (more than 10 years old) to PHP 7.4, we are currently implementing a continuous integration on the PHP 7.4 branch of the application. We decided to use a version of PHPUnit that is supported by the PHP current stable release. So we upgraded the ci testing job of the PHP 7.4 branch to PHPUnit 9.3.
We made all necessary changes according to documentation, but we are blocked on one warning that we don’t know how to fix (granted the tests are executed and the report is published at the right place)
Warning - The configuration file did not pass validation!
The following problems have been detected:
Line 38:
- Element 'log': This element is not expected..
I am sharing our PHPUnit configuration below and the command we use to launch it, can anyone spot what is wrong with it?
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>
2
Answers
The
<log>
element has also changed in PHPUnit 9.3.You need to change
to
That being said, I would highly recommend to use PHPUnit´s
--migrate-configuration
CLI option to automatically your configuration file to the new format.Changed in PHPUnit 9.5.x
Try any from following
PHP Unit 9.5 Documentation – Logging