File

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

Class

ProfileBlockTestCase

Code

function testAuthorInformationBlock() {

  // Set the block to a region to confirm the block is available.
  $edit = array();
  $edit['blocks[profile_author-information][region]'] = 'footer';
  $this
    ->drupalPost('admin/structure/block', $edit, t('Save blocks'));
  $this
    ->assertText(t('The block settings have been updated.'), 'Block successfully move to footer region.');

  // Enable field 1.
  $this
    ->drupalPost('admin/structure/block/manage/profile/author-information/configure', array(
    'profile_block_author_fields[' . $this->field1['form_name'] . ']' => TRUE,
  ), t('Save block'));
  $this
    ->assertText(t('The block configuration has been saved.'), 'Block configuration set.');

  // Visit the node and confirm that the field is displayed.
  $this
    ->drupalGet('node/' . $this->node->nid);
  $this
    ->assertRaw($this->value1, 'Field 1 is displayed');
  $this
    ->assertNoRaw($this->value2, 'Field 2 is not displayed');

  // Enable only field 2.
  $this
    ->drupalPost('admin/structure/block/manage/profile/author-information/configure', array(
    'profile_block_author_fields[' . $this->field1['form_name'] . ']' => FALSE,
    'profile_block_author_fields[' . $this->field2['form_name'] . ']' => TRUE,
  ), t('Save block'));
  $this
    ->assertText(t('The block configuration has been saved.'), 'Block configuration set.');

  // Visit the node and confirm that the field is displayed.
  $this
    ->drupalGet('node/' . $this->node->nid);
  $this
    ->assertNoRaw($this->value1, 'Field 1 is not displayed');
  $this
    ->assertRaw($this->value2, 'Field 2 is displayed');

  // Enable both fields.
  $this
    ->drupalPost('admin/structure/block/manage/profile/author-information/configure', array(
    'profile_block_author_fields[' . $this->field1['form_name'] . ']' => TRUE,
    'profile_block_author_fields[' . $this->field2['form_name'] . ']' => TRUE,
  ), t('Save block'));
  $this
    ->assertText(t('The block configuration has been saved.'), 'Block configuration set.');

  // Visit the node and confirm that the field is displayed.
  $this
    ->drupalGet('node/' . $this->node->nid);
  $this
    ->assertRaw($this->value1, 'Field 1 is displayed');
  $this
    ->assertRaw($this->value2, 'Field 2 is displayed');

  // Enable the link to the user profile.
  $this
    ->drupalPost('admin/structure/block/manage/profile/author-information/configure', array(
    'profile_block_author_fields[user_profile]' => TRUE,
  ), t('Save block'));
  $this
    ->assertText(t('The block configuration has been saved.'), 'Block configuration set.');

  // Visit the node and confirm that the user profile link is displayed.
  $this
    ->drupalGet('node/' . $this->node->nid);
  $this
    ->clickLink(t('View full user profile'));
  $this
    ->assertEqual($this
    ->getUrl(), url('user/' . $this->normal_user->uid, array(
    'absolute' => TRUE,
  )));
}