Created PredefinedModelsTest class.
Overview
The PredefinedModelsTest class is a unit test for the PredefinedModels utility class within the AI module. This utility class likely provides methods to retrieve predefined models based on
operation types, and this test ensures that these methods function correctly under various scenarios.
Test Methods
-
testGetPredefinedModelsValidOperationType()-
Purpose: Validates that the
getPredefinedModelsmethod correctly retrieves predefined models for a valid operation type. -
Setup:
- Mocks the
ModuleHandlerto return a path to a YAML file. - Reads the YAML file and stores its content in
$models_data.
- Mocks the
-
Execution:
- Calls
PredefinedModels::getPredefinedModels($operation_type)with a valid operation type ('chat').
- Calls
-
Assertion: Compares the returned models with
$models_datausingassertEquals.
-
Purpose: Validates that the
-
testGetPredefinedModelsInvalidOperationType()-
Purpose: Validates that the
getPredefinedModelsmethod returns an empty array for an invalid operation type. -
Execution:
- Calls
PredefinedModels::getPredefinedModels($operation_type)with an invalid operation type ('invalid..operation').
- Calls
-
Assertion: Uses
assertEqualsto check if the returned value is an empty array.
-
Purpose: Validates that the
-
testGetPredefinedModelsAsOptionsValidOperationType()-
Purpose: Validates that the
getPredefinedModelsAsOptionsmethod correctly retrieves predefined models as options for a valid operation type. -
Setup:
- Mocks the
ModuleHandlerto return a path to a YAML file. - Reads the YAML file, processes the data to create
$models_data, and sorts it.
- Mocks the
-
Execution:
- Calls
PredefinedModels::getPredefinedModelsAsOptions($operation_type)with a valid operation type ('chat').
- Calls
-
Assertion: Compares the returned options with
$models_datausingassertEquals.
-
Purpose: Validates that the