public function AgreementCustomUnprivilegedUserTestCase::testAgreementDestination in Agreement 7.2
Same name and namespace in other branches
- 6.2 agreement.test \AgreementCustomUnprivilegedUserTestCase::testAgreementDestination()
- 6 agreement.test \AgreementCustomUnprivilegedUserTestCase::testAgreementDestination()
Tests the agreement destination functionality.
1. Agreement destination = blank.
- user goes to regular get URL -> redirect to front.
- user goes to node/1 -> redirect to node/1.
- user needs to change password -> redirect to user/%/edit
2. Agreement destination = node/1.
- user goes to regular get URL -> redirect to node/1.
- user goes to user profile -> redirect to node/1.
- user needs to change password -> redirect to user/%/edit.
File
- ./
agreement.test, line 395 - Tests for Agreement module.
Class
- AgreementCustomUnprivilegedUserTestCase
- Tests the agreement functionality with custom settings.
Code
public function testAgreementDestination() {
// A) Agreement destination = blank.
$this->agreement['settings']['destination'] = '';
$this->agreement['settings']['visibility_settings'] = 0;
$this->agreement['settings']['visibility_pages'] = '';
agreement_type_save($this->agreement);
$this->agreement = agreement_type_load($this->agreement['name'], FALSE);
// Log in, open agreement, go to front page.
$this
->unprivilegedUserLogin('/node');
$this
->isAgreementPage($this->agreement);
$this
->drupalGet('node/' . $this->node->nid);
$this
->isAgreementPage($this->agreement);
$this
->submitAgreementFormWithAgreeing($this->unprivilegedUser->uid);
$this
->isFrontPage();
// Log in, go somewhere other than front page, open agreement, go to user's
// original destination.
$this
->unprivilegedUserLogin('/node/' . $this->node->nid);
$this
->isAgreementPage($this->agreement);
$this
->drupalGet('/node');
$this
->isAgreementPage($this->agreement);
$this
->submitAgreementFormWithAgreeing($this->unprivilegedUser->uid);
$this
->assertUrl('node/' . $this->node->nid, array(), t('User is redirected to original destination: !url', array(
'!url' => $this
->getUrl(),
)));
// @todo: Log in following password reset link, go somewhere other than
// front page, open agreement, go to user profile.
// B) Agreement destination = node/1.
$this->agreement['settings']['destination'] = 'node/1';
agreement_type_save($this->agreement);
$this->agreement = agreement_type_load($this->agreement['name']);
// Log in, open agreement, go to node/1.
$this
->unprivilegedUserLogin('/node');
$this
->isAgreementPage($this->agreement);
$this
->drupalGet('user/' . $this->unprivilegedUser->uid . '/edit');
$this
->isAgreementPage($this->agreement);
$this
->submitAgreementFormWithAgreeing($this->unprivilegedUser->uid);
$this
->assertUrl('node/1', array(), t('User is redirected to node 1: !url', array(
'!url' => $this
->getUrl(),
)));
// Log in, go somewhere other than front page, open agreement, go to node/1.
$this
->unprivilegedUserLogin('user');
$this
->isAgreementPage($this->agreement);
$this
->drupalGet('user/' . $this->unprivilegedUser->uid . '/edit');
$this
->isAgreementPage($this->agreement);
$this
->submitAgreementFormWithAgreeing($this->unprivilegedUser->uid);
$this
->assertUrl('node/1', array(), t('User is redirected to node 1: !url', array(
'!url' => $this
->getUrl(),
)));
// @todo: Log in following password reset link, go somewhere other than
// front page, open agreement, go to user profile.
}