- Timestamp:
- 03/23/2026 07:39:45 PM (4 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tests/phpunit/tests/rest-api/wpRestAbilitiesV1RunController.php
r61999 r62094 380 380 ); 381 381 382 // Ability with nested namespace (3 segments).383 $this->register_test_ability(384 'test/math/add',385 array(386 'label' => 'Nested Add',387 'description' => 'Adds numbers with nested namespace',388 'category' => 'math',389 'input_schema' => array(390 'type' => 'object',391 'properties' => array(392 'a' => array(393 'type' => 'number',394 'description' => 'First number',395 ),396 'b' => array(397 'type' => 'number',398 'description' => 'Second number',399 ),400 ),401 'required' => array( 'a', 'b' ),402 'additionalProperties' => false,403 ),404 'output_schema' => array(405 'type' => 'number',406 ),407 'execute_callback' => static function ( array $input ) {408 return $input['a'] + $input['b'];409 },410 'permission_callback' => static function () {411 return current_user_can( 'edit_posts' );412 },413 'meta' => array(414 'show_in_rest' => true,415 ),416 )417 );418 419 382 // Read-only ability for query params testing. 420 383 $this->register_test_ability( … … 468 431 $this->assertEquals( 200, $response->get_status() ); 469 432 $this->assertEquals( 8, $response->get_data() ); 470 }471 472 /**473 * Test executing an ability with a nested namespace (3 segments) via REST.474 *475 * @ticket 64098476 */477 public function test_execute_nested_namespace_ability(): void {478 $request = new WP_REST_Request( 'POST', '/wp-abilities/v1/abilities/test/math/add/run' );479 $request->set_header( 'Content-Type', 'application/json' );480 $request->set_body(481 wp_json_encode(482 array(483 'input' => array(484 'a' => 10,485 'b' => 7,486 ),487 )488 )489 );490 491 $response = $this->server->dispatch( $request );492 493 $this->assertEquals( 200, $response->get_status() );494 $this->assertEquals( 17, $response->get_data() );495 433 } 496 434
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)