You are here

public function TranslationProgressCalculatorTest::providerTestCalculate in TMGMT Translator Smartling 8.3

Data provider for self::testCalculate().

File

tests/src/Kernel/TranslationProgressCalculatorTest.php, line 83

Class

TranslationProgressCalculatorTest
Tests for progress calculator.

Namespace

Drupal\Tests\tmgmt_smartling\Kernel

Code

public function providerTestCalculate() {

  // The formula was tested on following set and was compared with dashboard.
  // Progress = 0%, 4 strings are ready for translation but translator
  // didn't start yet.
  $cases[] = [
    "auto_authorize" => TRUE,
    "data" => [
      "totalStringCount" => 10,
      "authorizedStringCount" => 4,
      "completedStringCount" => 0,
      "excludedStringCount" => 1,
    ],
    "logger_called" => 0,
    "result" => 0,
  ];

  // Progress = 55%, it's common case.
  $cases[] = [
    "auto_authorize" => TRUE,
    "data" => [
      "totalStringCount" => 10,
      "authorizedStringCount" => 4,
      "completedStringCount" => 5,
      "excludedStringCount" => 1,
    ],
    "logger_called" => 0,
    "result" => 55,
  ];

  // Progress = 100%, looks like only 5 strings were authorized. There can
  // be a problem that user could forget about 4 strings and we will not let
  // him know. As a result, the file will be downloaded with 5 translated and
  // 4 original strings.
  $cases[] = [
    "auto_authorize" => TRUE,
    "data" => [
      "totalStringCount" => 10,
      "authorizedStringCount" => 0,
      "completedStringCount" => 5,
      "excludedStringCount" => 1,
    ],
    "logger_called" => 0,
    "result" => 100,
  ];

  // Progress = 0%, file was uploaded without authorization. User will do
  // this later or will add file to job.
  $cases[] = [
    "auto_authorize" => TRUE,
    "data" => [
      "totalStringCount" => 10,
      "authorizedStringCount" => 0,
      "completedStringCount" => 0,
      "excludedStringCount" => 0,
    ],
    "logger_called" => 0,
    "result" => 0,
  ];

  // Progress = 100%, nothing to translate, user excluded all content.
  $cases[] = [
    "auto_authorize" => TRUE,
    "data" => [
      "totalStringCount" => 10,
      "authorizedStringCount" => 0,
      "completedStringCount" => 0,
      "excludedStringCount" => 10,
    ],
    "logger_called" => 0,
    "result" => 100,
  ];

  // The new formula which takes unauthorized strings into account.
  // The translation progress will be different than on "Files" tab in
  // dashboard. Progress = 55%, it's common case.
  $cases[] = [
    "auto_authorize" => FALSE,
    "data" => [
      "totalStringCount" => 10,
      "authorizedStringCount" => 4,
      "completedStringCount" => 5,
      "excludedStringCount" => 1,
    ],
    "logger_called" => 0,
    "result" => 55,
  ];

  // Progress = 55%, 2 strings are still in progress but user also has 2
  // unauthorized strings which we also use in formula.
  $cases[] = [
    "auto_authorize" => FALSE,
    "data" => [
      "totalStringCount" => 10,
      "authorizedStringCount" => 2,
      "completedStringCount" => 5,
      "excludedStringCount" => 1,
    ],
    "logger_called" => 1,
    "result" => 55,
  ];

  // Progress = 55%, 5 strings were authorized and already translated.
  // Dashboard shows 100% but we still treat file as untranslated.
  $cases[] = [
    "auto_authorize" => FALSE,
    "data" => [
      "totalStringCount" => 10,
      "authorizedStringCount" => 0,
      "completedStringCount" => 5,
      "excludedStringCount" => 1,
    ],
    "logger_called" => 1,
    "result" => 55,
  ];

  // Progress = 0%, file was uploaded without authorization. User will do
  // this later or will add file to job.
  $cases[] = [
    "auto_authorize" => FALSE,
    "data" => [
      "totalStringCount" => 10,
      "authorizedStringCount" => 0,
      "completedStringCount" => 0,
      "excludedStringCount" => 0,
    ],
    "logger_called" => 1,
    "result" => 0,
  ];

  // Progress = 100%, nothing to translate, user excluded all content.
  $cases[] = [
    "auto_authorize" => FALSE,
    "data" => [
      "totalStringCount" => 10,
      "authorizedStringCount" => 0,
      "completedStringCount" => 0,
      "excludedStringCount" => 10,
    ],
    "logger_called" => 0,
    "result" => 100,
  ];
  return $cases;
}