Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--migrate-configuration does not remove beStrictAboutTodoAnnotatedTests attribute from XML configuration file #6087

Closed
janedbal opened this issue Dec 17, 2024 · 1 comment
Assignees
Labels
feature/configuration/xml feature/test-runner CLI test runner type/bug Something is broken version/10 Something affects PHPUnit 10 version/11 Something affects PHPUnit 11

Comments

@janedbal
Copy link
Contributor

janedbal commented Dec 17, 2024

Q A
PHPUnit version 11.4.3
PHP version 8.3.14
Installation Method Composer

Summary

Given following phpunit.xml:

<?xml version="1.0" encoding="UTF-8"?>
<phpunit
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.4/phpunit.xsd"
    beStrictAboutTodoAnnotatedTests="true"
    displayDetailsOnPhpunitDeprecations="true">
</phpunit>

And running vendor/bin/phpunit -c phpunit.xml, I get:

There was 1 PHPUnit test runner deprecation:

1) Your XML configuration validates against a deprecated schema. Migrate your XML configuration using "--migrate-configuration"!

But when I run the migration via vendor/bin/phpunit -c phpunit.xml --migrate-configuration, the error persists and config is still invalid:

So I used some XSD validator to determine that the beStrictAboutTodoAnnotatedTests must not be present (the real config XML was huge).

Current behavior

As above

How to reproduce

As above

Expected behavior

--migrate-configuration should fix XSD issues. Any decent XSD validator gives me better insight what is wrong, but PHPUnit just guides me to autofix which does not work.

@sebastianbergmann
Copy link
Owner

I can reproduce the issue:

❯ mkdir issue-6087
❯ cd issue-6087
❯ composer require --dev phpunit/phpunit:11.4.3
❯ ./vendor/bin/phpunit --version
PHPUnit 11.4.3 by Sebastian Bergmann and contributors.
❯ cat phpunit.xml
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
         cacheDirectory=".phpunit.cache"
         beStrictAboutTodoAnnotatedTests="true"
>
    <testsuites>
        <testsuite name="default">
            <directory>tests</directory>
        </testsuite>
    </testsuites>
</phpunit>
❯ ./vendor/bin/phpunit --version
❯ ./vendor/bin/phpunit --display-phpunit-deprecations
PHPUnit 11.4.3 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.4.2
Configuration: /home/sb/issue-6087/phpunit.xml

.                                                                   1 / 1 (100%)

Time: 00:00.003, Memory: 8.00 MB

There was 1 PHPUnit test runner deprecation:

1) Your XML configuration validates against a deprecated schema. Migrate your XML configuration using "--migrate-configuration"!

OK, but there were issues!
Tests: 1, Assertions: 1, PHPUnit Deprecations: 1.

The beStrictAboutTodoAnnotatedTests attribute is unexpected according to the schema definition for the XML configuration file for PHPUnit 11.4.3.

❯ ./vendor/bin/phpunit --migrate-configuration
PHPUnit 11.4.3 by Sebastian Bergmann and contributors.

Created backup:         /home/sb/issue-6087/phpunit.xml.bak
Migrated configuration: /home/sb/issue-6087/phpunit.xml
❯ ./vendor/bin/phpunit --display-phpunit-deprecations
PHPUnit 11.4.3 by Sebastian Bergmann and contributors.

Runtime:       PHP 8.4.2
Configuration: /home/sb/issue-6087/phpunit.xml

.                                                                   1 / 1 (100%)

Time: 00:00.003, Memory: 8.00 MB

There was 1 PHPUnit test runner deprecation:

1) Your XML configuration validates against a deprecated schema. Migrate your XML configuration using "--migrate-configuration"!

OK, but there were issues!
Tests: 1, Assertions: 1, PHPUnit Deprecations: 1.

@sebastianbergmann sebastianbergmann changed the title PHPUnit fails to fix XSD issue via --migrate-configuration --migrate-configuration does not remove beStrictAboutTodoAnnotatedTests attribute from XML configuration file Dec 20, 2024
@sebastianbergmann sebastianbergmann added version/11 Something affects PHPUnit 11 version/10 Something affects PHPUnit 10 labels Dec 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature/configuration/xml feature/test-runner CLI test runner type/bug Something is broken version/10 Something affects PHPUnit 10 version/11 Something affects PHPUnit 11
Projects
None yet
Development

No branches or pull requests

2 participants