You are here

public function BambooTwigSecurityTest::testHasRoles in Bamboo Twig 8.4

Same name in this branch
  1. 8.4 tests/src/Functional/BambooTwigSecurityTest.php \Drupal\Tests\bamboo_twig\Functional\BambooTwigSecurityTest::testHasRoles()
  2. 8.4 tests/src/Kernel/BambooTwigSecurityTest.php \Drupal\Tests\bamboo_twig\Kernel\BambooTwigSecurityTest::testHasRoles()
Same name and namespace in other branches
  1. 8.5 tests/src/Functional/BambooTwigSecurityTest.php \Drupal\Tests\bamboo_twig\Functional\BambooTwigSecurityTest::testHasRoles()

@covers Drupal\bamboo_twig_security\TwigExtension\Security::hasRoles

File

tests/src/Functional/BambooTwigSecurityTest.php, line 155

Class

BambooTwigSecurityTest
Tests Security twig filters and functions.

Namespace

Drupal\Tests\bamboo_twig\Functional

Code

public function testHasRoles() {
  $this
    ->drupalGet('/bamboo-twig-security');
  $this
    ->assertElementPresent('.test-security div.security-roles-current');
  $this
    ->assertElementContains('.test-security div.security-roles-current', 'FALSE');
  $this
    ->assertElementPresent('.test-security div.security-roles-admin');
  $this
    ->assertElementContains('.test-security div.security-roles-admin', 'TRUE');
  $this
    ->assertElementPresent('.test-security div.security-roles-user-none-or');
  $this
    ->assertElementContains('.test-security div.security-roles-user-none-or', 'FALSE');
  $this
    ->assertElementPresent('.test-security div.security-roles-user-none-and');
  $this
    ->assertElementContains('.test-security div.security-roles-user-none-and', 'FALSE');
  $this
    ->assertElementPresent('.test-security div.security-roles-nobody-or');
  $this
    ->assertElementContains('.test-security div.security-roles-nobody-or', 'FALSE');
  $this
    ->assertElementPresent('.test-security div.security-roles-nobody-and');
  $this
    ->assertElementContains('.test-security div.security-roles-nobody-and', 'FALSE');
  $this
    ->drupalLogin($this->admin_user);
  $this
    ->drupalGet('/bamboo-twig-security');
  $this
    ->assertElementPresent('.test-security div.security-roles-current');
  $this
    ->assertElementContains('.test-security div.security-roles-current', 'TRUE');
  $this
    ->assertElementPresent('.test-security div.security-roles-admin');
  $this
    ->assertElementContains('.test-security div.security-roles-admin', 'TRUE');
  $this
    ->assertElementPresent('.test-security div.security-roles-admin-or');
  $this
    ->assertElementContains('.test-security div.security-roles-admin-or', 'TRUE');
  $this
    ->assertElementPresent('.test-security div.security-roles-user-none-or');
  $this
    ->assertElementContains('.test-security div.security-roles-user-none-or', 'FALSE');
  $this
    ->assertElementPresent('.test-security div.security-roles-user-none-and');
  $this
    ->assertElementContains('.test-security div.security-roles-user-none-and', 'FALSE');
  $this
    ->assertElementPresent('.test-security div.security-roles-nobody-or');
  $this
    ->assertElementContains('.test-security div.security-roles-nobody-or', 'FALSE');
  $this
    ->assertElementPresent('.test-security div.security-roles-nobody-and');
  $this
    ->assertElementContains('.test-security div.security-roles-nobody-and', 'FALSE');
}