Lines:
1 to 100 of 328
<?php if ( defined( 'WP_TESTS_CONFIG_FILE_PATH' ) ) { $config_file_path = WP_TESTS_CONFIG_FILE_PATH; } else { $config_file_path = dirname( __DIR__ ); if ( ! file_exists( $config_file_path . '/wp-tests-config.php' ) ) { // Support the config file from the root of the develop repository. if ( basename( $config_file_path ) === 'phpunit' && basename( dirname( $config_file_path ) ) === 'tests' ) { $config_file_path = dirname( dirname( $config_file_path ) ); } } $config_file_path .= '/wp-tests-config.php'; } /* * Globalize some WordPress variables, because PHPUnit loads this file inside a function. * See: https://github.com/sebastianbergmann/phpunit/issues/325 */ global $wpdb, $current_site, $current_blog, $wp_rewrite, $shortcode_tags, $wp, $phpmailer, $wp_theme_directories; if ( ! is_readable( $config_file_path ) ) { echo 'Error: wp-tests-config.php is missing! Please use wp-tests-config-sample.php to create a config file.' . PHP_EOL; exit( 1 ); } require_once $config_file_path; require_once __DIR__ . '/functions.php'; if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS && ! is_dir( ABSPATH ) ) { if ( substr( ABSPATH, -7 ) !== '/build/' ) { printf( 'Error: The ABSPATH constant in the `wp-tests-config.php` file is set to a non-existent path "%s". Please verify.' . PHP_EOL, ABSPATH ); exit( 1 ); } else { echo 'Error: The PHPUnit tests should be run on the /src/ directory, not the /build/ directory.' . ' Please update the ABSPATH constant in your `wp-tests-config.php` file to `dirname( __FILE__ ) . \'/src/\'`' . ' or run `npm run build` prior to running PHPUnit.' . PHP_EOL; exit( 1 ); } } $phpunit_version = tests_get_phpunit_version(); if ( version_compare( $phpunit_version, '5.7.21', '<' ) ) { printf( "Error: Looks like you're using PHPUnit %s. WordPress requires at least PHPUnit 5.7.21." . PHP_EOL, $phpunit_version ); echo 'Please use the latest PHPUnit version supported for the PHP version you are running the tests on.' . PHP_EOL; exit( 1 ); } /* * Load the PHPUnit Polyfills autoloader. * * The PHPUnit Polyfills are a requirement for the WP test suite. * * For running the Core tests, the Make WordPress Core handbook contains step-by-step instructions * on how to get up and running for a variety of supported workflows: * {@link https://make.wordpress.org/core/handbook/testing/automated-testing/phpunit/#test-running-workflow-options} * * Plugin/theme integration tests can handle this in any of the following ways: * - When using a full WP install: run `composer update -W` for the WP install prior to running the tests. * - When using a partial WP test suite install: * - Add a `yoast/phpunit-polyfills` (dev) requirement to the plugin/theme's own `composer.json` file. * - And then: * - Either load the PHPUnit Polyfills autoload file prior to running the WP core bootstrap file. * - Or declare a `WP_TESTS_PHPUNIT_POLYFILLS_PATH` constant containing the absolute path to the * root directory of the PHPUnit Polyfills installation. * If the constant is used, it is strongly recommended to declare this constant in the plugin/theme's * own test bootstrap file. * The constant MUST be declared prior to calling this file. */ if ( ! class_exists( 'Yoast\PHPUnitPolyfills\Autoload' ) ) { // Default location of the autoloader for WP core test runs. $phpunit_polyfills_autoloader = dirname( dirname( dirname( __DIR__ ) ) ) . '/vendor/yoast/phpunit-polyfills/phpunitpolyfills-autoload.php'; $phpunit_polyfills_error = false; // Allow for a custom installation location to be provided for plugin/theme integration tests. if ( defined( 'WP_TESTS_PHPUNIT_POLYFILLS_PATH' ) ) { $phpunit_polyfills_path = WP_TESTS_PHPUNIT_POLYFILLS_PATH; if ( is_string( WP_TESTS_PHPUNIT_POLYFILLS_PATH ) && '' !== WP_TESTS_PHPUNIT_POLYFILLS_PATH ) { // Be tolerant to the path being provided including the filename. if ( substr( $phpunit_polyfills_path, -29 ) !== 'phpunitpolyfills-autoload.php' ) { $phpunit_polyfills_path = rtrim( $phpunit_polyfills_path, '/\\' ); $phpunit_polyfills_path = $phpunit_polyfills_path . '/phpunitpolyfills-autoload.php'; } $phpunit_polyfills_autoloader = $phpunit_polyfills_path; } else { $phpunit_polyfills_error = true; } } if ( $phpunit_polyfills_error || ! file_exists( $phpunit_polyfills_autoloader ) ) {