You are here

function ProfileTestFields::testProfileFields in Drupal 7

Test each of the field types. List selection and date fields are tested separately because they need some special handling.

File

modules/profile/profile.test, line 180
Tests for profile.module.

Class

ProfileTestFields

Code

function testProfileFields() {
  $this
    ->drupalLogin($this->admin_user);

  // Set test values for every field type.
  $field_types = array(
    'textfield' => $this
      ->randomName(),
    'textarea' => $this
      ->randomName(),
    'list' => $this
      ->randomName(),
    'checkbox' => 1,
    // An underscore is an invalid character in a domain name. The method randomName can
    // return an underscore.
    'url' => 'http://www.' . str_replace('_', '', $this
      ->randomName(10)) . '.org',
  );

  // For each field type, create a field, give it a value, update the field,
  // and delete the field.
  foreach ($field_types as $type => $value) {
    $field = $this
      ->createProfileField($type);
    $this
      ->setProfileField($field, $value);
    $edit = array(
      'name' => $field['form_name'],
      'title' => $this
        ->randomName(),
      'category' => $field['category'],
      'explanation' => $this
        ->randomName(),
    );
    $field = $this
      ->updateProfileField($field['fid'], $field['type'], $edit);
    $this
      ->deleteProfileField($field);
  }
}