function LocaleUpdateTest::assertTranslation

Checks the translation of a string.

Parameters

string $source: Translation source string

string $translation: Translation to check. Use empty string to check for a not existing translation.

string $langcode: Language code of the language to translate to.

string $message: (optional) A message to display with the assertion.

3 calls to LocaleUpdateTest::assertTranslation()
LocaleUpdateTest::testEnableDisableLanguage in drupal/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateTest.php
Tests automatic translation import when a langauge is enabled.
LocaleUpdateTest::testEnableDisableModule in drupal/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateTest.php
Tests automatic translation import when a module is enabled.
LocaleUpdateTest::testUpdateImportModeNone in drupal/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateTest.php
Tests translation import with a translations directory and don't overwrite any translation.

File

drupal/core/modules/locale/lib/Drupal/locale/Tests/LocaleUpdateTest.php, line 308
Contains Drupal\locale\Tests\LocaleUpdateTest.

Class

LocaleUpdateTest
Tests for update translations.

Namespace

Drupal\locale\Tests

Code

function assertTranslation($source, $translation, $langcode, $message = '') {
  $db_translation = db_query('SELECT translation FROM {locales_target} lt INNER JOIN {locales_source} ls ON ls.lid = lt.lid WHERE ls.source = :source AND lt.language = :langcode', array(
    ':source' => $source,
    ':langcode' => $langcode,
  ))
    ->fetchField();
  $db_translation = $db_translation == FALSE ? '' : $db_translation;
  $this
    ->assertEqual($translation, $db_translation, $message ? $message : format_string('Correct translation of %source (%language)', array(
    '%source' => $source,
    '%language' => $langcode,
  )));
}