You are here

public function TOUSettingsTestCase::testTOUBasic in Terms of Use 6

File

tests/terms_of_use.test, line 56
Terms of use module functionality tests.

Class

TOUSettingsTestCase
Test for all simple settings.

Code

public function testTOUBasic() {
  $edit = array(
    'terms_of_use_node_title' => $this->node->title,
    'terms_of_use_checkbox_label' => $this->lable,
    'terms_of_use_fieldset_name' => $this->fieldset,
  );
  $this
    ->drupalPost('admin/settings/terms_of_use', $edit, t('Save configuration'));
  $this
    ->assertFieldByName('terms_of_use_node_title', $this->node->title, 'Node set.');
  $this
    ->assertFieldByName('terms_of_use_checkbox_label', $this->lable, 'Lable name set.');
  $this
    ->assertFieldByName('terms_of_use_fieldset_name', $this->fieldset, 'Fieldset name set.');
  $this
    ->drupalLogout();
  $this
    ->drupalGet('user/register');
  $this
    ->assertRaw(filter_xss_admin($this->lable), 'Checkbox lable found.');
  $this
    ->assertRaw(filter_xss($this->fieldset), 'Fieldset name found.');
  $this
    ->assertText($this->body, 'Terms node body text found.');
  $this
    ->drupalPost('user/register', array(), t('Create new account'));
  $this
    ->assertRaw(t('You must agree with the !terms to get an account.', array(
    '!terms' => filter_xss($this->fieldset),
  )), 'Checkbox lable found.');
  $edit = array(
    'name' => $this
      ->randomName(),
    'mail' => $this
      ->randomName() . '@example.com',
    'terms_of_use' => TRUE,
  );
  $this
    ->drupalPost('user/register', $edit, t('Create new account'));
  $this
    ->assertText(t('Your password and further instructions have been sent to your e-mail address.'), 'Account creation successfull.');
  $this
    ->drupalLogin($this->admin_user);
  $edit = array(
    'terms_of_use_checkbox_label' => $this->lable_link,
  );
  $this
    ->drupalPost('admin/settings/terms_of_use', $edit, t('Save configuration'));
  $this
    ->assertFieldByName('terms_of_use_checkbox_label', $this->lable_link, 'Lable name with @link set.');
  $this
    ->drupalLogout();
  $this
    ->drupalGet('user/register');
  $replaced_lable = str_replace('@link', l($this->node->title, 'node/' . $this->node->nid), filter_xss_admin($this->lable_link));
  $this
    ->assertRaw($replaced_lable, 'Checkbox lable found.');
  $this
    ->assertNoText($this->body, 'Terms node body text not found.');
}