File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
tests/phpunit/tests/abilities-api Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,12 @@ public function set_up(): void {
2626 'label ' => 'Math ' ,
2727 'description ' => 'Mathematical operations. ' ,
2828 );
29+
30+ // Unregister all ability categories to ensure a clean slate for each test.
31+ foreach ( wp_get_ability_categories () as $ ability_category ) {
32+ wp_unregister_ability_category ( $ ability_category ->get_slug () );
33+ }
34+ remove_action ( 'wp_abilities_api_categories_init ' , 'wp_register_core_ability_categories ' );
2935 }
3036
3137 /**
@@ -52,6 +58,10 @@ public function tear_down(): void {
5258 * @expectedIncorrectUsage wp_register_ability_category
5359 */
5460 public function test_register_category_before_init_hook (): void {
61+ // simulate that the 'wp_abilities_api_categories_init' action has not yet fired.
62+ global $ wp_actions ;
63+ $ wp_actions [ 'wp_abilities_api_categories_init ' ] = 0 ;
64+
5565 $ result = wp_register_ability_category (
5666 self ::$ test_ability_category_name ,
5767 self ::$ test_ability_category_args
You can’t perform that action at this time.
0 commit comments