|
50 | 50 | require_once __DIR__ . '/class-mockobject-autoload.php';
|
51 | 51 | spl_autoload_register( 'MockObject_Autoload::load', true, true );
|
52 | 52 |
|
| 53 | +// Check that the PHPUnit Polyfills autoloader exists. |
| 54 | +$phpunit_polyfills_autoloader = __DIR__ . '/../../../vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php'; |
| 55 | +if ( ! file_exists( $phpunit_polyfills_autoloader ) ) { |
| 56 | + echo "Error: You need to run `composer update` before running the tests.\n"; |
| 57 | + echo "You can still use a PHPUnit phar to run them, but the dependencies do need to be installed.\n"; |
| 58 | + exit( 1 ); |
| 59 | +} |
| 60 | + |
53 | 61 | // If running core tests, check if all the required PHP extensions are loaded before running the test suite.
|
54 | 62 | if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS ) {
|
55 | 63 | $required_extensions = array(
|
@@ -195,13 +203,12 @@ function wp_tests_options( $value ) {
|
195 | 203 | require __DIR__ . '/phpunit6/compat.php';
|
196 | 204 | }
|
197 | 205 |
|
198 |
| -// Load separate WP_UnitTestCase classes for PHPUnit 7.5+ and older versions. |
199 |
| -if ( version_compare( tests_get_phpunit_version(), '7.5', '>=' ) ) { |
200 |
| - require __DIR__ . '/phpunit7/testcase.php'; |
201 |
| -} else { |
202 |
| - require __DIR__ . '/testcase.php'; |
203 |
| -} |
| 206 | +// Load the PHPUnit Polyfills autoloader (check for existence of the file is done earlier in the script). |
| 207 | +require_once $phpunit_polyfills_autoloader; |
| 208 | +unset( $phpunit_polyfills_autoloader ); |
204 | 209 |
|
| 210 | +require __DIR__ . '/abstract-testcase.php'; |
| 211 | +require __DIR__ . '/testcase.php'; |
205 | 212 | require __DIR__ . '/testcase-rest-api.php';
|
206 | 213 | require __DIR__ . '/testcase-rest-controller.php';
|
207 | 214 | require __DIR__ . '/testcase-rest-post-type-controller.php';
|
|
0 commit comments