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

  1. testGetPredefinedModelsValidOperationType()

    • Purpose: Validates that the getPredefinedModels method correctly retrieves predefined models for a valid operation type.
    • Setup:
      • Mocks the ModuleHandler to return a path to a YAML file.
      • Reads the YAML file and stores its content in $models_data.
    • Execution:
      • Calls PredefinedModels::getPredefinedModels($operation_type) with a valid operation type ('chat').
    • Assertion: Compares the returned models with $models_data using assertEquals.
  2. testGetPredefinedModelsInvalidOperationType()

    • Purpose: Validates that the getPredefinedModels method returns an empty array for an invalid operation type.
    • Execution:
      • Calls PredefinedModels::getPredefinedModels($operation_type) with an invalid operation type ('invalid..operation').
    • Assertion: Uses assertEquals to check if the returned value is an empty array.
  3. testGetPredefinedModelsAsOptionsValidOperationType()

    • Purpose: Validates that the getPredefinedModelsAsOptions method correctly retrieves predefined models as options for a valid operation type.
    • Setup:
      • Mocks the ModuleHandler to return a path to a YAML file.
      • Reads the YAML file, processes the data to create $models_data, and sorts it.
    • Execution:
      • Calls PredefinedModels::getPredefinedModelsAsOptions($operation_type) with a valid operation type ('chat').
    • Assertion: Compares the returned options with $models_data using assertEquals.

Merge request reports

Loading