Skip to content
Snippets Groups Projects

Created TranslateTextTest class.

Closes #3488374

The provided Drupal unit test, TranslateTextTest, focuses on testing the functionality of two classes: TranslateTextInput and TranslateTextOutput. These classes are part of a module named ai, specifically within the OperationType\TranslateText namespace. The tests ensure that these classes can be properly created with valid input data and that their methods return expected results.

Here's a summary of each test case:

  1. Test Case: testTranslateTextInputCreation

    • Purpose: This test verifies that an instance of TranslateTextInput is created correctly.
    • Input: A string 'Hello, world!', source language 'en', and target language 'es'.
    • Expected Output:
      • The toString() and (string) methods should return the original text `'Hello, world!'.
      • The getSourceLanguage() method should return the source language 'en'.
      • The getTargetLanguage() method should return the target language 'es'.
    • Additional Test: The test also checks that the source and target languages can be updated using the setSourceLanguage and setTargetLanguage methods.
  2. Test Case: testTranslateTextOutputCreation

    • Purpose: This test verifies that an instance of TranslateTextOutput is created correctly.
    • Input:
      • A normalized string '¡Hola, mundo!', a raw output array containing the translated text, and metadata with a confidence level.
    • Expected Output:
      • The getNormalized() method should return the normalized text `'¡Hola, mundo!'.
      • The getRawOutput() method should return the raw output array.
      • The getMetadata() method should return the metadata.
    • Additional Test: The test also checks that the output can be converted to an associative array using the toArray method.

Summary

  • The tests ensure that both TranslateTextInput and TranslateTextOutput classes handle their properties and methods as expected.
  • They verify the proper creation of instances with correct data.
  • Additional tests check for mutability of source/target languages in the input class and conversion to array format in the output class.

Merge request reports

Code Quality is loading
Test summary results are being parsed

Merged by Marcus JohanssonMarcus Johansson 7 months ago (Dec 16, 2024 5:01pm UTC)

Merge details

  • Changes merged into 1.0.x with a5d58927 (commits were squashed).
  • Did not delete the source branch.
  • Auto-merge enabled

Pipeline #370114 passed

Pipeline passed for a5d58927 on 1.0.x

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
Please register or sign in to reply
Loading