You are here

function ProfileTestCase::updateProfileField in Drupal 7

Update a profile field.

Parameters

$fid: The fid of the field to be updated.

$type: The type of field to be updated.

$edit: Field parameters to be submitted.

Return value

Array representation of the updated field.

3 calls to ProfileTestCase::updateProfileField()
ProfileTestDate::testProfileDateField in modules/profile/profile.test
Create a date field, give it a value, update and delete the field.
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.

File

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

Class

ProfileTestCase
A class for common methods for testing profile fields.

Code

function updateProfileField($fid, $type = 'textfield', $edit = array()) {
  $form_name = $edit['name'];
  $title = $edit['title'];
  $category = $edit['category'];
  $this
    ->drupalPost('admin/config/people/profile/edit/' . $fid, $edit, t('Save field'));

  // Check that the updated field is appearing on the user edit form.
  $this
    ->drupalGet('user/' . $this->admin_user->uid . '/edit/' . $category);

  // Checking field.
  if ($type == 'date') {
    $this
      ->assertField($form_name . '[month]', 'Found month selection field');
    $this
      ->assertField($form_name . '[day]', 'Found day selection field');
    $this
      ->assertField($form_name . '[year]', 'Found day selection field');
  }
  else {
    $this
      ->assertField($form_name, format_string('Found form named @name', array(
      '@name' => $form_name,
    )));
  }

  // Checking name.
  $this
    ->assertText($title, format_string('Checking title for field %title', array(
    '%title' => $title,
  )));

  // Checking explanation.
  $this
    ->assertText($edit['explanation'], format_string('Checking explanation for field %title', array(
    '%title' => $title,
  )));
  return array(
    'fid' => $fid,
    'type' => $type,
    'form_name' => $form_name,
    'title' => $title,
    'category' => $category,
  );
}