You are here

protected function FileTranslatorTest::importFile in Translation Management Tool 8

2 calls to FileTranslatorTest::importFile()
FileTranslatorTest::testHTML in translators/tmgmt_file/tests/src/Functional/FileTranslatorTest.php
Tests export and import for the HTML format.
FileTranslatorTest::testXLIFF in translators/tmgmt_file/tests/src/Functional/FileTranslatorTest.php
Tests import and export for the XLIFF format.

File

translators/tmgmt_file/tests/src/Functional/FileTranslatorTest.php, line 501

Class

FileTranslatorTest
Tests for the file translator.

Namespace

Drupal\Tests\tmgmt_file\Functional

Code

protected function importFile($translated_file, $translated_text, JobInterface $job) {

  // To test the upload form functionality, navigate to the edit form.
  $edit = array(
    'files[file]' => $translated_file,
  );
  $this
    ->drupalPostForm($job
    ->toUrl(), $edit, t('Import'));

  // Make sure the translations have been imported correctly.
  $this
    ->assertNoRaw('title="In progress"');

  // @todo: Enable this assertion once new releases for views and entity
  // module are out.

  //$this->assertText(t('Needs review'));

  // Review both items.
  list($item1, $item2) = array_values($job
    ->getItems());
  $this
    ->drupalGet($item1
    ->toUrl());
  foreach ($translated_text[1] as $key => $value) {
    $this
      ->assertText(Html::escape($value));
  }
  foreach ($translated_text[2] as $key => $value) {
    $this
      ->assertNoText(Html::escape($value));
  }
  $this
    ->drupalPostForm(NULL, array(), t('Save as completed'));

  // Review both items.
  $this
    ->drupalGet($item2
    ->toUrl());
  foreach ($translated_text[1] as $key => $value) {
    $this
      ->assertNoText(Html::escape($value));
  }
  foreach ($translated_text[2] as $key => $value) {
    $this
      ->assertText(Html::escape($value));
  }
  $this
    ->drupalPostForm(NULL, array(), t('Save as completed'));

  // @todo: Enable this assertion once new releases for views and entity
  // module are out.

  //$this->assertText(t('Accepted'));
  $this
    ->assertText(t('Finished'));
  $this
    ->assertNoRaw('title="Needs review"');
}