protected function L10nUpdateTestBase::setTranslationFiles in Localization update 7.2
Setup the environment containing local and remote translation files.
Update tests require a simulated environment for local and remote files. Normally remote files are located at a remote server (e.g. ftp.drupal.org). For testing we can not rely on this. A directory in the file system of the test site is designated for remote files and is addressed using an absolute URL. Because Drupal does not allow files with a po extension to be accessed (denied in .htaccess) the translation files get a _po extension. Another directory is designated for local translation files.
The environment is set up with the following files. File creation times are set to create different variations in test conditions. contrib_module_one
- remote file: timestamp new
- local file: timestamp old
- current: timestamp medium
contrib_module_two
- remote file: timestamp old
- local file: timestamp new
- current: timestamp medium
contrib_module_three
- remote file: timestamp old
- local file: timestamp old
- current: timestamp medium
custom_module_one
- local file: timestamp new
- current: timestamp medium
Time stamp of current translation set by setCurrentTranslations() is always timestamp medium. This makes it easy to predict which translation will be imported.
6 calls to L10nUpdateTestBase::setTranslationFiles()
- L10nUpdateCronTest::testUpdateCron in tests/
L10nUpdateCronTest.test - Tests interface translation update using cron.
- L10nUpdateTest::testUpdateCheckStatus in tests/
L10nUpdateTest.test - Checks if local or remote translation sources are detected.
- L10nUpdateTest::testUpdateImportModeNonCustomized in tests/
L10nUpdateTest.test - Tests translation import and only overwrite non-customized translations.
- L10nUpdateTest::testUpdateImportModeNone in tests/
L10nUpdateTest.test - Tests translation import and don't overwrite any translation.
- L10nUpdateTest::testUpdateImportSourceLocal in tests/
L10nUpdateTest.test - Tests translation import from local sources.
File
- tests/
L10nUpdateTestBase.test, line 156 - Contains L10nUpdateTest.
Class
- L10nUpdateTestBase
- Tests for update translations.
Code
protected function setTranslationFiles() {
// A flag is set to let the l10n_update_test module replace the project data
// with a set of test projects which match the below project files.
variable_set('l10n_update_test_projects_alter', TRUE);
// Setup the environment.
$public_path = drupal_realpath('public://');
$this
->setTranslationsDirectory($public_path . '/local');
variable_set('l10n_update_default_filename', '%project-%release.%language._po');
// Setting up sets of translations for the translation files.
$translations_one = array(
'January' => 'Januar_1',
'February' => 'Februar_1',
'March' => 'Marz_1',
);
$translations_two = array(
'February' => 'Februar_2',
'March' => 'Marz_2',
'April' => 'April_2',
);
$translations_three = array(
'April' => 'April_3',
'May' => 'Mai_3',
'June' => 'Juni_3',
);
// Add a number of files to the local file system to serve as remote
// translation server and match the project definitions set in
// l10n_update_test_l10n_update_projects_alter().
$this
->makePoFile('remote/7.x/contrib_module_one', 'contrib_module_one-7.x-1.1.de._po', $this->timestamp_new, $translations_one);
$this
->makePoFile('remote/7.x/contrib_module_two', 'contrib_module_two-7.x-2.0-beta4.de._po', $this->timestamp_old, $translations_two);
$this
->makePoFile('remote/7.x/contrib_module_three', 'contrib_module_three-7.x-1.0.de._po', $this->timestamp_old, $translations_three);
// Add a number of files to the local file system to serve as local
// translation files and match the project definitions set in
// l10n_update_test_l10n_update_projects_alter().
$this
->makePoFile('local', 'contrib_module_one-7.x-1.1.de._po', $this->timestamp_old, $translations_one);
$this
->makePoFile('local', 'contrib_module_two-7.x-2.0-beta4.de._po', $this->timestamp_new, $translations_two);
$this
->makePoFile('local', 'contrib_module_three-7.x-1.0.de._po', $this->timestamp_old, $translations_three);
$this
->makePoFile('local', 'custom_module_one.de.po', $this->timestamp_new);
}