protected function FileTranslatorTest::importFile

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 508

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.
  $this
    ->drupalGet($job
    ->toUrl());
  $edit = array(
    'files[file]' => $translated_file,
  );
  $this
    ->submitForm($edit, 'Import');

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

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

  //$this->assertSession()->pageTextContains('Needs review');

  // Review both items.
  list($item1, $item2) = array_values($job
    ->getItems());
  $this
    ->drupalGet($item1
    ->toUrl());
  foreach ($translated_text[1] as $key => $value) {
    $this
      ->assertSession()
      ->responseContains(Html::escape($value));
  }
  foreach ($translated_text[2] as $key => $value) {
    $this
      ->assertSession()
      ->responseNotContains(Html::escape($value));
  }
  $this
    ->submitForm([], 'Save as completed');

  // Review both items.
  $this
    ->drupalGet($item2
    ->toUrl());
  foreach ($translated_text[1] as $key => $value) {
    $this
      ->assertSession()
      ->responseNotContains(Html::escape($value));
  }
  foreach ($translated_text[2] as $key => $value) {
    $this
      ->assertSession()
      ->responseContains(Html::escape($value));
  }
  $this
    ->submitForm([], 'Save as completed');

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

  //$this->assertSession()->pageTextContains('Accepted');
  $this
    ->assertSession()
    ->pageTextContains('Finished');
  $this
    ->assertSession()
    ->responseNotContains('title="Needs review"');
}