Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions tests/phpunit/tests/abilities-api/wpRegisterCoreAbilities.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ public static function set_up_before_class(): void {
add_action( 'wp_abilities_api_init', 'wp_register_core_abilities' );
do_action( 'wp_abilities_api_categories_init' );
do_action( 'wp_abilities_api_init' );

/*
* Restore the hooks right away instead of after the class. The first test of a run
* snapshots the hooks and every test resets them to that snapshot, so changes left
* here would leak into every later test whenever this class runs first.
*/
remove_action( 'wp_abilities_api_categories_init', 'wp_register_core_ability_categories' );
remove_action( 'wp_abilities_api_init', 'wp_register_core_abilities' );
add_action( 'wp_abilities_api_categories_init', '_unhook_core_ability_categories_registration', 1 );
add_action( 'wp_abilities_api_init', '_unhook_core_abilities_registration', 1 );
}

/**
Expand All @@ -38,10 +48,6 @@ public static function set_up_before_class(): void {
* @since 6.9.0
*/
public static function tear_down_after_class(): void {
// Re-add the unhook functions for subsequent tests.
add_action( 'wp_abilities_api_categories_init', '_unhook_core_ability_categories_registration', 1 );
add_action( 'wp_abilities_api_init', '_unhook_core_abilities_registration', 1 );

// Remove the core abilities and their categories.
foreach ( wp_get_abilities() as $ability ) {
wp_unregister_ability( $ability->get_name() );
Expand Down
Loading