You are here

function Drupali18nTestCase::setUp in Internationalization 6

Generates a random database prefix, runs the install scripts on the prefixed database and enable the specified modules. After installation many caches are flushed and the internal browser is setup so that the page requests will run on the new prefix. A temporary files directory is created with the same name as the database prefix.

Parameters

...: List of modules to enable for the duration of the test.

Overrides DrupalWebTestCase::setUp

4 calls to Drupali18nTestCase::setUp()
i18n_API_Tests::setUp in tests/i18n_api.test
Generates a random database prefix, runs the install scripts on the prefixed database and enable the specified modules. After installation many caches are flushed and the internal browser is setup so that the page requests will run on the new prefix.…
i18n_Blocks_Test::setUp in tests/i18n_blocks.test
Generates a random database prefix, runs the install scripts on the prefixed database and enable the specified modules. After installation many caches are flushed and the internal browser is setup so that the page requests will run on the new prefix.…
i18n_Strings_Test::setUp in tests/i18n_strings.test
Generates a random database prefix, runs the install scripts on the prefixed database and enable the specified modules. After installation many caches are flushed and the internal browser is setup so that the page requests will run on the new prefix.…
i18n_Taxonomy_Test::setUp in tests/i18n_taxonomy.test
Generates a random database prefix, runs the install scripts on the prefixed database and enable the specified modules. After installation many caches are flushed and the internal browser is setup so that the page requests will run on the new prefix.…
4 methods override Drupali18nTestCase::setUp()
i18n_API_Tests::setUp in tests/i18n_api.test
Generates a random database prefix, runs the install scripts on the prefixed database and enable the specified modules. After installation many caches are flushed and the internal browser is setup so that the page requests will run on the new prefix.…
i18n_Blocks_Test::setUp in tests/i18n_blocks.test
Generates a random database prefix, runs the install scripts on the prefixed database and enable the specified modules. After installation many caches are flushed and the internal browser is setup so that the page requests will run on the new prefix.…
i18n_Strings_Test::setUp in tests/i18n_strings.test
Generates a random database prefix, runs the install scripts on the prefixed database and enable the specified modules. After installation many caches are flushed and the internal browser is setup so that the page requests will run on the new prefix.…
i18n_Taxonomy_Test::setUp in tests/i18n_taxonomy.test
Generates a random database prefix, runs the install scripts on the prefixed database and enable the specified modules. After installation many caches are flushed and the internal browser is setup so that the page requests will run on the new prefix.…

File

tests/drupal_i18n_test_case.php, line 90

Class

Drupali18nTestCase
Test case for typical Drupal tests.

Code

function setUp() {
  global $db_prefix, $user, $language;

  // $language (Drupal 6).
  global $install_locale;

  // Store necessary current values before switching to prefixed database.
  $this->db_prefix_original = $db_prefix;
  $clean_url_original = variable_get('clean_url', 0);

  // Generate temporary prefixed database to ensure that tests have a clean starting point.
  $db_prefix = 'simpletest' . mt_rand(1000, 1000000);
  include_once './includes/install.inc';
  drupal_install_system();

  // Add the specified modules to the list of modules in the default profile.
  $args = func_get_args();

  // Add language and basic i18n modules
  $install_locale = $this->install_locale;
  $i18n_modules = array(
    'locale',
    'translation',
    'i18n',
    'i18n_test',
  );
  $modules = array_unique(array_merge(drupal_verify_profile('default', $this->install_locale), $args, $i18n_modules));
  drupal_install_modules($modules);

  // Install locale
  if ($this->install_locale != 'en') {
    $this
      ->addLanguage($this->install_locale, TRUE);
  }

  // Run default profile tasks.
  $task = 'profile';
  default_profile_tasks($task, '');

  // Rebuild caches.
  actions_synchronize();
  _drupal_flush_css_js();
  $this
    ->refreshVariables();
  $this
    ->checkPermissions(array(), TRUE);
  user_access(NULL, NULL, TRUE);

  // Drupal 6.
  // Log in with a clean $user.
  $this->originalUser = $user;

  //    drupal_save_session(FALSE);
  //    $user = user_load(1);
  session_save_session(FALSE);
  $user = user_load(array(
    'uid' => 1,
  ));

  // Restore necessary variables.
  variable_set('install_profile', 'default');
  variable_set('install_task', 'profile-finished');
  variable_set('clean_url', $clean_url_original);
  variable_set('site_mail', 'simpletest@example.com');

  // Use temporary files directory with the same prefix as database.
  $this->originalFileDirectory = file_directory_path();
  variable_set('file_directory_path', file_directory_path() . '/' . $db_prefix);
  $directory = file_directory_path();

  // Create the files directory.
  file_check_directory($directory, FILE_CREATE_DIRECTORY | FILE_MODIFY_PERMISSIONS);
  set_time_limit($this->timeLimit);

  // Some more includes
  require_once 'includes/language.inc';

  // Refresh theme
  $this
    ->initTheme();

  // Set path languages so we can retrieve pages in different languages
  variable_set('language_negotiation', LANGUAGE_NEGOTIATION_PATH);
}