You are here

public function UrlRedirectNegateTest::testUserNegation in Url Redirect 8

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/UrlRedirectNegateTest.php \Drupal\Tests\url_redirect\Functional\UrlRedirectNegateTest::testUserNegation()

File

tests/src/Functional/UrlRedirectNegateTest.php, line 122

Class

UrlRedirectNegateTest
Tests the negation option for user and role redirect condition.

Namespace

Drupal\Tests\url_redirect\Functional

Code

public function testUserNegation() {

  // Add User redirect with negation.
  $this
    ->drupalLogin($this->adminUser);
  $this
    ->addUrlRedirect($this->sourcePath, $this->destPath, 'User', [
    $this->userOne
      ->getUsername(),
  ], '1', 'No', '1');

  // Confirm user one is not redirected.
  $this
    ->drupalLogin($this->userOne);
  $this
    ->drupalGet($this->sourcePath);
  $this
    ->assertSession()
    ->addressNotEquals($this->destPath);

  // Confirm user two is redirected.
  $this
    ->drupalLogin($this->userTwo);
  $this
    ->drupalGet($this->sourcePath);
  $this
    ->assertSession()
    ->addressNotEquals($this->destPath);
}