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.

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.

Return value

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

Overrides BackdropWebTestCase::setUp

See also

BackdropWebTestCase::prepareDatabasePrefix()

BackdropWebTestCase::changeDatabasePrefix()

BackdropWebTestCase::prepareEnvironment()

File

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

Class

TranslationTestCase
Functional tests for the Translation module.

Code

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'));

  $this->backdropLogin($this->admin_user);

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

  // 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.
  $this->backdropGet('admin/structure/types/manage/page');
  $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');
  $layout->save();

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

  $this->backdropLogin($this->translator);
}