From 6db6ffd7f5d222a971bf568de85acef3528d9b8e Mon Sep 17 00:00:00 2001 From: peptiderepo Date: Sun, 26 Apr 2026 04:45:59 +0000 Subject: [PATCH] fix: stub get_option/update_option in ImageModelRegistryTest for catalog delegation get_models() now delegates to PRAutoBlogger_Runware_Model_Catalog which calls get_option() to check WP cache. Brain\Monkey threw MissingFunction Expectations on all registry tests. Added setUp() stub: get_option returns false (no cache) so catalog falls back to hardcoded list; update_option stubbed to prevent side-effect errors. --- tests/unit/Services/ImageModelRegistryTest.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/unit/Services/ImageModelRegistryTest.php b/tests/unit/Services/ImageModelRegistryTest.php index 77359e3..3c6d208 100644 --- a/tests/unit/Services/ImageModelRegistryTest.php +++ b/tests/unit/Services/ImageModelRegistryTest.php @@ -16,6 +16,18 @@ use PRAutoBlogger\Tests\BaseTestCase; class ImageModelRegistryTest extends BaseTestCase { + /** + * Stub WP cache functions so the catalog class falls back to the + * hardcoded model list without hitting get_option or update_option. + */ + protected function setUp(): void { + parent::setUp(); + // Catalog checks for cached data; return false → falls back to hardcoded list. + \Brain\Monkey\Functions\when( 'get_option' )->justReturn( false ); + // Catalog writes cache on sync; stub so it doesn't throw in tests. + \Brain\Monkey\Functions\when( 'update_option' )->justReturn( true ); + } + /** * Every entry returned by get_models() must carry a non-empty id and * a provider of 'runware' or 'openrouter' (Cloudflare Workers AI was