function LocaleFileImportStatus::testBulkImportUpdateExisting

Update a pre-existing file.

File

drupal/core/modules/locale/lib/Drupal/locale/Tests/LocaleFileImportStatus.php, line 131
Definition of Drupal\locale\Tests\LocaleFileImportStatus.

Class

LocaleFileImportStatus
Functional tests for the import of translation files.

Namespace

Drupal\locale\Tests

Code

function testBulkImportUpdateExisting() {
  $langcode = 'de';

  // Translations should not exist.
  $strings = array(
    'Monday' => '',
    'Tuesday' => '',
  );
  $this
    ->checkTranslations($strings, $langcode);

  // Fill the {locale_file} table with an older file.
  $file = $this
    ->mockImportedPoFile($langcode, -1);

  // Add language.
  $this
    ->addLanguage($langcode);

  // The file was imported, translations should exist.
  $strings = array(
    'Monday' => 'Montag',
    'Tuesday' => 'Dienstag',
  );
  $this
    ->checkTranslations($strings, $langcode);
  $timestamp = db_query('SELECT timestamp FROM {locale_file} WHERE uri = :uri', array(
    ':uri' => $file->uri,
  ))
    ->fetchField();

  // Ensure that $timestamp is now greater than the manipulated timestamp.
  $this
    ->assertTrue($timestamp > $file->timestamp, 'Timestamp on locale_file updated.');
}