public function AgreementCustomUnprivilegedUserTestCase::testAgreementDestination in Agreement 6.2
Same name and namespace in other branches
- 6 agreement.test \AgreementCustomUnprivilegedUserTestCase::testAgreementDestination()
- 7.2 agreement.test \AgreementCustomUnprivilegedUserTestCase::testAgreementDestination()
File
- ./
agreement.test, line 270 - Tests for Agreement module.
Class
Code
public function testAgreementDestination() {
// A) 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
// B) 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
// A) Agreement destination = blank
variable_set('agreement_success_destination', '');
variable_set('agreement_page_visibility_settings', 0);
variable_set('agreement_page_visibility_pages', '');
// Log in, open agreement, go to front page
$this
->unprivilegedUserLogin('/node');
$this
->isAgreementPage();
$this
->drupalGet('node/' . $this->node->nid);
$this
->isAgreementPage();
$this
->submitAgreementFormWithAgreeing($this->unprivileged_user->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
->drupalGet('/node');
$this
->isAgreementPage();
$this
->submitAgreementFormWithAgreeing($this->unprivileged_user->uid);
$this
->assertUrl('node/' . $this->node->nid, array(), t('User is redirected to original destination') . ' : ' . $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
variable_set('agreement_success_destination', 'node/1');
variable_set('agreement_page_visibility_settings', 0);
variable_set('agreement_page_visibility_pages', '');
// Log in, open agreement, go to node/1
$this
->unprivilegedUserLogin('/node');
$this
->isAgreementPage();
$this
->drupalGet('user/' . $this->unprivileged_user->uid . '/edit');
$this
->isAgreementPage();
$this
->submitAgreementFormWithAgreeing($this->unprivileged_user->uid);
$this
->assertUrl('node/1', array(), t('User is redirected to node 1') . ' : ' . $this
->getUrl());
// Log in, go somewhere other than front page, open agreement, go to node/1
$this
->unprivilegedUserLogin('user');
$this
->isAgreementPage();
$this
->drupalGet('user/' . $this->unprivileged_user->uid . '/edit');
$this
->isAgreementPage();
$this
->submitAgreementFormWithAgreeing($this->unprivileged_user->uid);
$this
->assertUrl('node/1', array(), t('User is redirected to node 1') . ' : ' . $this
->getUrl());
// TODO: Log in following password reset link, go somewhere other than front page, open agreement, go to user profile
}