You are here

function BirthdaysTestCase::setUp in Birthdays 6

Implementation of setUp().

Overrides DrupalWebTestCase::setUp

File

./birthdays.test, line 25
Tests for the Birthdays module.

Class

BirthdaysTestCase
@file Tests for the Birthdays module.

Code

function setUp() {
  parent::setUp('birthdays', 'profile');

  // Create users.
  $this->admin_user = $this
    ->drupalCreateUser(array(
    'administer site configuration',
    'access administration pages',
    'administer users',
    'administer permissions',
    'access birthdays',
  ));
  $this->web_user = $this
    ->drupalCreateUser(array(
    'access birthdays',
  ));
  $this
    ->drupalLogin($this->admin_user);

  // Add profile field.
  $field = array(
    'category' => $this
      ->randomName(8),
    'title' => $this
      ->randomName(8),
    'name' => 'profile_' . $this
      ->randomName(8),
    'required' => 1,
  );
  $this
    ->drupalPost('admin/user/profile/add/date', $field, t('Save field'));

  // Get profile field ID.
  $fid = db_result(db_query("SELECT fid FROM {profile_fields} WHERE name = '%s'", $field['name']));

  // Set profile field as birthdays field.
  $this
    ->drupalPost('admin/settings/birthdays', array(
    'birthdays_field_id' => $fid,
  ), t('Save configuration'));

  // Confirm that the field_id has been set
  $this
    ->assertEqual(variable_get('birthdays_field_id', NULL), $fid, t('Birthdays field has been set successfully'));
  $this->field = _birthdays_get_field(variable_get('birthdays_field_id', NULL));
  $this
    ->drupalLogout();
}