wp-self-test: hooks and filters
3 actions and 10 filters, read from the source of wp-self-test at v2.2.5. Each hook links to the line that fires it.
Browser layer
Example: mmwp_self_test_admin_menu_exclusions
add_filter( 'mmwp_self_test_admin_menu_exclusions', function ( $needles ) {
// Change $needles here.
return $needles;
} );
Filter
Since 2.1.0
Filter the substrings that keep an admin URL out of the browser crawl (matched case-insensitively). Return the defaults plus your own, or remove defaults you accept to crawl.
Parameters of mmwp_self_test_admin_menu_exclusions | Name | Type | Description |
$needles | string[] | Default: DEFAULT_EXCLUSIONS. |
Fired in src/Browser/Menu_Inventory.php#L125↗(opens in a new tab) (Menu_Inventory::exclusions()).
Filter
Since 2.1.0
Filter the command that starts the Node runner of the browser layer.
Parameters of mmwp_self_test_browser_command | Name | Type | Description |
$command | string[] | Default: `node <package>/e2e/bin/run.js`. |
$package | string | Directory of the installed e2e package. |
$definition | array | Case definition. |
Fired in src/Browser/Browser_Runner.php#L118↗(opens in a new tab) (Browser_Runner::plan()).
Gates and configuration
Example: mmwp_self_test_abilities_available
add_filter( 'mmwp_self_test_abilities_available', function ( $available ) {
// Change $available here.
return $available;
} );
Filter
Since 0.1.0
Filter whether the Abilities API is usable for self-tests; a host plugin that gates its own abilities can report that here.
Parameters of mmwp_self_test_abilities_available | Name | Type | Description |
$available | bool | Default: `function_exists('wp_get_ability')`. |
Fired in src/Config.php#L143↗(opens in a new tab) (Config::abilities_available()).
Filter
Since 0.1.0
Filter the URL of a package asset.
Parameters of mmwp_self_test_asset_url | Name | Type | Description |
$url | string | Resolved URL. |
$relative | string | Path relative to the package root. |
Fired in src/Config.php#L172↗(opens in a new tab) (Config::asset_url()).
Filter
Since 0.1.0
Filter the capability required to run the self-tests.
Parameters of mmwp_self_test_capability | Name | Type | Description |
$capability | string | Default 'manage_options'. |
Fired in src/Config.php#L39↗(opens in a new tab) (Config::capability()).
Filter
Since 0.1.0
Filter whether the WP_CLI shim is defined on web requests.
Parameters of mmwp_self_test_shim_enabled | Name | Type | Description |
$enabled | bool | Default: the dashboard is enabled. |
Fired in src/Config.php#L123↗(opens in a new tab) (Config::shim_enabled()).
Filter
Since 0.6.0
Filter whether the self-test dashboard (and its REST routes) are registered.
Parameters of mmwp_self_test_ui_enabled | Name | Type | Description |
$enabled | bool | Default: true unless the environment is `production`. |
$environment | string | `WP_ENV` or `wp_get_environment_type()`. |
Fired in src/Config.php#L103↗(opens in a new tab) (Config::ui_enabled()).
Lifecycle
Example: mmwp_self_test_enabled
add_filter( 'mmwp_self_test_enabled', function ( $enabled, $environment ) {
// Change $enabled here.
return $enabled;
}, 10, 2 );
Action
Since 0.1.0
Fires once the self-test package has booted.
Parameters of mmwp_self_test_booted | Name | Type | Description |
$path | string | Directory of the booted copy. |
$version | string | Version of the booted copy. |
Fired in src/Loader.php#L128↗(opens in a new tab) (Loader::boot()).
Filter
Since 0.7.0
Filter whether the self-test package boots on this request (surfaces, manifests, dashboard, commands and abilities).
Parameters of mmwp_self_test_enabled | Name | Type | Description |
$enabled | bool | Default: true unless the environment is `production`. |
$environment | string | `WP_ENV` or `wp_get_environment_type()`. |
Fired in src/Loader.php#L168↗(opens in a new tab) (Loader::enabled()).
Also fired in src/Config.php#L56↗(opens in a new tab).
Filter
Since 0.1.0
Filter one parsed manifest before its cases are built.
Parameters of mmwp_self_test_manifest | Name | Type | Description |
$manifest | array | Parsed manifest (`version`, `cases`). |
$path | string | Manifest file path. |
$plugin | string | Owning plugin slug. |
Fired in src/Manifest.php#L96↗(opens in a new tab) (Manifest::load()).
Action
Since 0.1.0
Register self-test manifests.
Parameters of mmwp_self_test_register | Name | Type | Description |
$registry | Registry | Call `$registry->register($slug, $manifest_path, $opts)`. |
Fired in src/Self_Test.php#L125↗(opens in a new tab) (Self_Test::fire_register()).
Surfaces and runs
Example: mmwp_self_test_ability_definitions
add_filter( 'mmwp_self_test_ability_definitions', function ( $definitions ) {
// Change $definitions here.
return $definitions;
} );
Filter
Since 0.1.0
Filter the self-test ability definitions before registration.
Parameters of mmwp_self_test_ability_definitions | Name | Type | Description |
$definitions | array<string,array> | Definitions keyed by ability name. |
Fired in src/Surfaces/Abilities.php#L77↗(opens in a new tab) (Abilities::register_abilities()).
Action
Since 0.1.0
Fires after a self-test run completed.
Parameters of mmwp_self_test_completed | Name | Type | Description |
$report | array | The report that was stored. |
Fired in src/Runner.php#L194↗(opens in a new tab) (Runner::run()).