1 translation.test TranslationTestCase::setUp()

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

Generates a random database prefix and installs Backdrop with the specified installation profile in BackdropWebTestCase::$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.

Return value

bool: TRUE if set up completes, FALSE if an error occurred.

Overrides BackdropWebTestCase::setUp

See also





core/modules/translation/tests/translation.test, line 14
Tests for the Translation module.


Functional tests for the Translation module.


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

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


  // Add languages.

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

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

  // Enable the language switcher block.
  $language_type = LANGUAGE_TYPE_INTERFACE;
  $layout = layout_load('default');
  $layout->addBlock('locale', $language_type, 'sidebar');

  // Reset static caches in our local language environment.