-
Notifications
You must be signed in to change notification settings - Fork 206
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #949 from Automattic/improve/phpunit-setup
- Loading branch information
Showing
16 changed files
with
351 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
/node_modules/ | ||
/vendor/ | ||
/.phpcs.xml | ||
/.phpunit.result.cache | ||
/composer.lock | ||
/phpcs.xml | ||
/phpunit.xml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,57 @@ | ||
<?php | ||
/** | ||
* PHPUnit bootstrap file. | ||
* | ||
* @package Automattic\LegacyRedirector | ||
*/ | ||
|
||
use Yoast\WPTestUtils\WPIntegration; | ||
|
||
require_once dirname( dirname( __FILE__ ) ) . '/vendor/yoast/wp-test-utils/src/WPIntegration/bootstrap-functions.php'; | ||
|
||
$_tests_dir = getenv( 'WP_TESTS_DIR' ); | ||
|
||
if ( ! $_tests_dir ) { | ||
$_tests_dir = '/tmp/wordpress-tests-lib'; | ||
$_tests_dir = rtrim( sys_get_temp_dir(), '/\\' ) . '/wordpress-tests-lib'; | ||
} | ||
|
||
// Load the composer autoloader. | ||
require_once __DIR__ . '/../vendor/autoload.php'; | ||
// Forward custom PHPUnit Polyfills configuration to PHPUnit bootstrap file. | ||
$_phpunit_polyfills_path = getenv( 'WP_TESTS_PHPUNIT_POLYFILLS_PATH' ); | ||
if ( false !== $_phpunit_polyfills_path ) { | ||
define( 'WP_TESTS_PHPUNIT_POLYFILLS_PATH', $_phpunit_polyfills_path ); | ||
} | ||
|
||
require_once $_tests_dir . '/includes/functions.php'; | ||
if ( ! file_exists( "{$_tests_dir}/includes/functions.php" ) ) { | ||
echo "Could not find {$_tests_dir}/includes/functions.php, have you run bin/install-wp-tests.sh ?" . PHP_EOL; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped | ||
exit( 1 ); | ||
} | ||
|
||
// Give access to tests_add_filter() function. | ||
require_once "{$_tests_dir}/includes/functions.php"; | ||
|
||
/** | ||
* Manually load the plugin being tested. | ||
*/ | ||
function _manually_load_plugin() { | ||
require dirname( __FILE__ ) . '/../co-authors-plus.php'; | ||
// Updated from default (__FILE__), since this bootstrap is an extra level down in tests/Integration/. | ||
require dirname( dirname( __FILE__ ) ) . '/co-authors-plus.php'; | ||
} | ||
|
||
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' ); | ||
|
||
require $_tests_dir . '/includes/bootstrap.php'; | ||
// Make sure the Composer autoload file has been generated. | ||
WPIntegration\check_composer_autoload_exists(); | ||
|
||
// Start up the WP testing environment. | ||
require "{$_tests_dir}/includes/bootstrap.php"; | ||
|
||
/* | ||
* Register the custom autoloader to overload the PHPUnit MockObject classes when running on PHP 8. | ||
* | ||
* This function has to be called _last_, after the WP test bootstrap to make sure it registers | ||
* itself in FRONT of the Composer autoload (which also prepends itself to the autoload queue). | ||
*/ | ||
WPIntegration\register_mockobject_autoloader(); | ||
|
||
require dirname( __FILE__ ) . '/coauthorsplus-testcase.php'; | ||
// Add custom test case. | ||
require __DIR__ . '/coauthorsplus-testcase.php'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.