-
Notifications
You must be signed in to change notification settings - Fork 72
Description
Feature request
Currently, in my bootstrap.php I typically use WP_Mock::activateStrictMode().
I would like to disable strict mode for some tests, in particular where I use WP_Mock::expectActionAdded(). Often, a function that adds one action adds many, but I will only be interested in testing that one add_action() I've most recently added.
With strict mode on, other add_action/add_filter calls without their corresponding WP_Mock::expectActionAdded() result in:
Unexpected use of add_action for action init with callback BrianHenryIE\Example::init
Proposed solution
Add a public setter on WP_Mock::$__strict_mode() that can be used during individual tests, then in TestCase::setUp() reset strict mode to the configured/default value.
WP_Mock::activateStrictMode() only allows setting it before boostrap, and the documentation says it has to be enabled before bootstrap, but WP_Mock::strictMode() is only actually used in one, two places that don't read to me like it would matter.
The feature tests are already enabling/disabling it as desired in FeatureContext::forceStrictModeOn().