You are here

public function LingotekInterfaceTranslationTest::testCheckSourceStatusNotCompletedAndStillImporting in Lingotek Translation 4.0.x

Same name and namespace in other branches
  1. 3.7.x tests/src/Functional/LingotekInterfaceTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekInterfaceTranslationTest::testCheckSourceStatusNotCompletedAndStillImporting()
  2. 3.8.x tests/src/Functional/LingotekInterfaceTranslationTest.php \Drupal\Tests\lingotek\Functional\LingotekInterfaceTranslationTest::testCheckSourceStatusNotCompletedAndStillImporting()

Tests that all the statuses are set when using the Check Translations action.

File

tests/src/Functional/LingotekInterfaceTranslationTest.php, line 774

Class

LingotekInterfaceTranslationTest
Tests translating the user interface using the Lingotek form.

Namespace

Drupal\Tests\lingotek\Functional

Code

public function testCheckSourceStatusNotCompletedAndStillImporting() {

  // In Drupal.org CI the module will be at modules/contrib/lingotek.
  // In my local that's modules/lingotek. We need to generate the path and not
  // hardcode it.
  $path = drupal_get_path('module', 'lingotek_interface_translation_test');
  $component = $path;
  $indexOfModuleLink = 2;
  $assert_session = $this
    ->assertSession();

  // Login as admin.
  $this
    ->drupalLogin($this->rootUser);
  $this
    ->goToInterfaceTranslationManagementForm();
  $assert_session
    ->responseContains('lingotek_interface_translation_test');

  // Clicking English must init the upload of content.
  $this
    ->assertLingotekInterfaceTranslationUploadLink($component);
  $this
    ->clickLink('EN', $indexOfModuleLink);
  $assert_session
    ->responseContains('<em class="placeholder">' . $component . '</em> uploaded successfully');
  $this
    ->assertIdentical('en_US', \Drupal::state()
    ->get('lingotek.uploaded_locale'));

  // I can check current status.
  $this
    ->assertLingotekInterfaceTranslationCheckSourceStatusLink($component);

  // The document has not been imported yet.
  \Drupal::state()
    ->set('lingotek.document_status_completion', FALSE);
  $this
    ->clickLink('EN', $indexOfModuleLink);
  $this
    ->assertSourceStatus('EN', Lingotek::STATUS_IMPORTING);
  $this
    ->assertLingotekInterfaceTranslationCheckSourceStatusLink($component);
  $assert_session
    ->responseContains('The import for <em class="placeholder">' . $component . '</em> is still pending.');
}