Skip to content

XML configuration migration does not migrate whitelist/file elements #5405

@anomiex

Description

@anomiex
Q A
PHPUnit version 10.2.1, 9.6.8
PHP version 8.2.5, 8.0.28
Installation Method Composer

Summary

Migration fails if the <whitelist> uses <file>.

Current behavior

$ vendor/bin/phpunit --migrate-configuration
PHPUnit 10.2.1 by Sebastian Bergmann and contributors.

Created backup:         /tmp/test/phpunit.xml.dist.bak
Migration failed: whitelist element has unexpected children
$ vendor/bin/phpunit --migrate-configuration
PHPUnit 9.6.8 by Sebastian Bergmann and contributors.

Created backup:         /tmp/test/phpunit.xml.dist.bak
Migration failed: whitelist element has unexpected children

How to reproduce

  1. Create a phpunit.xml.dist like this, which is valid in older versions of PHPUnit.
    <phpunit>
    
        <testsuites>
            <testsuite name="main">
                <directory suffix=".php">tests/php</directory>
            </testsuite>
        </testsuites>
    
        <filter>
            <whitelist>
                <file>./*.php</file>
                <directory suffix=".php">src</directory>
            </whitelist>
        </filter>
    
    </phpunit>
  2. Run vendor/bin/phpunit --migrate-configuration

Expected behavior

Migration succeeds, producing this valid PHPUnit 10.2.1 configuration.

<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd" cacheDirectory=".phpunit.cache">
  <coverage/>
  <testsuites>
    <testsuite name="main">
      <directory suffix=".php">tests/php</directory>
    </testsuite>
  </testsuites>
  <source>
    <include>
      <file>./*.php</file>
      <directory suffix=".php">src</directory>
    </include>
  </source>
</phpunit>

or this valid PHPUnit 9.6 configuration

<?xml version="1.0"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
  <coverage>
    <include>
      <file>./*.php</file>
      <directory suffix=".php">src</directory>
    </include>
  </coverage>
  <testsuites>
    <testsuite name="main">
      <directory suffix=".php">tests/php</directory>
    </testsuite>
  </testsuites>
</phpunit>

Metadata

Metadata

Labels

type/bugSomething is brokenversion/10Something affects PHPUnit 10version/9Something affects PHPUnit 9

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions