You are here

public function BambooTwigSecurityTest::testHasRole in Bamboo Twig 8.5

Same name and namespace in other branches
  1. 8 tests/src/Functional/BambooTwigSecurityTest.php \Drupal\Tests\bamboo_twig\Functional\BambooTwigSecurityTest::testHasRole()
  2. 8.2 tests/src/Functional/BambooTwigSecurityTest.php \Drupal\Tests\bamboo_twig\Functional\BambooTwigSecurityTest::testHasRole()
  3. 8.3 tests/src/Functional/BambooTwigSecurityTest.php \Drupal\Tests\bamboo_twig\Functional\BambooTwigSecurityTest::testHasRole()
  4. 8.4 tests/src/Functional/BambooTwigSecurityTest.php \Drupal\Tests\bamboo_twig\Functional\BambooTwigSecurityTest::testHasRole()

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

File

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

Class

BambooTwigSecurityTest
Tests Security twig filters and functions.

Namespace

Drupal\Tests\bamboo_twig\Functional

Code

public function testHasRole() {
  $this
    ->drupalGet('/bamboo-twig-security');
  $this
    ->assertSession()
    ->elementExists('css', '.test-security div.security-role-current');
  $this
    ->assertElementContains('.test-security div.security-role-current', 'FALSE');
  $this
    ->assertSession()
    ->elementExists('css', '.test-security div.security-role-admin');
  $this
    ->assertElementContains('.test-security div.security-role-admin', 'TRUE');
  $this
    ->assertSession()
    ->elementExists('css', '.test-security div.security-role-nobody');
  $this
    ->assertElementContains('.test-security div.security-role-nobody', 'FALSE');
  $this
    ->drupalLogin($this->admin_user);
  $this
    ->drupalGet('/bamboo-twig-security');
  $this
    ->assertSession()
    ->elementExists('css', '.test-security div.security-role-current');
  $this
    ->assertElementContains('.test-security div.security-role-current', 'TRUE');
  $this
    ->assertSession()
    ->elementExists('css', '.test-security div.security-role-admin');
  $this
    ->assertElementContains('.test-security div.security-role-admin', 'TRUE');
  $this
    ->assertSession()
    ->elementExists('css', '.test-security div.security-role-nobody');
  $this
    ->assertElementContains('.test-security div.security-role-nobody', 'FALSE');
}