Comments (3)
In the WPLoader module configuration set the backupGlobals, backupStaticAttributes to false; default value is true
This worked great, thanks.
from wp-browser.
Hi @BrianHenryIE,
the issue arises from the fact that, in v4, I've modified the WPTestCase::$backupGlobals
to true
; it was false
in v3.
In your test cases, an immediate fix for the issue would be to explicitly override the WPTestCase::$backupGlobals
property and set it to false
.
I've set up a curated list of known offenders in the WPTestCase
code, but cannot possibly cover it all.
Why change the $backupGlobals
and $backupStaticAttributes
properties of the WPTestCase
from false
(v3) to true
(v4)? While the WPTestCase
cleanup of global variables covers some, it will mainly cover the ones set and used by WordPress; globals and static properties frequently used to cache values will not be reset, leading to all kinds of difficult-to-track bugs and false results where tests are behaving differently depending on the run order.
Thinking about how to improve on this:
- Add
backupGlobals
andbackupStaticAttributes
configuration parameters to theWPLoader
configuration, defaulttrue
, to control the behavior of the respectiveWPTestCase
properties. - I like the sweeping cleanup done by the two properties and would like to be able to define what should not be serialized as part of the snapshot procedure PHPUnit uses to back up and restore the global state. I will add the
backupGlobalsExcludeList
andbackupStaticAttributesExcludeList
to the configuration of theWPLoader
module to add to the respective lists.
In this API, your problem could be solved in two ways:
- Disable backup of globals and static attributes:
config: lucatume\WPBrowser\Module\WPLoader: backupGlobals: false backupStaticAttributes: false
- Selectively exclude the problematic class:
config: lucatume\WPBrowser\Module\WPLoader: backupStaticAttributesExcludeList: WC_Payment_Gateways: ['instance']
This API should provide a flexible approach to handle issues like this one.
from wp-browser.
I've followed up, in version 4.0.12
on this, to recap the possible approaches to solve the issue:
- In the test case override the
backupStaticAttributes
orbackupGlobals
properties setting them tofalse
; this could already be done in previous versions. - In the
WPLoader
module configuration set thebackupGlobals
,backupStaticAttributes
tofalse
; default value istrue
. - In the
WPLoader
module configuration set thebackupGlobalsExcludeList
andbackupStaticAttributesExcludeList
to add entries to the list of ignored globals and static attributes.
from wp-browser.
Related Issues (20)
- [BUG] Git Hub Pages are Down? HOT 1
- [BUG] "Could not find a WordPress installation" error when initialising a plugin HOT 1
- [BUG] `amEditingUserWithId()` method missing from v4 HOT 1
- [BUG] Ajax tests fail HOT 2
- [BUG] Tests fail when being run from phpstorm HOT 3
- https://wpbrowser.wptestkit.dev/ not working HOT 1
- [FEATURE REQUEST] Add (grab|see)TransientInDatabase methods to WPDb
- [BUG] v4 doesn't like database names with periods in them HOT 1
- [DOC REQUEST] Test examples HOT 4
- [BUG] Can't access WP built-in functions even when using WPLoader HOT 14
- [BUG] Empty < Invalid database name: > when trying to add WPLoader HOT 2
- [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
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.