ProfileTestCase::updateProfileField

7 profile.test ProfileTestCase::updateProfileField($fid, $type = 'textfield', $edit = array())

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.

File

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

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]', t('Found month selection field'));
    $this->assertField($form_name . '[day]', t('Found day selection field'));
    $this->assertField($form_name . '[year]', t('Found day selection field'));
  }
  else {
    $this->assertField($form_name, t('Found form named @name', array('@name' => $form_name)));
  }

  // Checking name.
  $this->assertText($title, t('Checking title for field %title', array('%title' => $title)));
  // Checking explanation.
  $this->assertText($edit['explanation'], t('Checking explanation for field %title', array('%title' => $title)));

  return array(
    'fid' => $fid, 
    'type' => $type, 
    'form_name' => $form_name, 
    'title' => $title, 
    'category' => $category,
  );
}
Login or register to post comments