You are here

function WebformTestCase::setUp in Webform 6.2

Same name and namespace in other branches
  1. 6.3 tests/webform.test \WebformTestCase::setUp()
  2. 7.4 tests/WebformTestCase.test \WebformTestCase::setUp()
  3. 7.3 tests/webform.test \WebformTestCase::setUp()

Implementation of setUp().

Overrides DrupalWebTestCase::setUp

3 calls to WebformTestCase::setUp()
WebformComponentsTestCase::setUp in tests/components.test
Implementation of setUp().
WebformPermissionsTestCase::setUp in tests/permissions.test
Implementation of setUp().
WebformSubmissionTestCase::setUp in tests/submission.test
Implementation of setUp().
3 methods override WebformTestCase::setUp()
WebformComponentsTestCase::setUp in tests/components.test
Implementation of setUp().
WebformPermissionsTestCase::setUp in tests/permissions.test
Implementation of setUp().
WebformSubmissionTestCase::setUp in tests/submission.test
Implementation of setUp().

File

tests/webform.test, line 27
Webform module tests.

Class

WebformTestCase
@file Webform module tests.

Code

function setUp() {

  // Enable Webform.
  parent::setUp('webform', 'profile');

  // Create a profile field to test %profile tokens.
  db_query("INSERT INTO {profile_fields} (title, name, explanation, category, type, weight, required, register, visibility, autocomplete, options, page) VALUES ('%s', '%s', '%s', '%s', '%s', %d, %d, %d, %d, %d, '%s', '%s')", 'Gender', 'profile_gender', '', 'Profile', 'textfield', 0, 0, 0, 2, 0, '', '');

  // Create a normal user that can view their own submissions.
  $permissions['userAccess'] = array(
    'access content',
    'access own webform submissions',
  );

  // Create a normal user than can edit their own submissions.
  $permissions['userEdit'] = array(
    'access content',
    'edit own webform submissions',
  );

  // Create a webform editor to test creating and editing own content.
  $permissions['editor'] = array(
    'access content',
    'create webforms',
    'edit own webforms',
    'access webform results',
  );

  // Create a webform admin that will do all node creation.
  $permissions['admin'] = array(
    'access content',
    'administer nodes',
    'create webforms',
    'edit webforms',
    'edit webform submissions',
    'access webform results',
    'clear webform results',
  );
  foreach ($permissions as $user_key => $role_permissions) {
    $this->webform_users[$user_key] = $this
      ->drupalCreateUser($role_permissions);
    $profile = array(
      'profile_gender' => 'Female',
    );
    $this->webform_users[$user_key]->profile_gender = 'Female';
    profile_save_profile($profile, $this->webform_users[$user_key], 'Profile');
  }
}