You are here

public function AgreementCustomUnprivilegedUserTestCase::testAgreementDestination in Agreement 6

Same name and namespace in other branches
  1. 6.2 agreement.test \AgreementCustomUnprivilegedUserTestCase::testAgreementDestination()
  2. 7.2 agreement.test \AgreementCustomUnprivilegedUserTestCase::testAgreementDestination()

File

./agreement.test, line 267
Tests for the Agreement module

Class

AgreementCustomUnprivilegedUserTestCase

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
  $this
    ->privilegedUserLogin();
  $this
    ->drupalGet('admin/settings/agreement');
  $settings = array();
  $settings['agreement_success_destination'] = '';
  $settings['agreement_page_visibility_settings'] = 0;
  $settings['agreement_page_visibility_pages'] = '';
  $this
    ->configureAgreementSettings($settings);

  // Log in, open agreement, go to front page
  $this
    ->unprivilegedUserLogin('/node');
  $this
    ->isAgreementPage();
  $this
    ->drupalGet('node/' . $this->node->uid);
  $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->uid);
  $this
    ->isAgreementPage();
  $this
    ->drupalGet('/node');
  $this
    ->isAgreementPage();
  $this
    ->submitAgreementFormWithAgreeing($this->unprivileged_user->uid);
  $this
    ->assertEqual($this->base_url . '/node/' . $this->node->uid, $this
    ->getURL(), t('User is redirected to original destination') . ' : ' . $this
    ->getUrl());

  // Log in following password reset link, go somewhere other than front page, open agreement, go to user profile

  /*
  $this->drupalLogin($this->unprivileged_user);
  $this->drupalGet('node');
  $this->isAgreementPage();
  $this->drupalGet('admin');
  $this->isAgreementPage();
  $this->submitAgreementFormWithAgreeing($this->unprivileged_user->uid);
  $this->isUserProfilePage($this->unprivileged_user->uid);
  */

  // B) Agreement destination = node/1
  $this
    ->privilegedUserLogin();
  $this
    ->drupalGet('admin/settings/agreement');
  $settings = array();
  $settings['agreement_success_destination'] = 'node/1';
  $settings['agreement_page_visibility_settings'] = 0;
  $settings['agreement_page_visibility_pages'] = '';
  $this
    ->configureAgreementSettings($settings);

  // 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
    ->assertEqual($this->base_url . '/node/1', $this
    ->getURL(), 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
    ->assertEqual($this->base_url . '/node/1', $this
    ->getURL(), t('User is redirected to node 1') . ' : ' . $this
    ->getUrl());

  // Log in following password reset link, go somewhere other than front page, open agreement, go to user profile

  /*
  $this->drupalLogin($this->unprivileged_user);
  $this->drupalGet('node');
  $this->isAgreementPage();
  $this->drupalGet('admin');
  $this->isAgreementPage();
  $this->submitAgreementFormWithAgreeing($this->unprivileged_user->uid);
  $this->isUserProfileEditPage($this->unprivileged_user->uid);
  */
}