You are here

function WebformLocalizationWebTestCase::setUp in Webform Localization 7

Same name and namespace in other branches
  1. 7.4 tests/webform_localization.test \WebformLocalizationWebTestCase::setUp()

Implements setUp().

Overrides DrupalWebTestCase::setUp

2 calls to WebformLocalizationWebTestCase::setUp()
WebformLocalizationApiTestCase::setUp in tests/webform_localization.test
Set up test.
WebformLocalizationStringTranslationTestCase::setUp in tests/webform_localization.test
Set up test.
2 methods override WebformLocalizationWebTestCase::setUp()
WebformLocalizationApiTestCase::setUp in tests/webform_localization.test
Set up test.
WebformLocalizationStringTranslationTestCase::setUp in tests/webform_localization.test
Set up test.

File

tests/webform_localization.test, line 21
Webform localization module tests.

Class

WebformLocalizationWebTestCase
@file Webform localization module tests.

Code

function setUp($added_modules = array()) {

  // Enable Webform and Token module if available.
  $drupalorg = TRUE;
  if (module_exists('webform_localization') || $drupalorg) {
    $added_modules = array_merge(array(
      'webform_localization',
    ), $added_modules);
  }
  if (module_exists('webform') || $drupalorg) {
    $added_modules = array_merge(array(
      'webform',
    ), $added_modules);
  }
  if (module_exists('token') || $drupalorg) {
    $added_modules = array_merge(array(
      'token',
    ), $added_modules);
  }
  if (module_exists('views') || $drupalorg) {
    $added_modules = array_merge(array(
      'views',
    ), $added_modules);
  }
  if (module_exists('ctools') || $drupalorg) {
    $added_modules = array_merge(array(
      'ctools',
    ), $added_modules);
  }
  if (module_exists('i18n_translation') || $drupalorg) {
    $added_modules = array_merge(array(
      'i18n_translation',
    ), $added_modules);
  }
  if (module_exists('i18n_string') || $drupalorg) {
    $added_modules = array_merge(array(
      'i18n_string',
    ), $added_modules);
  }
  if (module_exists('i18n') || $drupalorg) {
    $added_modules = array_merge(array(
      'i18n',
    ), $added_modules);
  }
  if (module_exists('variable') || $drupalorg) {
    $added_modules = array_merge(array(
      'variable',
    ), $added_modules);
  }
  if (module_exists('translation') || $drupalorg) {
    $added_modules = array_merge(array(
      'translation',
    ), $added_modules);
  }
  if (module_exists('locale') || $drupalorg) {
    $added_modules = array_merge(array(
      'locale',
    ), $added_modules);
  }
  if (module_exists('block') || $drupalorg) {
    $added_modules = array_merge(array(
      'block',
    ), $added_modules);
  }

  //debug($added_modules);
  parent::setUp($added_modules);

  // We load webform test class to reuse webform and components creation functions.
  module_load_include('test', 'webform', 'tests/webform');
  $this->wtc = new WebformTestCase();

  /* Reset the permissions cache prior to calling drupalCreateUser
   * see notes here: https://api.drupal.org/comment/28739#comment-28739
   */

  //  drupal_flush_all_caches();
  $this
    ->checkPermissions(array(), TRUE);

  // Setup users.
  $this->adminuser = $this
    ->drupalCreateUser(array(
    'bypass node access',
    'administer nodes',
    'administer languages',
    'administer content types',
    'administer blocks',
    'access administration pages',
    'translate content',
    'create webform content',
    'edit any webform content',
    'access all webform results',
    'edit all webform submissions',
    'delete all webform submissions',
    'translate interface',
    'translate user-defined strings',
  ));

  /* Reset the permissions cache prior to calling drupalCreateUser
   * see notes here: https://api.drupal.org/comment/28739#comment-28739
   */
  $this
    ->checkPermissions(array(
    'access content',
  ), TRUE);
  $this->translator = $this
    ->drupalCreateUser(array(
    'translate content',
    'create webform content',
    'edit any webform content',
    'access all webform results',
    'translate interface',
    'translate user-defined strings',
  ));

  /* Reset the permissions cache prior to calling drupalCreateUser
   * see notes here: https://api.drupal.org/comment/28739#comment-28739
   */
  $this
    ->checkPermissions(array(
    'access content',
  ), TRUE);
  $this->normaluser = $this
    ->drupalCreateUser(array(
    'access content',
    'edit own webform submissions',
  ));

  // Fix for reuse of webform test class.
  $this->wtc->webform_users['admin'] = $this->adminuser;
  $this->wtc->webform_users['admin']->profile_gender = array(
    'Female',
    'Male',
  );
  $this
    ->drupalLogin($this->adminuser);

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

  // Enable URL language detection and selection.
  $edit = array(
    'language[enabled][locale-url]' => TRUE,
  );
  $this
    ->drupalPost('admin/config/regional/language/configure', $edit, t('Save settings'));
  $this
    ->assertRaw(t('Language negotiation configuration saved.'), 'URL language detection enabled.');
  drupal_static_reset('locale_url_outbound_alter');
}