protected function LocalTranslatorTestBase::assertTaskProgress

Asserts the task progress bar.

Parameters

int $row: The row of the item you want to check.

string $overview: The overview to be checked.

int $untranslated: The amount of untranslated items.

int $translated: The amount of translated items.

int $completed: The amount of completed items.

File

translators/tmgmt_local/tests/src/Functional/LocalTranslatorTestBase.php, line 98

Class

LocalTranslatorTestBase
Base class for local translator tests.

Namespace

Drupal\Tests\tmgmt_local\Functional

Code

protected function assertTaskProgress($row, $overview, $untranslated, $translated, $completed) {
  $result = $this
    ->xpath('//*[@id="views-form-tmgmt-local-task-overview-' . $overview . '"]/table/tbody/tr[' . $row . ']/td[3]')[0];
  $div_number = 1;
  if ($untranslated > 0) {
    $this
      ->assertEquals('tmgmt-local-progress-untranslated', $result
      ->find('css', "div > div:nth-child({$div_number})")
      ->getAttribute('class'));
    $div_number++;
  }
  else {
    $this
      ->assertNotEquals('tmgmt-local-progress-untranslated', $result
      ->find('css', "div > div:nth-child({$div_number})")
      ->getAttribute('class'));
  }
  if ($translated > 0) {
    $this
      ->assertEquals('tmgmt-local-progress-translated', $result
      ->find('css', "div > div:nth-child({$div_number})")
      ->getAttribute('class'));
    $div_number++;
  }
  else {
    $child = $result
      ->find('css', "div > div:nth-child({$div_number})");
    $this
      ->assertTrue(!$child || $child
      ->getAttribute('class'), 'tmgmt-local-progress-translated');
  }
  if ($completed > 0) {
    $this
      ->assertEquals('tmgmt-local-progress-completed', $result
      ->find('css', "div > div:nth-child({$div_number})")
      ->getAttribute('class'));
  }
  else {
    $child = $result
      ->find('css', "div > div:nth-child({$div_number})");
    $this
      ->assertTrue(!$child || $child
      ->getAttribute('class'), 'tmgmt-local-progress-completed');
  }
  $title = t('Untranslated: @untranslated, translated: @translated, completed: @completed.', array(
    '@untranslated' => $untranslated,
    '@translated' => $translated,
    '@completed' => $completed,
  ));
  $this
    ->assertEquals($title, $result
    ->find('css', 'div')
    ->getAttribute('title'));
}