From d31d378ec1642a525d5fa7ee27aa2dc1074b4860 Mon Sep 17 00:00:00 2001 From: peptiderepo Date: Thu, 16 Apr 2026 20:55:03 +0700 Subject: [PATCH] fix(tests): add wp_parse_url mock to OpenRouter tests Both the provider and validator call wp_parse_url() for host extraction. Tests were missing the Brain Monkey stub. Co-Authored-By: Claude Opus 4.6 --- tests/unit/Providers/OpenRouterProviderTest.php | 3 +++ tests/unit/Providers/OpenRouterValidatorTest.php | 3 +++ 2 files changed, 6 insertions(+) diff --git a/tests/unit/Providers/OpenRouterProviderTest.php b/tests/unit/Providers/OpenRouterProviderTest.php index b650bd2..0f9d301 100644 --- a/tests/unit/Providers/OpenRouterProviderTest.php +++ b/tests/unit/Providers/OpenRouterProviderTest.php @@ -48,6 +48,9 @@ class OpenRouterProviderTest extends BaseTestCase { ); Functions\when( 'set_transient' )->justReturn( true ); + // Stub URL parsing. + Functions\when( 'wp_parse_url' )->alias( 'parse_url' ); + // Stub HTTP functions for API calls. Functions\when( 'wp_remote_post' )->justReturn( [ 'body' => '{"choices":[{"message":{"content":"test"},"finish_reason":"stop"}],"usage":{"prompt_tokens":10,"completion_tokens":5,"total_tokens":15}}', diff --git a/tests/unit/Providers/OpenRouterValidatorTest.php b/tests/unit/Providers/OpenRouterValidatorTest.php index f7f4bf7..540e21f 100644 --- a/tests/unit/Providers/OpenRouterValidatorTest.php +++ b/tests/unit/Providers/OpenRouterValidatorTest.php @@ -30,6 +30,9 @@ class OpenRouterValidatorTest extends BaseTestCase { // Stub wp_salt for encryption. Functions\when( 'wp_salt' )->justReturn( 'test_salt_key_for_unit_tests' ); + // Stub URL parsing. + Functions\when( 'wp_parse_url' )->alias( 'parse_url' ); + // Stub HTTP functions. Functions\when( 'wp_remote_get' )->justReturn( [ 'body' => '{}',