You are here

protected function LocaleUpdateBase::assertTranslation in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/locale/src/Tests/LocaleUpdateBase.php \Drupal\locale\Tests\LocaleUpdateBase::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 LocaleUpdateBase::assertTranslation()
LocaleUpdateTest::testEnableLanguage in core/modules/locale/src/Tests/LocaleUpdateTest.php
Tests automatic translation import when a language is added.
LocaleUpdateTest::testEnableUninstallModule in core/modules/locale/src/Tests/LocaleUpdateTest.php
Tests automatic translation import when a module is enabled.
LocaleUpdateTest::testUpdateImportModeNone in core/modules/locale/src/Tests/LocaleUpdateTest.php
Tests translation import and don't overwrite any translation.

File

core/modules/locale/src/Tests/LocaleUpdateBase.php, line 303
Contains \Drupal\locale\Tests\LocaleUpdateBase.

Class

LocaleUpdateBase
Base class for testing updates to string translations.

Namespace

Drupal\locale\Tests

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