function TranslationTest::setUp

Same name in this branch

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 Drupal\simpletest\WebTestBase::$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.

Parameters

...: 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 WebTestBase::setUp

See also

Drupal\simpletest\WebTestBase::prepareDatabasePrefix()

Drupal\simpletest\WebTestBase::changeDatabasePrefix()

Drupal\simpletest\WebTestBase::prepareEnvironment()

File

drupal/core/modules/translation/lib/Drupal/translation/Tests/TranslationTest.php, line 37
Definition of Drupal\translation\Tests\TranslationTest.

Class

TranslationTest
Functional tests for the Translation module.

Namespace

Drupal\translation\Tests

Code

function setUp() {
  parent::setUp();

  // Setup users.
  $this->admin_user = $this
    ->drupalCreateUser(array(
    'bypass node access',
    'administer nodes',
    'administer languages',
    'administer content types',
    'administer blocks',
    'access administration pages',
    'translate all content',
  ));
  $this->translator = $this
    ->drupalCreateUser(array(
    'create page content',
    'edit own page content',
    'translate all content',
  ));
  $this->limited_translator = $this
    ->drupalCreateUser(array(
    'create page content',
    'edit own page content',
    'translate own content',
  ));
  $this
    ->drupalLogin($this->admin_user);

  // Add languages.
  $this
    ->addLanguage('en');
  $this
    ->addLanguage('es');

  // Set "Basic page" content type to use multilingual support with
  // translation.
  $this
    ->drupalGet('admin/structure/types/manage/page');
  $edit = array(
    'language_configuration[language_hidden]' => FALSE,
    'node_type_language_translation_enabled' => TRUE,
  );
  $this
    ->drupalPost('admin/structure/types/manage/page', $edit, t('Save content type'));
  $this
    ->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[language_{$language_type}][region]" => 'sidebar_first',
  );
  $this
    ->drupalPost('admin/structure/block', $edit, t('Save blocks'));

  // Reset static caches in our local language environment.
  $this
    ->resetCaches();
  $this
    ->drupalLogin($this->translator);
}