public function SiteDisclaimerSettingsTestCase::testSiteDisclaimerBasic in Site Disclaimer 7        
                          
                  
                        Same name and namespace in other branches
- 6 tests/site_disclaimer.test \SiteDisclaimerSettingsTestCase::testSiteDisclaimerBasic()
 
 
File
 
   - tests/site_disclaimer.test, line 89
 
  - Site Disclaimer module functionality tests.
 
  Class
  
  - SiteDisclaimerSettingsTestCase 
 
  - Test for all simple settings.
 
Code
public function testSiteDisclaimerBasic() {
  
  $edit = array(
    'site_disclaimer_node_title' => $this->node->title,
    'site_disclaimer_checkbox_label' => $this->label,
    'site_disclaimer_title' => $this->title,
    'site_disclaimer_version_details' => $this
      ->randomName(),
  );
  $this
    ->drupalPost(TEST_SITE_DISCLAIMER_SETTINGS_PATH, $edit, t('Save configuration'));
  $this
    ->assertFieldByName('site_disclaimer_node_title', $edit['site_disclaimer_node_title'], 'Node set.');
  $this
    ->assertFieldByName('site_disclaimer_checkbox_label', $edit['site_disclaimer_checkbox_label'], 'Label name set.');
  $this
    ->assertFieldByName('site_disclaimer_title', $edit['site_disclaimer_title'], 'Title set.');
  $this
    ->drupalLogout();
  
  $this
    ->drupalGet('user/register');
  $this
    ->assertRaw(filter_xss_admin($edit['site_disclaimer_checkbox_label']), 'Checkbox label found.');
  $this
    ->assertRaw(check_plain($edit['site_disclaimer_title']), 'Title found.');
  $this
    ->assertRaw($this->body, 'Terms node body text found.');
  $this
    ->assertNoRaw(filter_xss_admin($edit['site_disclaimer_version_details']), 'Site Disclaimer version details not found');
  
  $this
    ->drupalPost('user/register', array(), t('Create new account'));
  $this
    ->assertRaw(t('!name field is required.', array(
    '!name' => filter_xss_admin($edit['site_disclaimer_checkbox_label']),
  )), 'Checkbox label found, required.');
  
  
  $edit = array();
  $edit['name'] = $name = $this
    ->randomName();
  $edit['mail'] = $mail = $this
    ->randomName() . '@example.com';
  $edit['I_agree'] = TRUE;
  $edit['pass[pass1]'] = $pass = $this
    ->randomName();
  $edit['pass[pass2]'] = $pass;
  $this
    ->drupalPost('user/register', $edit, t('Create new account'));
  
  $this
    ->assertText(t('Registration successful. You are now logged in.'), t('Users are logged in after registering.'));
  $this
    ->drupalLogout();
  
  $auth = array(
    'name' => $name,
    'pass' => $pass,
  );
  
  $this
    ->drupalPost('user/login', $auth, t('Log in'));
  $this
    ->assertText(t('Member for'), t('User can log in.'));
  $this
    ->drupalLogout();
  
  $this
    ->drupalLogin($this->admin_user);
  $edit = array(
    'site_disclaimer_checkbox_label' => $this->label_link,
  );
  $label_raw = str_replace('@link', l($this->node->title, 'node/' . $this->node->nid), filter_xss_admin($edit['site_disclaimer_checkbox_label']));
  $this
    ->drupalPost(TEST_SITE_DISCLAIMER_SETTINGS_PATH, $edit, t('Save configuration'));
  $this
    ->assertFieldByName('site_disclaimer_checkbox_label', $edit['site_disclaimer_checkbox_label'], 'Label name with @link set.');
  $this
    ->drupalLogout();
  
  $this
    ->drupalGet('user/register');
  $this
    ->assertRaw($label_raw, 'Checkbox label found.');
  $this
    ->assertNoRaw($this->body, 'Terms node body text not found.');
  
  $this
    ->drupalLogin($this->admin_user);
  $edit = array(
    'site_disclaimer_checkbox_label' => $this->label_link,
    'site_disclaimer_version' => 2,
    'site_disclaimer_version_details' => $this
      ->randomName(),
  );
  $label_raw = str_replace('@link', l($this->node->title, 'node/' . $this->node->nid), filter_xss_admin($edit['site_disclaimer_checkbox_label']));
  $this
    ->drupalPost(TEST_SITE_DISCLAIMER_SETTINGS_PATH, $edit, t('Save configuration'));
  $this
    ->assertFieldByName('site_disclaimer_checkbox_label', $edit['site_disclaimer_checkbox_label'], 'Label name with @link set.');
  
  
  debug('Inspect site_disclaimer_allow_nodes=' . print_r(variable_get('site_disclaimer_allow_nodes', array()), 1));
  $this
    ->drupalLogout();
  
  $auth = array(
    'name' => $name,
    'pass' => $pass,
  );
  $this
    ->drupalPost('user/login', $auth, t('Log in'));
  $this
    ->assertNoText(t('Member for'), t('User log in incomplete.'));
  $this
    ->assertRaw(filter_xss_admin($edit['site_disclaimer_version_details']), 'Site Disclaimer version details found');
  $this
    ->assertRaw($label_raw, 'Checkbox label found.');
  
  $this
    ->clickLink($this->node->title);
  $this
    ->assertRaw($this->body, 'Site Disclaimer node found');
  
  $this
    ->clickLink($this->node1->title);
  $this
    ->assertRaw($this->body1, 'node linked from Site Disclaimer node found');
  
  $this
    ->drupalGet('');
  $this
    ->assertRaw(filter_xss_admin($edit['site_disclaimer_version_details']), 'Site Disclaimer version details found');
  $this
    ->assertRaw($label_raw, 'Checkbox label found.');
  
  $edit = array(
    'I_agree' => TRUE,
  );
  $this
    ->drupalPost(NULL, $edit, t('Continue'));
  $this
    ->assertText(t('Log out'), t('User can log in.'));
  $this
    ->assertText(t('My account'), t('User can log in.'));
  $this
    ->drupalLogout();
  
  
}