Fix compatibility with PHPUnit 11#4313
Conversation
- Adds static data providers for Twig\Test\IntegrationTestCase. Running PHPUnit 10+ will require Twig\Test\IntegrationTestCase::getFixturesDirectory() to be implemented. - Removes the Twig\Test\NodeTestCase::getTests() data provider from the DataProvider attribute. This way it doesn't get called with PHPUnit 10+ causing the tests to fail. Signed-off-by: Maurício Meneghini Fauth <mauricio@mfauth.net>
|
No go for this feature as it does not make tests compatible with PHPUnit 10+ if projects have not been migrated yet away from the deprecated APIs, which goes against the way deprecations should work. If you read the discussion on #4266, you will see that support for newer PHPUnit versions in the IntegrationTestCase will be part of Twig 4.0 |
|
@stof Would it be acceptable if tests are skipped if the method has not been implemented yet and is running PHPUnit 10+? |
Or skipped only for PHPUnit 11 if the method is not implemented, however that will require adding a new test method that only runs on PHPUnit 11 (no impact to the user). |
|
The issue is not the test method. It is the fact that the old methods used inside the data provider were not static, so we cannot implement a static data provider that is compatible with projects that haven't migrated. Having a changelog entry saying |
|
@stof I opened a new pull request as I couldn't push to this one anymore. |
|
@MauricioFauth but even if you trigger a deprecation, this is not properly backward compatible as it does not run the expected tests (while running those tests is the expected behavior of the IntegrationTestCase) |
|
@stof I understand, but I don't think this is a BC break, because the expected tests don't run already. It's not like they are perfectly running before and now they don't, which is a BC break. So instead of causing errors and failing the test suite, these tests are now skipped and a deprecation is triggered, if the method is not implemented. |
|
@MauricioFauth the current state of Twig is "supports PHPUnit 10 and lower for IntegrationTestCase", not "supports PHPUnit 11 without running test" |
When
PHPUnit\Framework\Attributes\DataProviderattribute is found, PHPUnit ignores the@dataProviderannotation. This behavior can be used to fix compatibility with PHPUnit 11.Twig\Test\IntegrationTestCase. Running PHPUnit 10+ will requireTwig\Test\IntegrationTestCase::getFixturesDirectory()to be implemented.Twig\Test\NodeTestCase::getTests()data provider from theDataProviderattribute. This way it doesn't get called with PHPUnit 10+ causing the tests to fail.Related to: