You are here

public function EntityLegalMethodsTestCase::testRedirectMethod in Entity Legal 7.2

Same name and namespace in other branches
  1. 7 tests/entity_legal.methods.test \EntityLegalMethodsTestCase::testRedirectMethod()

Redirection method test.

File

tests/entity_legal.methods.test, line 158
Test for defined methods in Entity Legal module.

Class

EntityLegalMethodsTestCase
Simpletest class for acceptance methods.

Code

public function testRedirectMethod() {
  $document = $this
    ->createDocument(TRUE, TRUE, array(
    'existing_users' => array(
      'require_method' => 'redirect',
    ),
  ));
  $this
    ->createDocumentVersion($document, TRUE);
  $account = $this
    ->createUserWithAcceptancePermissions($document);
  $this
    ->drupalLogin($account);
  $document_uri = entity_uri(ENTITY_LEGAL_DOCUMENT_ENTITY_NAME, $document);
  $document_path = $document_uri['path'];
  $this
    ->assertUrl($document_path, array(
    'query' => array(
      'destination' => 'user/' . $account->uid,
    ),
  ), 'User was redirected to legal document after login');
  $this
    ->drupalGet('');
  $this
    ->assertUrl($document_path, array(
    'query' => array(
      'destination' => 'node',
    ),
  ), 'User was forecefully redirected to legal document after navigation');
  $this
    ->drupalPost(NULL, array(
    'agree' => TRUE,
  ), 'Submit');
  $this
    ->drupalGet('');
  $this
    ->assertUrl('', array(), 'User is free to navigate the site after acceptance');
}