Skip to content

Commit c56bf85

Browse files
committed
test: adds includeOutputModality tests
1 parent 3fd1fc2 commit c56bf85

File tree

1 file changed

+139
-0
lines changed

1 file changed

+139
-0
lines changed

tests/unit/Providers/Models/DTO/ModelConfigTest.php

Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,4 +654,143 @@ public function testSetCustomOption(): void
654654
$restored = ModelConfig::fromArray($array);
655655
$this->assertEquals($customOptions, $restored->getCustomOptions());
656656
}
657+
658+
/**
659+
* Tests includeOutputModality method.
660+
*
661+
* @return void
662+
*/
663+
public function testIncludeOutputModality(): void
664+
{
665+
$config = new ModelConfig();
666+
667+
// Test adding modality to null output modalities
668+
$this->assertNull($config->getOutputModalities());
669+
$config->includeOutputModality(ModalityEnum::text());
670+
$modalities = $config->getOutputModalities();
671+
$this->assertCount(1, $modalities);
672+
$this->assertTrue($modalities[0]->isText());
673+
674+
// Test adding a different modality
675+
$config->includeOutputModality(ModalityEnum::image());
676+
$modalities = $config->getOutputModalities();
677+
$this->assertCount(2, $modalities);
678+
$this->assertTrue($modalities[0]->isText());
679+
$this->assertTrue($modalities[1]->isImage());
680+
681+
// Test adding a duplicate modality (should not add)
682+
$config->includeOutputModality(ModalityEnum::text());
683+
$modalities = $config->getOutputModalities();
684+
$this->assertCount(2, $modalities);
685+
$this->assertTrue($modalities[0]->isText());
686+
$this->assertTrue($modalities[1]->isImage());
687+
688+
// Test adding another unique modality
689+
$config->includeOutputModality(ModalityEnum::audio());
690+
$modalities = $config->getOutputModalities();
691+
$this->assertCount(3, $modalities);
692+
$this->assertTrue($modalities[0]->isText());
693+
$this->assertTrue($modalities[1]->isImage());
694+
$this->assertTrue($modalities[2]->isAudio());
695+
696+
// Test that duplicate modalities are not added (different instance, same value)
697+
$config->includeOutputModality(ModalityEnum::image());
698+
$modalities = $config->getOutputModalities();
699+
$this->assertCount(3, $modalities);
700+
}
701+
702+
/**
703+
* Tests includeOutputModality with existing modalities set via setOutputModalities.
704+
*
705+
* @return void
706+
*/
707+
public function testIncludeOutputModalityWithExistingModalitiesSet(): void
708+
{
709+
$config = new ModelConfig();
710+
711+
// Set initial modalities
712+
$config->setOutputModalities([ModalityEnum::text(), ModalityEnum::video()]);
713+
$modalities = $config->getOutputModalities();
714+
$this->assertCount(2, $modalities);
715+
716+
// Include a new modality
717+
$config->includeOutputModality(ModalityEnum::image());
718+
$modalities = $config->getOutputModalities();
719+
$this->assertCount(3, $modalities);
720+
$this->assertTrue($modalities[0]->isText());
721+
$this->assertTrue($modalities[1]->isVideo());
722+
$this->assertTrue($modalities[2]->isImage());
723+
724+
// Include an existing modality (should not add)
725+
$config->includeOutputModality(ModalityEnum::video());
726+
$modalities = $config->getOutputModalities();
727+
$this->assertCount(3, $modalities);
728+
}
729+
730+
/**
731+
* Tests includeOutputModality preserves modality order.
732+
*
733+
* @return void
734+
*/
735+
public function testIncludeOutputModalityPreservesOrder(): void
736+
{
737+
$config = new ModelConfig();
738+
739+
// Add modalities in specific order
740+
$config->includeOutputModality(ModalityEnum::audio());
741+
$config->includeOutputModality(ModalityEnum::document());
742+
$config->includeOutputModality(ModalityEnum::text());
743+
$config->includeOutputModality(ModalityEnum::image());
744+
745+
$modalities = $config->getOutputModalities();
746+
$this->assertCount(4, $modalities);
747+
$this->assertTrue($modalities[0]->isAudio());
748+
$this->assertTrue($modalities[1]->isDocument());
749+
$this->assertTrue($modalities[2]->isText());
750+
$this->assertTrue($modalities[3]->isImage());
751+
752+
// Try to add existing modalities in different order (should not change)
753+
$config->includeOutputModality(ModalityEnum::text());
754+
$config->includeOutputModality(ModalityEnum::audio());
755+
756+
$modalities = $config->getOutputModalities();
757+
$this->assertCount(4, $modalities);
758+
$this->assertTrue($modalities[0]->isAudio());
759+
$this->assertTrue($modalities[1]->isDocument());
760+
$this->assertTrue($modalities[2]->isText());
761+
$this->assertTrue($modalities[3]->isImage());
762+
}
763+
764+
/**
765+
* Tests includeOutputModality handles all modality types.
766+
*
767+
* @return void
768+
*/
769+
public function testIncludeOutputModalityHandlesAllModalityTypes(): void
770+
{
771+
$config = new ModelConfig();
772+
773+
// Test all available modality types
774+
$allModalities = [
775+
ModalityEnum::text(),
776+
ModalityEnum::image(),
777+
ModalityEnum::audio(),
778+
ModalityEnum::video(),
779+
ModalityEnum::document()
780+
];
781+
782+
foreach ($allModalities as $modality) {
783+
$config->includeOutputModality($modality);
784+
}
785+
786+
$modalities = $config->getOutputModalities();
787+
$this->assertCount(5, $modalities);
788+
789+
// Verify all modalities are present
790+
$this->assertTrue($modalities[0]->isText());
791+
$this->assertTrue($modalities[1]->isImage());
792+
$this->assertTrue($modalities[2]->isAudio());
793+
$this->assertTrue($modalities[3]->isVideo());
794+
$this->assertTrue($modalities[4]->isDocument());
795+
}
657796
}

0 commit comments

Comments
 (0)