@@ -3390,4 +3390,123 @@ public function testMethodChainingWithNewMethods(): void
33903390 $ this ->assertTrue ($ config ->getLogprobs ());
33913391 $ this ->assertEquals (3 , $ config ->getTopLogprobs ());
33923392 }
3393+
3394+ /**
3395+ * Tests isSupported method with explicit capability.
3396+ *
3397+ * @return void
3398+ */
3399+ public function testIsSupportedWithExplicitCapability (): void
3400+ {
3401+ $ builder = new PromptBuilder ($ this ->registry , 'Test prompt ' );
3402+
3403+ // Mock registry to return a model supporting text generation
3404+ $ this ->registry ->method ('findModelsMetadataForSupport ' )
3405+ ->willReturn ([$ this ->createMock (ProviderModelsMetadata::class)]);
3406+
3407+ $ this ->assertTrue ($ builder ->isSupported (CapabilityEnum::textGeneration ()));
3408+ }
3409+
3410+ /**
3411+ * Tests isSupported method with inferred capability from output modalities.
3412+ *
3413+ * @return void
3414+ */
3415+ public function testIsSupportedWithInferredCapability (): void
3416+ {
3417+ $ builder = new PromptBuilder ($ this ->registry , 'Test prompt ' );
3418+ $ builder ->asOutputModalities (ModalityEnum::image ());
3419+
3420+ // Mock registry to return a model supporting image generation
3421+ $ this ->registry ->method ('findModelsMetadataForSupport ' )
3422+ ->willReturn ([$ this ->createMock (ProviderModelsMetadata::class)]);
3423+
3424+ // Should infer image generation capability
3425+ $ this ->assertTrue ($ builder ->isSupported ());
3426+ }
3427+
3428+ /**
3429+ * Tests isSupported method with inferred capability from model interfaces.
3430+ *
3431+ * @return void
3432+ */
3433+ public function testIsSupportedWithInferredCapabilityFromModel (): void
3434+ {
3435+ $ metadata = $ this ->createMock (ModelMetadata::class);
3436+ $ metadata ->method ('getId ' )->willReturn ('test-model ' );
3437+ $ metadata ->method ('getSupportedCapabilities ' )->willReturn ([
3438+ CapabilityEnum::textGeneration ()
3439+ ]);
3440+ $ metadata ->method ('getSupportedOptions ' )->willReturn ([
3441+ new SupportedOption (OptionEnum::inputModalities (), [
3442+ [ModalityEnum::text ()]
3443+ ])
3444+ ]);
3445+
3446+ $ result = new GenerativeAiResult ('test-id ' , [
3447+ new Candidate (
3448+ new ModelMessage ([new MessagePart ('Test ' )]),
3449+ FinishReasonEnum::stop ()
3450+ )
3451+ ], new TokenUsage (10 , 5 , 15 ), $ this ->createTestProviderMetadata (), $ this ->createTestTextModelMetadata ());
3452+
3453+ $ model = $ this ->createMockTextGenerationModel ($ result , $ metadata );
3454+
3455+ $ builder = new PromptBuilder ($ this ->registry , 'Test prompt ' );
3456+ $ builder ->usingModel ($ model );
3457+
3458+ // Should infer text generation capability from the model interface
3459+ $ this ->assertTrue ($ builder ->isSupported ());
3460+ }
3461+
3462+ /**
3463+ * Tests isSupported method when a model is explicitly set.
3464+ *
3465+ * @return void
3466+ */
3467+ public function testIsSupportedWithModelSet (): void
3468+ {
3469+ $ metadata = $ this ->createMock (ModelMetadata::class);
3470+ $ metadata ->method ('getId ' )->willReturn ('text-model ' );
3471+ $ metadata ->method ('getSupportedCapabilities ' )->willReturn ([
3472+ CapabilityEnum::textGeneration ()
3473+ ]);
3474+ // Mock getSupportedOptions to return required options
3475+ $ metadata ->method ('getSupportedOptions ' )->willReturn ([
3476+ new SupportedOption (OptionEnum::inputModalities (), [
3477+ [ModalityEnum::text ()]
3478+ ])
3479+ ]);
3480+
3481+ $ result = new GenerativeAiResult ('test-id ' , [
3482+ new Candidate (
3483+ new ModelMessage ([new MessagePart ('Test ' )]),
3484+ FinishReasonEnum::stop ()
3485+ )
3486+ ], new TokenUsage (10 , 5 , 15 ), $ this ->createTestProviderMetadata (), $ this ->createTestTextModelMetadata ());
3487+
3488+ $ model = $ this ->createMockTextGenerationModel ($ result , $ metadata );
3489+
3490+ $ builder = new PromptBuilder ($ this ->registry , 'Test prompt ' );
3491+ $ builder ->usingModel ($ model );
3492+
3493+ $ this ->assertTrue ($ builder ->isSupported (CapabilityEnum::textGeneration ()));
3494+ $ this ->assertFalse ($ builder ->isSupported (CapabilityEnum::imageGeneration ()));
3495+ }
3496+
3497+ /**
3498+ * Tests isSupported method when no models support the requirements.
3499+ *
3500+ * @return void
3501+ */
3502+ public function testIsSupportedWithNoSupport (): void
3503+ {
3504+ $ builder = new PromptBuilder ($ this ->registry , 'Test prompt ' );
3505+
3506+ // Mock registry to return no models
3507+ $ this ->registry ->method ('findModelsMetadataForSupport ' )
3508+ ->willReturn ([]);
3509+
3510+ $ this ->assertFalse ($ builder ->isSupported (CapabilityEnum::textGeneration ()));
3511+ }
33933512}
0 commit comments