You are here

protected function L10nUpdateTestBase::assertTranslation in Localization update 7.2

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 L10nUpdateTestBase::assertTranslation()
L10nUpdateTest::testEnableLanguage in tests/L10nUpdateTest.test
Tests automatic translation import when a langauge is enabled.
L10nUpdateTest::testEnableUninstallModule in tests/L10nUpdateTest.test
Tests automatic translation import when a module is enabled.
L10nUpdateTest::testUpdateImportModeNone in tests/L10nUpdateTest.test
Tests translation import and don't overwrite any translation.

File

tests/L10nUpdateTestBase.test, line 281
Contains L10nUpdateTest.

Class

L10nUpdateTestBase
Tests for update translations.

Code

protected 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,
  )));
}