You are here

AgreementAccessDeniedRedirectTest.php in Agreement 3.0.x

Same filename and directory in other branches
  1. 8.2 tests/src/Functional/AgreementAccessDeniedRedirectTest.php

File

tests/src/Functional/AgreementAccessDeniedRedirectTest.php
View source
<?php

namespace Drupal\Tests\agreement\Functional;


/**
 * Tests that user is redirected when attempting to access privileged route.
 *
 * @group agreement
 */
class AgreementAccessDeniedRedirectTest extends AgreementTestBase {

  /**
   * The user account to test.
   *
   * @var \Drupal\user\Entity\User
   */
  protected $unprivilegedUser;

  /**
   * {@inheritdoc}
   */
  protected function setUp() : void {
    parent::setUp();
    $this->unprivilegedUser = $this
      ->createUnprivilegedUser();
  }

  /**
   * Asserts that the page is reached.
   */
  public function testAccessDeniedRedirect() {
    $this
      ->drupalLogin($this->unprivilegedUser);
    $this
      ->assertAgreementPage($this->agreement);
    $this
      ->drupalGet('/admin');
    $this
      ->assertAgreementPage($this->agreement);
  }

}

Classes

Namesort descending Description
AgreementAccessDeniedRedirectTest Tests that user is redirected when attempting to access privileged route.