You are here

public function RestrictIpAccessTest::testRedirectToLoginWhenBypassByRoleEnabled in Restrict IP 8.2

Same name and namespace in other branches
  1. 8 tests/src/Functional/RestrictIpAccessTest.php \Drupal\Tests\restrict_ip\Functional\RestrictIpAccessTest::testRedirectToLoginWhenBypassByRoleEnabled()
  2. 3.x tests/src/Functional/RestrictIpAccessTest.php \Drupal\Tests\restrict_ip\Functional\RestrictIpAccessTest::testRedirectToLoginWhenBypassByRoleEnabled()

File

tests/src/Functional/RestrictIpAccessTest.php, line 100

Class

RestrictIpAccessTest
@group restrict_ip

Namespace

Drupal\Tests\restrict_ip\Functional

Code

public function testRedirectToLoginWhenBypassByRoleEnabled() {
  $adminUser = $this
    ->drupalCreateUser([
    'administer restricted ip addresses',
    'access administration pages',
    'administer modules',
  ]);
  $this
    ->createArticleContentType();
  $this
    ->createArticle();
  $this
    ->drupalLogin($adminUser);
  $this
    ->drupalGet('admin/config/people/restrict_ip');
  $this
    ->assertStatusCodeEquals(200);
  $this
    ->checkCheckbox('#edit-allow-role-bypass');
  $this
    ->selectRadio('#edit-bypass-action-redirect-login-page');
  $this
    ->click('#edit-submit');
  $admin_role = $this
    ->createRole([
    'bypass ip restriction',
  ]);
  $adminUser
    ->addRole($admin_role);
  $this
    ->checkCheckbox('#edit-enable');
  $this
    ->click('#edit-submit');
  $this
    ->drupalLogout();
  $this
    ->drupalGet('node/1');
  $this
    ->assertElementExists('#edit-name');
}