Import a single interface translation file.
$langcode: Langcode of the po file and language to import.
int $timestamp_difference: (optional) Timestamp offset, used to mock older or newer files.
stdClass A file object of type stdClass.
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;
}