function LocaleFileImportStatus::mockImportedPoFile

Import a single interface translation file.

Parameters

$langcode: Langcode of the po file and language to import.

int $timestamp_difference: (optional) Timestamp offset, used to mock older or newer files.

Return value

stdClass A file object of type stdClass.

2 calls to LocaleFileImportStatus::mockImportedPoFile()
LocaleFileImportStatus::testBulkImportNotUpdateExisting in drupal/core/modules/locale/lib/Drupal/locale/Tests/LocaleFileImportStatus.php
Don't update a pre-existing file.
LocaleFileImportStatus::testBulkImportUpdateExisting in drupal/core/modules/locale/lib/Drupal/locale/Tests/LocaleFileImportStatus.php
Update a pre-existing file.

File

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

Class

LocaleFileImportStatus
Functional tests for the import of translation files.

Namespace

Drupal\locale\Tests

Code

function mockImportedPoFile($langcode, $timestamp_difference = 0) {
  $testfile_uri = 'translations://test.' . $langcode . '.po';
  $file = locale_translate_file_create($testfile_uri);
  $file->original_timestamp = $file->timestamp;
  $file->timestamp = $file->timestamp + $timestamp_difference;
  $file->langcode = $langcode;

  // Fill the {locale_file} with a custom timestamp.
  if ($timestamp_difference != 0) {
    locale_translate_update_file_history($file);
  }
  $count = db_query('SELECT COUNT(*) FROM {locale_file} WHERE langcode = :langcode', array(
    ':langcode' => $langcode,
  ))
    ->fetchField();
  $this
    ->assertEqual(1, $count, format_plural($count, '@count file registered in {locale_file}.', '@count files registered in {locale_file}.'));
  $result = db_query('SELECT langcode, uri FROM {locale_file}')
    ->fetchAssoc();
  $this
    ->assertEqual($result['uri'], $testfile_uri, t('%uri is in {locale_file}.', array(
    '%uri' => $result['uri'],
  )));
  $this
    ->assertEqual($result['langcode'], $langcode, t('Langcode is %langcode.', array(
    '%langcode' => $langcode,
  )));
  return $file;
}