-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add standalone PHPUnit configs in plugins/
#1013
Conversation
plugins/
f897b31
to
1f5b39e
Compare
These tests are specifically to test image editors with GD extension loaded. performance/plugins/dominant-color-images/tests/dominant-color-image-editor-gd-test.php Lines 48 to 60 in 5583bcd
But if both Imagick and GD extensions are loaded, it's not guaranteed which editor will take effect since we are loading both performance/plugins/dominant-color-images/helper.php Lines 27 to 28 in 5583bcd
If any of the editor satisfies the implementation conditions, it will not check for others as per https://github.com/WordPress/wordpress-develop/blob/aea8a21c118cf268128693dc8b6e5016c4314f7b/src/wp-includes/media.php#L4159 In wp-env setup, it seems like Imagick extension not supporting |
Seems like the Imagick extension in wp-env is not working properly. It's not loading any formats, while the new WP Tests setup is loading them properly. So it seems like we have some flakiness in tests due to this which are failing in a properly working environment. PHP Info wp-env: Imagick extension
PHP Info wp-tests CI: Imagick extension
|
7ee3299
to
f658608
Compare
ceea704
to
f1b17f0
Compare
ad549e0
to
f1b17f0
Compare
// Determine correct location for plugins directory to use. | ||
if ( false !== getenv( 'WP_PLUGIN_DIR' ) ) { | ||
define( 'WP_PLUGIN_DIR', getenv( 'WP_PLUGIN_DIR' ) ); | ||
} else { | ||
define( 'WP_PLUGIN_DIR', dirname( TESTS_PLUGIN_DIR ) ); | ||
} | ||
|
||
// Load Composer dependencies if applicable. | ||
if ( file_exists( TESTS_PLUGIN_ROOT . '/vendor/autoload.php' ) ) { | ||
require_once TESTS_PLUGIN_ROOT . '/vendor/autoload.php'; | ||
} | ||
|
||
// Detect where to load the WordPress tests environment from. | ||
$_tests_dir = WPP_Tests_Helpers::get_path_to_wp_test_dir(); | ||
require_once $_tests_dir . '/includes/functions.php'; | ||
|
||
// Force plugin to be active. | ||
$GLOBALS['wp_tests_options'] = array( | ||
'active_plugins' => array( basename( TESTS_PLUGIN_DIR ) . '/load.php' ), | ||
); | ||
|
||
// Start up the WP testing environment. | ||
require $_tests_dir . '/includes/bootstrap.php'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code would be shared across all standalone plugins' bootstrap files, correct? I think this would make sense to put up in some common shared tests dir:
// Determine correct location for plugins directory to use. | |
if ( false !== getenv( 'WP_PLUGIN_DIR' ) ) { | |
define( 'WP_PLUGIN_DIR', getenv( 'WP_PLUGIN_DIR' ) ); | |
} else { | |
define( 'WP_PLUGIN_DIR', dirname( TESTS_PLUGIN_DIR ) ); | |
} | |
// Load Composer dependencies if applicable. | |
if ( file_exists( TESTS_PLUGIN_ROOT . '/vendor/autoload.php' ) ) { | |
require_once TESTS_PLUGIN_ROOT . '/vendor/autoload.php'; | |
} | |
// Detect where to load the WordPress tests environment from. | |
$_tests_dir = WPP_Tests_Helpers::get_path_to_wp_test_dir(); | |
require_once $_tests_dir . '/includes/functions.php'; | |
// Force plugin to be active. | |
$GLOBALS['wp_tests_options'] = array( | |
'active_plugins' => array( basename( TESTS_PLUGIN_DIR ) . '/load.php' ), | |
); | |
// Start up the WP testing environment. | |
require $_tests_dir . '/includes/bootstrap.php'; | |
require TESTS_PLUGIN_ROOT . '/tests/standalone-bootstrap.php'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@westonruter I think we should keep the configurable part in the plugin-specific bootstrap file. In the case of some plugin, we need to add some test filter before WP tests bootstrap, then we again need to make changes to this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We may need to. But if we don't now, maybe err on the side of reducing duplication until we need to?
// Determine correct location for plugins directory to use. | ||
if ( false !== getenv( 'WP_PLUGIN_DIR' ) ) { | ||
define( 'WP_PLUGIN_DIR', getenv( 'WP_PLUGIN_DIR' ) ); | ||
} else { | ||
define( 'WP_PLUGIN_DIR', dirname( TESTS_PLUGIN_DIR ) ); | ||
} | ||
|
||
// Load Composer dependencies if applicable. | ||
if ( file_exists( TESTS_PLUGIN_ROOT . '/vendor/autoload.php' ) ) { | ||
require_once TESTS_PLUGIN_ROOT . '/vendor/autoload.php'; | ||
} | ||
|
||
// Detect where to load the WordPress tests environment from. | ||
$_tests_dir = WPP_Tests_Helpers::get_path_to_wp_test_dir(); | ||
require_once $_tests_dir . '/includes/functions.php'; | ||
|
||
// Force plugin to be active. | ||
$GLOBALS['wp_tests_options'] = array( | ||
'active_plugins' => array( basename( TESTS_PLUGIN_DIR ) . '/load.php' ), | ||
); | ||
|
||
// Start up the WP testing environment. | ||
require $_tests_dir . '/includes/bootstrap.php'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment below for plugins/webp-uploads/tests/bootstrap.php
// Determine correct location for plugins directory to use. | ||
if ( false !== getenv( 'WP_PLUGIN_DIR' ) ) { | ||
define( 'WP_PLUGIN_DIR', getenv( 'WP_PLUGIN_DIR' ) ); | ||
} else { | ||
define( 'WP_PLUGIN_DIR', dirname( TESTS_PLUGIN_DIR ) ); | ||
} | ||
|
||
// Load Composer dependencies if applicable. | ||
if ( file_exists( TESTS_PLUGIN_ROOT . '/vendor/autoload.php' ) ) { | ||
require_once TESTS_PLUGIN_ROOT . '/vendor/autoload.php'; | ||
} | ||
|
||
// Detect where to load the WordPress tests environment from. | ||
$_tests_dir = WPP_Tests_Helpers::get_path_to_wp_test_dir(); | ||
require_once $_tests_dir . '/includes/functions.php'; | ||
|
||
// Force plugin to be active. | ||
$GLOBALS['wp_tests_options'] = array( | ||
'active_plugins' => array( basename( TESTS_PLUGIN_DIR ) . '/auto-sizes.php' ), | ||
); | ||
|
||
// Start up the WP testing environment. | ||
require $_tests_dir . '/includes/bootstrap.php'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment below for plugins/webp-uploads/tests/bootstrap.php
8a89eda
to
9e9c47c
Compare
cd6f237
to
6c0b435
Compare
de77320
to
7bd5f3f
Compare
…site before class setup
0e06f87
to
ffb640a
Compare
This PR has huge code changes and has changed its base branch multiple times. Hence I am closing this and will open a new PR with its changes. |
Summary
Fixes task 2 of #1012
Relevant technical choices
phpunit.xml.dist
to standalone plugins.Checklist
[Focus]
orInfrastructure
label.[Type]
label.no milestone
label.