You are here

public function WebformTestCase::setUp in Webform 7.3

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

Implements hook.

Overrides DrupalWebTestCase::setUp

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

File

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

Class

WebformTestCase

Code

public function setUp() {

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

  // Create a profile field to test %profile tokens.
  db_query("INSERT INTO {profile_field} (title, name, explanation, category, type, weight, required, register, visibility, autocomplete, options, page) VALUES ('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 webform content',
    'edit own webform content',
    'access all webform results',
  );

  // Create a webform admin that will do all node creation.
  $permissions['admin'] = array(
    'access content',
    'administer nodes',
    'create webform content',
    'edit any webform content',
    'access all webform results',
    'edit all webform submissions',
    'delete all webform submissions',
  );
  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');
  }
}