Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 7 additions & 0 deletions tests/phpunit/tests/abilities-api/wpAbilitiesRegistry.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ public function set_up(): void {
wp_unregister_ability_category( $ability_category->get_slug() );
}

// Remove core registration action to prevent re-registration.
remove_action( 'wp_abilities_api_categories_init', 'wp_register_core_ability_categories' );

// Fire the init hook to allow test ability category registration.
do_action( 'wp_abilities_api_categories_init' );
wp_register_ability_category(
Expand Down Expand Up @@ -92,6 +95,10 @@ public function tear_down(): void {
// Clean up registered test ability category.
wp_unregister_ability_category( 'math' );

// Re-add core registration action and re-register core categories.
add_action( 'wp_abilities_api_categories_init', 'wp_register_core_ability_categories' );
do_action( 'wp_abilities_api_categories_init' );

parent::tear_down();
}

Expand Down
7 changes: 7 additions & 0 deletions tests/phpunit/tests/abilities-api/wpAbility.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ public function set_up(): void {
wp_unregister_ability_category( $ability_category->get_slug() );
}

// Remove core registration action to prevent re-registration.
remove_action( 'wp_abilities_api_categories_init', 'wp_register_core_ability_categories' );

// Fire the init hook to allow test ability category registration.
do_action( 'wp_abilities_api_categories_init' );
wp_register_ability_category(
Expand Down Expand Up @@ -64,6 +67,10 @@ public function tear_down(): void {
// Clean up registered test ability category.
wp_unregister_ability_category( 'math' );

// Re-add core registration action and re-register core categories.
add_action( 'wp_abilities_api_categories_init', 'wp_register_core_ability_categories' );
do_action( 'wp_abilities_api_categories_init' );

parent::tear_down();
}

Expand Down
7 changes: 7 additions & 0 deletions tests/phpunit/tests/abilities-api/wpRegisterAbility.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ public function set_up(): void {
wp_unregister_ability_category( $ability_category->get_slug() );
}

// Remove core registration action to prevent re-registration.
remove_action( 'wp_abilities_api_categories_init', 'wp_register_core_ability_categories' );

// Fire the init hook to allow test ability category registration.
do_action( 'wp_abilities_api_categories_init' );
wp_register_ability_category(
Expand Down Expand Up @@ -102,6 +105,10 @@ public function tear_down(): void {
// Clean up registered test ability category.
wp_unregister_ability_category( 'math' );

// Re-add core registration action and re-register core categories.
add_action( 'wp_abilities_api_categories_init', 'wp_register_core_ability_categories' );
do_action( 'wp_abilities_api_categories_init' );

parent::tear_down();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public function tear_down(): void {
wp_unregister_ability_category( $ability_category->get_slug() );
}

// Re-add core registration action and re-register core categories.
add_action( 'wp_abilities_api_categories_init', 'wp_register_core_ability_categories' );
do_action( 'wp_abilities_api_categories_init' );

parent::tear_down();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Tests_REST_API_WpRestAbilitiesV1CategoriesController extends WP_UnitTestCa
protected static $admin_user_id;

/**
* Test subscriber user ID.
* Test subscriber user ID.x
*
* @var int
*/
Expand Down Expand Up @@ -67,6 +67,9 @@ public function set_up(): void {
wp_unregister_ability_category( $ability_category->get_slug() );
}

// Remove core registration action to prevent re-registration.
remove_action( 'wp_abilities_api_categories_init', 'wp_register_core_ability_categories' );

// Initialize the API and register test ability categories.
do_action( 'wp_abilities_api_categories_init' );
$this->register_test_ability_categories();
Expand All @@ -88,6 +91,10 @@ public function tear_down(): void {
wp_unregister_ability_category( $ability_category->get_slug() );
}

// Re-add core registration action and re-register core categories.
add_action( 'wp_abilities_api_categories_init', 'wp_register_core_ability_categories' );
do_action( 'wp_abilities_api_categories_init' );

global $wp_rest_server;
$wp_rest_server = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ public function set_up(): void {
wp_unregister_ability_category( $ability_category->get_slug() );
}

// Remove core registration actions to prevent re-registration.
remove_action( 'wp_abilities_api_categories_init', 'wp_register_core_ability_categories' );
remove_action( 'wp_abilities_api_init', 'wp_register_core_abilities' );

// Initialize Abilities API.
do_action( 'wp_abilities_api_init' );
$this->register_test_abilities();
Expand All @@ -98,6 +102,11 @@ public function tear_down(): void {
wp_unregister_ability( $ability->get_name() );
}

// Re-add core registration actions and re-register core abilities.
add_action( 'wp_abilities_api_categories_init', 'wp_register_core_ability_categories' );
add_action( 'wp_abilities_api_init', 'wp_register_core_abilities' );
do_action( 'wp_abilities_api_init' );

// Reset REST server
global $wp_rest_server;
$wp_rest_server = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ public function set_up(): void {
wp_unregister_ability_category( $ability_category->get_slug() );
}

// Remove core registration actions to prevent re-registration.
remove_action( 'wp_abilities_api_categories_init', 'wp_register_core_ability_categories' );
remove_action( 'wp_abilities_api_init', 'wp_register_core_abilities' );

// Initialize Abilities API.
do_action( 'wp_abilities_api_init' );
$this->register_test_abilities();
Expand All @@ -109,6 +113,11 @@ public function tear_down(): void {
wp_unregister_ability( $ability->get_name() );
}

// Re-add core registration actions and re-register core abilities.
add_action( 'wp_abilities_api_categories_init', 'wp_register_core_ability_categories' );
add_action( 'wp_abilities_api_init', 'wp_register_core_abilities' );
do_action( 'wp_abilities_api_init' );

global $wp_rest_server;
$wp_rest_server = null;

Expand Down
Loading