Opened 7 months ago
Closed 7 months ago
#63833 closed feature request (fixed)
PHPUnit classes don't exist in later versions of PHPUnit
| Reported by: |
|
Owned by: |
|
|---|---|---|---|
| Milestone: | 6.9 | Priority: | normal |
| Severity: | normal | Version: | 6.9 |
| Component: | Build/Test Tools | Keywords: | has-patch has-unit-tests |
| Focuses: | tests | Cc: |
Description
Trying to run the PHPUnit test suite produces warnings when running the tests in PHPUnit 10 or above.
[15-Aug-2025 20:58:56 UTC] PHP Warning: Class "PHPUnit\Framework\Error\Deprecated" not found in /wordpress-phpunit/includes/phpunit6/compat.php on line 8 [15-Aug-2025 20:58:56 UTC] PHP Warning: Class "PHPUnit\Framework\Error\Notice" not found in /wordpress-phpunit/includes/phpunit6/compat.php on line 9 [15-Aug-2025 20:58:56 UTC] PHP Warning: Class "PHPUnit\Framework\Error\Warning" not found in /wordpress-phpunit/includes/phpunit6/compat.php on line 10 [15-Aug-2025 20:58:56 UTC] PHP Warning: Class "PHPUnit\Framework\Warning" not found in /wordpress-phpunit/includes/phpunit6/compat.php on line 12 [15-Aug-2025 20:58:56 UTC] PHP Warning: Class "PHPUnit\Framework\TestListener" not found in /wordpress-phpunit/includes/phpunit6/compat.php on line 15
I think instead of blindly calling class_alias() on each of these, it would be better to wrap each in a call to class_exists(). This could easily be done in a foreach loop.
Change History (3)
This ticket was mentioned in PR #9520 on WordPress/wordpress-develop by @devasheeshkaul.
7 months ago
#1
- Keywords has-patch has-unit-tests added
Note: See
TracTickets for help on using
tickets.
This PR resolves the warning triggered when running the PHPUnit test suite with PHPUnit 10 or higher. Instead of directly using
class_alias, it first check whether the class exist or not. This ensures that the alias is only created when the class is available.Trac ticket: https://core.trac.wordpress.org/ticket/63833