function TranslationTestCase::setUp

Sets up a Drupal site for running functional and integration tests.

Generates a random database prefix and installs Drupal with the specified installation profile in DrupalWebTestCase::$profile into the prefixed database. Afterwards, installs any additional modules specified by the test.

After installation all caches are flushed and several configuration values are reset to the values of the parent site executing the test, since the default values may be incompatible with the environment in which tests are being executed.


...: List of modules to enable for the duration of the test. This can be either a single array or a variable number of string arguments.

Overrides DrupalWebTestCase::setUp

See also





drupal/modules/translation/translation.test, line 22
Tests for the Translation module.


Functional tests for the Translation module.


function setUp() {
  parent::setUp('locale', 'translation', 'translation_test');

  // Setup users.
  $this->admin_user = $this
    'bypass node access',
    'administer nodes',
    'administer languages',
    'administer content types',
    'administer blocks',
    'access administration pages',
    'translate content',
  $this->translator = $this
    'create page content',
    'edit own page content',
    'translate content',

  // Add languages.

  // Disable Italian to test the translation behavior with disabled languages.
  $edit = array(
    'enabled[it]' => FALSE,
    ->drupalPost('admin/config/regional/language', $edit, t('Save configuration'));

  // Set "Basic page" content type to use multilingual support with
  // translation.
  $edit = array();
  $edit['language_content_type'] = 2;
    ->drupalPost('admin/structure/types/manage/page', $edit, t('Save content type'));
    ->assertRaw(t('The content type %type has been updated.', array(
    '%type' => 'Basic page',
  )), 'Basic page content type has been updated.');

  // Enable the language switcher block.
  $language_type = LANGUAGE_TYPE_INTERFACE;
  $edit = array(
    "blocks[locale_{$language_type}][region]" => 'sidebar_first',
    ->drupalPost('admin/structure/block', $edit, t('Save blocks'));

  // Enable URL language detection and selection to make the language switcher
  // block appear.
  $edit = array(
    'language[enabled][locale-url]' => TRUE,
    ->drupalPost('admin/config/regional/language/configure', $edit, t('Save settings'));
    ->assertRaw(t('Language negotiation configuration saved.'), 'URL language detection enabled.');