- Timestamp:
- 11/04/2025 04:32:45 PM (9 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/wpRestAbilitiesV1ListController.php
r61032 r61130 38 38 ); 39 39 40 // Fire the init hook to allow test ability categories registration.41 do_action( 'wp_abilities_api_categories_init' );42 40 self::register_test_categories(); 43 41 } … … 68 66 do_action( 'rest_api_init' ); 69 67 70 // Initialize Abilities API.71 do_action( 'wp_abilities_api_init' );72 68 $this->register_test_abilities(); 73 69 … … 100 96 */ 101 97 public static function register_test_categories(): void { 98 // Simulates the init hook to allow test ability categories registration. 99 global $wp_current_filter; 100 $wp_current_filter[] = 'wp_abilities_api_categories_init'; 101 102 102 wp_register_ability_category( 103 103 'math', … … 123 123 ) 124 124 ); 125 126 array_pop( $wp_current_filter ); 127 } 128 129 /** 130 * Helper to register a test ability. 131 * 132 * @param string $name Ability name. 133 * @param array $args Ability arguments. 134 */ 135 private function register_test_ability( string $name, array $args ): void { 136 // Simulates the init hook to allow test abilities registration. 137 global $wp_current_filter; 138 $wp_current_filter[] = 'wp_abilities_api_init'; 139 140 wp_register_ability( $name, $args ); 141 142 array_pop( $wp_current_filter ); 125 143 } 126 144 … … 130 148 private function register_test_abilities(): void { 131 149 // Register a regular ability. 132 wp_register_ability(150 $this->register_test_ability( 133 151 'test/calculator', 134 152 array( … … 174 192 175 193 // Register a read-only ability. 176 wp_register_ability(194 $this->register_test_ability( 177 195 'test/system-info', 178 196 array( … … 221 239 222 240 // Ability that does not show in REST. 223 wp_register_ability(241 $this->register_test_ability( 224 242 'test/not-show-in-rest', 225 243 array( … … 236 254 // Register multiple abilities for pagination testing 237 255 for ( $i = 1; $i <= 60; $i++ ) { 238 wp_register_ability(256 $this->register_test_ability( 239 257 "test/ability-{$i}", 240 258 array( … … 590 608 public function test_ability_name_with_valid_special_characters(): void { 591 609 // Register ability with hyphen (valid). 592 wp_register_ability(610 $this->register_test_ability( 593 611 'test-hyphen/ability', 594 612 array(
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)