Skip to content

Conversation

@jrfnl
Copy link
Collaborator

@jrfnl jrfnl commented Apr 1, 2023

PHPUnit 10.0.0 introduces the new Assert::assertStringEqualsStringIgnoringLineEndings() and Assert::assertStringContainsStringIgnoringLineEndings() methods.

This commit:

  • Adds two traits with the same name. One to polyfill the methods when not available in PHPUnit. The other - an empty trait - to allow for use-ing the trait in PHPUnit versions in which the methods are already natively available.
  • Logic to the custom autoloader which will load the correct trait depending on the PHPUnit version used.
  • An availability test and limited functional test for the functionality polyfilled.

Note: the function name for the private normalizeLineEndings() method is a little convoluted - normalizeLineEndingsForIgnoringLineEndingsAssertions(). This is intentional to prevent potential naming collisions with pre-existing end-user defined methods for the same, which may exist in other traits used in tests, which would be hard to solve due to the method only existing in the non-empty trait.

Includes:

  • Adding the new polyfill to the existing TestCases classes.

Refs:

…sertStringEqualsStringIgnoringLineEndings() et al methods

PHPUnit 10.0.0 introduces the new `Assert::assertStringEqualsStringIgnoringLineEndings()` and `Assert::assertStringContainsStringIgnoringLineEndings()` methods.

This commit:
* Adds two traits with the same name.
    One to polyfill the methods when not available in PHPUnit.
    The other - an empty trait - to allow for `use`-ing the trait in PHPUnit versions in which the methods are already natively available.
* Logic to the custom autoloader which will load the correct trait depending on the PHPUnit version used.
* An availability test and limited functional test for the functionality polyfilled.

Note: the function name for the `private` `normalizeLineEndings()` method is a little convoluted - `normalizeLineEndingsForIgnoringLineEndingsAssertions()`.
This is intentional to prevent potential naming collisions with pre-existing end-user defined methods for the same, which may exist in other traits used in tests, which would be hard to solve due to the method only existing in the non-empty trait.

Includes:
* Adding the new polyfill to the existing `TestCases` classes.

Refs:
* sebastianbergmann/phpunit#4641
* sebastianbergmann/phpunit#4670 (and follow up commits)
* sebastianbergmann/phpunit#5279

Co-authored-by: Sergei Predvoditelev <sergey.predvoditelev@gmail.com>
Co-authored-by: Sebastian Bergmann <sb@sebastian-bergmann.de>
@jrfnl jrfnl added this to the 2.0.0 milestone Apr 1, 2023
@jrfnl jrfnl merged commit 53764b3 into 2.x Apr 1, 2023
@jrfnl jrfnl deleted the feature/phpunit-10-add-assertignoringlineendingstrait branch April 1, 2023 13:19
@jrfnl jrfnl mentioned this pull request Apr 1, 2023
11 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant