public function AgreementMultipleTestCase::testAgreement in Agreement 7.2
Tests that multiple agreements can function independently.
File
- ./
agreement.test, line 500 - Tests for Agreement module.
Class
- AgreementMultipleTestCase
- Tests multiple agreement functionality.
Code
public function testAgreement() {
$page_title = $this
->randomString(10);
$page_text = $this
->randomString(50);
$settings = array(
'name' => 'new_agreement',
'type' => 'New Agreement',
'path' => 'new-agreement',
'settings[title]' => $page_title,
'agreement[value]' => $page_text,
'settings[visibility_settings]' => 1,
'settings[visibility_pages]' => 'node/' . $this->node->nid,
);
$this
->drupalPost('admin/config/people/agreement/add', $settings, t('Save configuration'));
$this
->assertText('Agreement type ' . $settings['type'] . ' saved successfully.', t('Second agreement created successfully.'));
// The static cache needs to be reset here as this is a different request.
$new_agreement = agreement_type_load($settings['name'], FALSE);
// Go to front page, no agreement.
$this
->drupalGet('node');
$this
->isNotAgreementPage($this->agreement);
$this
->isNotAgreementpage($new_agreement);
// Go anywhere else, open agreement.
$this
->drupalGet('admin');
$this
->isAgreementPage($this->agreement);
$this
->isNotAgreementPage($new_agreement);
// Agreement with visibility settings for all pages displays instead of
// agreement with explicity visibility page settings.
$this
->drupalGet('node/' . $this->node->nid);
$this
->isAgreementPage($this->agreement);
$this
->isNotAgreementPage($new_agreement);
// Accept the agreement.
$edit = array(
'agree' => 1,
);
$this
->drupalPost(NULL, $edit, t('Submit'));
$this
->isNotAgreementPage($this->agreement);
// Go to the node again, which is second agreement page.
$this
->drupalGet('node/' . $this->node->nid);
$this
->isAgreementPage($new_agreement);
$this
->isNotAgreementPage($this->agreement);
// Accept the second agreement.
$this
->drupalPost(NULL, $edit, $new_agreement['settings']['submit']);
$this
->isNotAgreementPage($new_agreement);
$this
->isNotAgreementPage($this->agreement);
// Remove the second agreement.
$this
->drupalLogin($this->privilegedUser);
$this
->drupalPost('admin/config/people/agreement/manage/' . $settings['name'] . '/delete', array(), t('Confirm'));
$agreement_type_delete_success = 'Successfully deleted agreement type, ' . $settings['type'];
$this
->assertText($agreement_type_delete_success, 'Found agreement type deleted message.');
}