1 locale.test LocaleExportFunctionalTest::testExportTranslation()

Test exportation of translations.

File

core/modules/locale/tests/locale.test, line 1147
Tests for locale.module.

Class

LocaleExportFunctionalTest
Functional tests for the export of translation files.

Code

function testExportTranslation() {
  // First import some known translations.
  // This will also automatically enable the 'fr' language.
  $name = backdrop_tempnam('temporary://', "po_") . '.po';
  file_put_contents($name, $this->getPoFile());
  $this->backdropPost('admin/config/regional/translate/import', array(
    'langcode' => 'fr',
    'files[file]' => $name,
  ), t('Import'));
  backdrop_unlink($name);

  // Get the French translations.
  $this->backdropPost('admin/config/regional/translate/export', array(
    'langcode' => 'fr',
  ), t('Export'));

  // Ensure we have a translation file.
  $this->assertRaw('# French translation of Backdrop', 'Exported French translation file.');
  // Ensure our imported translations exist in the file.
  $this->assertRaw('msgstr "lundi"', 'French translations present in exported file.');
}