Comments (4)
Hooking at muplugins_loaded
is a fairly common practice and one honoring WordPress real loading sequence. To point out some authoritative test code: posts-to-posts bootstrap file.
Furthermore the standard WordPress component loading flow loads plugins right after mu-plugins as can be seen in the wp-settings.php file.
Delaying that call would mean creating artificial conditions for the plugin existing in the test environment only.
There is, though, something happening between the muplugins_loaded
and the plugins_loaded
hook and it might be worth exploring the possibility to have the plugins loaded in a similar fashion
tests_add_filter( 'plugins_loaded', [ $this, `activatePlugins` ], PHP_INT_MIN );
aka "very very early in the hook".
from wp-browser.
Just to clarify, my suggestion wasn't to change when plugins are loaded - it was to change the hook on which they are activated.
I'd also agree wp
may not be the best action either (though it works) - wp_loaded
is probably better. Here's my take on the expected sequence of events when a plugin is activated:
wp-load.php
bootstraps WordPresswp-config.php
is included bywp-load.php
wp-settings.php
is included bywp-config.php
muplugins_loaded
firesplugins_loaded
fires- Various key objects are now instantiated (including the
$wp_rewrite
global) wp_loaded
fires (at this point, we're right at the end ofwp-settings.php
)
- The next thing we are interested in is the call to
activate_plugin(...)
which is responsible for firing theactivate_{plugin}
hook
So it's not unreasonable for a plugin to want to interact with things like $wp_rewrite
when the activation hook runs - directly or indirectly (ie, by registering a post type). All I'm really saying is, yep let's load the plugins as we're currently doing (or on plugins_loaded
) - but activation ought to move forward, as it would if we weren't in a test environment.
Does that make more sense?
from wp-browser.
It makes total sense and I think you are right.
I'm looking into it and will address this shortly, thanks for pointing it out.
from wp-browser.
I've updated the code to move the plugin activation to the wp_install
hook. This should take care of the plugin activation issue and give activating plugins the environment those need.
from wp-browser.
Related Issues (20)
- [BUG] Empty < Invalid database name: > when trying to add WPLoader HOT 2
- [BUG] v4 uses `__wakeup`, which many plugins have overridden with an error. HOT 3
- [BUG] WPLoader doesn't load wordpress installation HOT 12
- [DOC REQUEST] Setup issues HOT 4
- [BUG] Warnings while running tests HOT 1
- [SETUP ISSUE] failed activation, invalid Chrome binary HOT 4
- [FEATURE REQUEST] Integrate with ACF HOT 3
- [SETUP ISSUE] Teardown error — $wpdb is null HOT 5
- [FEATURE REQUEST] Lock WordPress to Specific Version HOT 4
- [BUG] race conditions & bugs due to connecting twice to database with WPTestCase and WPLoader | v3 HOT 13
- [Feature Request] - Question about dump option in WPLoader HOT 4
- Support for PHPUnit 10/11 and WebDriver 4 HOT 8
- [SETUP ISSUE] Running tests with wp-env HOT 8
- [DOC BUG] _boostrap.php documentation not up to date HOT 1
- [SETUP ISSUE] `composer require --dev lucatume/wp-browser` fails due to tdd-helpers 404 HOT 3
- Nano HOT 1
- [BUG] WordPress not loaded with WPLoader loadOnly: true HOT 5
- [FEATURE REQUEST] `Scaffolded::getContentDir()` should respect `WP_CONTENT_DIR` constant HOT 3
- [FEATURE REQUEST] Remove attachment files after tests HOT 1
- [BUG] fatal error with WPLoader on 4.3.0, LoadSandbox tries to use DB from wp-config, not test config HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wp-browser.