You are here

public function BambooTwigSecurityTest::testHasPermission 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::testHasPermission()
  2. 8.2 tests/src/Functional/BambooTwigSecurityTest.php \Drupal\Tests\bamboo_twig\Functional\BambooTwigSecurityTest::testHasPermission()
  3. 8.3 tests/src/Functional/BambooTwigSecurityTest.php \Drupal\Tests\bamboo_twig\Functional\BambooTwigSecurityTest::testHasPermission()
  4. 8.4 tests/src/Functional/BambooTwigSecurityTest.php \Drupal\Tests\bamboo_twig\Functional\BambooTwigSecurityTest::testHasPermission()

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

File

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

Class

BambooTwigSecurityTest
Tests Security twig filters and functions.

Namespace

Drupal\Tests\bamboo_twig\Functional

Code

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