function ProfileTestCase::setProfileField

Set the profile field to a random value

Parameters

$field: The field that should be set.

$value: The value for the field, defaults to a random string.

Return value

The value that has been assigned to

6 calls to ProfileTestCase::setProfileField()
ProfileBlockTestCase::setUp in modules/profile/profile.test
Sets up a Drupal site for running functional and integration tests.
ProfileTestAutocomplete::testAutocomplete in modules/profile/profile.test
Tests profile field autocompletion and access.
ProfileTestBrowsing::testProfileBrowsing in modules/profile/profile.test
Test profile browsing.
ProfileTestFields::testProfileFields in modules/profile/profile.test
Test each of the field types. List selection and date fields are tested separately because they need some special handling.
ProfileTestSelect::testProfileSelectionField in modules/profile/profile.test
Create a list selection field, give it a value, update and delete the field.

... See full list

File

modules/profile/profile.test, line 131

Class

ProfileTestCase
A class for common methods for testing profile fields.

Code

function setProfileField($field, $value = NULL) {
  if (!isset($value)) {
    $value = $this->randomName();
  }
  $edit = array(
    $field['form_name'] => $value,
  );
  $this->drupalPost('user/' . $this->normal_user->uid . '/edit/' . $field['category'], $edit, t('Save'));
  // Check profile page.
  $content = $this->drupalGet('user/' . $this->normal_user->uid);
  $this->assertText($field['title'], format_string('Found profile field with title %title', array(
    '%title' => $field['title'],
  )));
  if ($field['type'] != 'checkbox') {
    // $value must be cast to a string in order to be found by assertText.
    $this->assertText("{$value}", format_string('Found profile field with value %value', array(
      '%value' => $value,
    )));
  }
  return $value;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.