You are here

public function LingotekDashboardTest::testTranslationsAvailable in Lingotek Translation 3.6.x

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/LingotekDashboardTest.php \Drupal\Tests\lingotek\Functional\LingotekDashboardTest::testTranslationsAvailable()
  2. 4.0.x tests/src/Functional/LingotekDashboardTest.php \Drupal\Tests\lingotek\Functional\LingotekDashboardTest::testTranslationsAvailable()
  3. 3.0.x tests/src/Functional/LingotekDashboardTest.php \Drupal\Tests\lingotek\Functional\LingotekDashboardTest::testTranslationsAvailable()
  4. 3.1.x tests/src/Functional/LingotekDashboardTest.php \Drupal\Tests\lingotek\Functional\LingotekDashboardTest::testTranslationsAvailable()
  5. 3.2.x tests/src/Functional/LingotekDashboardTest.php \Drupal\Tests\lingotek\Functional\LingotekDashboardTest::testTranslationsAvailable()
  6. 3.3.x tests/src/Functional/LingotekDashboardTest.php \Drupal\Tests\lingotek\Functional\LingotekDashboardTest::testTranslationsAvailable()
  7. 3.4.x tests/src/Functional/LingotekDashboardTest.php \Drupal\Tests\lingotek\Functional\LingotekDashboardTest::testTranslationsAvailable()
  8. 3.5.x tests/src/Functional/LingotekDashboardTest.php \Drupal\Tests\lingotek\Functional\LingotekDashboardTest::testTranslationsAvailable()
  9. 3.7.x tests/src/Functional/LingotekDashboardTest.php \Drupal\Tests\lingotek\Functional\LingotekDashboardTest::testTranslationsAvailable()
  10. 3.8.x tests/src/Functional/LingotekDashboardTest.php \Drupal\Tests\lingotek\Functional\LingotekDashboardTest::testTranslationsAvailable()

Tests that there is a message when there are UI translations available.

File

tests/src/Functional/LingotekDashboardTest.php, line 581

Class

LingotekDashboardTest
Tests the Lingotek dashboard.

Namespace

Drupal\Tests\lingotek\Functional

Code

public function testTranslationsAvailable() {

  // Add a language.
  ConfigurableLanguage::createFromLangcode('es')
    ->setThirdPartySetting('lingotek', 'locale', 'es_MX')
    ->save();

  // One language added, there are missing translations.
  $this
    ->drupalGet('admin/lingotek');
  $this
    ->assertRaw(t('Missing translations for: @languages. See the <a href=":updates">Available translation updates</a> page for more information.', [
    '@languages' => t('Spanish'),
    ':updates' => Url::fromRoute('locale.translate_status')
      ->toString(),
  ]), 'Missing translations message');

  // Override Drupal core translation status as 'up-to-date'.
  $status = locale_translation_get_status();
  $status['drupal']['es'] = new \stdClass();
  $status['drupal']['es']->type = 'current';
  \Drupal::keyValue('locale.translation_status')
    ->set('drupal', $status['drupal']);

  // There are no missing translations, translations are current.
  $this
    ->drupalGet('admin/lingotek');
  $this
    ->assertNoRaw(t('Missing translations for: @languages. See the <a href=":updates">Available translation updates</a> page for more information.', [
    '@languages' => t('Spanish'),
    ':updates' => Url::fromRoute('locale.translate_status')
      ->toString(),
  ]), 'No missing translations message with current translations');

  // Set lingotek module to have a local translation available.
  $status = locale_translation_get_status();
  $status['lingotek']['es'] = new \stdClass();
  $status['lingotek']['es']->type = 'local';
  \Drupal::keyValue('locale.translation_status')
    ->set('lingotek', $status['lingotek']);

  // There are no missing translations, translations are local.
  $this
    ->drupalGet('admin/lingotek');
  $this
    ->assertNoRaw(t('Missing translations for: @languages. See the <a href=":updates">Available translation updates</a> page for more information.', [
    '@languages' => t('Spanish'),
    ':updates' => Url::fromRoute('locale.translate_status')
      ->toString(),
  ]), 'No missing translations message with local translations');
}