A set of polyfills for changed PHPUnit functionality to enable cross-version compatible PHP tests.
PHPUnit Polyfills is a library that provides polyfills for changed PHPUnit functionality, enabling developers to write PHPUnit tests that are compatible across multiple PHPUnit versions. It solves the problem of API changes between PHPUnit releases by allowing tests to use the latest assertions and methods while still running on older PHPUnit versions.
PHP developers and teams who maintain test suites that need to run across different PHPUnit versions, such as library maintainers, plugin developers, or projects with complex dependency matrices.
Developers choose PHPUnit Polyfills because it eliminates the need to constantly rewrite tests when upgrading PHPUnit, reduces maintenance overhead, and provides a smooth migration path by supporting forward compatibility with the latest PHPUnit features.
Set of polyfills for changed PHPUnit functionality to allow for creating PHPUnit cross-version compatible tests
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Enables writing tests for PHPUnit 12.x and running them on versions 7.5 to 12.x, allowing early adoption of new syntax without breaking older environments.
Provides individual traits for specific features like AssertContainsOnly or ExpectExceptionMessageMatches, making integration flexible and targeted.
Offers custom TestCase classes that manage signature mismatches in fixture methods like setUp and tearDown, simplifying cross-version test writing.
Supports PHPUnit 7.5 to 12.x with detailed compatibility tables, though excludes PHPUnit 10.x for certain polyfills in recent series.
The TestListener polyfill is not compatible with PHPUnit 10.x, 11.x, and 12.x, forcing users to stay on older polyfill versions or refactor, as admitted in the README.
Some polyfills, like assertIsClosedResource, are affected by bugs in PHP itself (e.g., in libxml), requiring workarounds and potentially skipping tests, adding complexity.
Using the library with PHPUnit Phar files or in CI/CD pipelines like GitHub Actions requires explicit autoloading steps, which can be error-prone for inexperienced users.