fix(tests): resolve Patchwork conflict and WP_Error_Stub issue

- Remove wp_strip_all_tags/sanitize_text_field stubs from bootstrap
  (Brain Monkey manages these via Functions\when() in individual tests;
  defining them early triggers Patchwork's DefinedTooEarly error)
- Add WP_Error class stub to bootstrap (class, not function — safe for
  Patchwork) so model registry and image pipeline tests can use it
- Replace WP_Error_Stub with standard WP_Error in model registry test

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
peptiderepo
2026-04-16 17:38:35 +07:00
parent 38157f0b41
commit 4f13afbb77
2 changed files with 33 additions and 24 deletions

View File

@@ -224,8 +224,7 @@ class OpenRouterModelRegistryTest extends BaseTestCase {
return 'Connection timed out';
};
Functions\when( 'wp_remote_get' )->alias( function () {
$e = new \WP_Error_Stub();
return $e;
return new \WP_Error( 'http_request_failed', 'Connection timed out' );
} );
// Accept that update_option will be called for the stale flag.
@@ -240,13 +239,3 @@ class OpenRouterModelRegistryTest extends BaseTestCase {
}
}
/**
* Minimal WP_Error stub for testing is_wp_error() branches.
*/
if ( ! class_exists( 'WP_Error_Stub' ) ) {
class WP_Error_Stub {
public function get_error_message(): string {
return 'Connection timed out';
}
}
}