Skip to content

Commit f263222

Browse files
committed
Update McpToolsRegistrationTest to handle non-existent REST routes
- Removed exception expectations for non-existent routes and updated the test to verify that tools are not registered when the route does not exist. - Added assertions to confirm that the tool with a non-existent route is not included in the registered tools list.
1 parent af86d58 commit f263222

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tests/phpunit/McpToolsRegistrationTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -642,8 +642,7 @@ function () {
642642
*/
643643
public function test_call_tool_endpoint_with_non_existent_rest_route(): void {
644644
// Register a test tool with a non-existent REST API route.
645-
$this->expectException( \InvalidArgumentException::class );
646-
$this->expectExceptionMessage( 'The route /wp/v2/non_existent_route with method GET does not exist.' );
645+
// The registration should be silently skipped and logged as an error.
647646

648647
add_action(
649648
'wordpress_mcp_init',
@@ -663,6 +662,11 @@ function () {
663662
);
664663

665664
do_action( 'wordpress_mcp_init' );
665+
666+
// Verify that the tool was NOT registered since the route doesn't exist.
667+
$registered_tools = $this->mcp->get_tools();
668+
$tool_names = array_column( $registered_tools, 'name' );
669+
$this->assertNotContains( 'non_existent_route_tool', $tool_names, 'Tool with non-existent route should not be registered' );
666670
}
667671

668672
/**

0 commit comments

Comments
 (0)