You are here

public function BambooTwigSecurityTest::testHasPermissions in Bamboo Twig 8.5

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

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

File

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

Class

BambooTwigSecurityTest
Tests Security twig filters and functions.

Namespace

Drupal\Tests\bamboo_twig\Functional

Code

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