BambooTwigSecurityTest.php in Bamboo Twig 8.3
File
tests/src/Functional/BambooTwigSecurityTest.php
View source
<?php
namespace Drupal\Tests\bamboo_twig\Functional;
class BambooTwigSecurityTest extends BambooTwigTestBase {
public static $modules = [
'bamboo_twig',
'bamboo_twig_security',
'bamboo_twig_test',
'user',
];
public function setUp() {
parent::setUp();
$this->admin_user = $this
->drupalCreateUser([
'access content',
'administer content types',
'bypass node access',
'administer site configuration',
'view the administration theme',
'administer menu',
'access administration pages',
]);
}
public function testHasPermission() {
$this
->drupalGet('/bamboo-twig-security');
$this
->assertElementPresent('.test-security div.security-permission-current');
$this
->assertElementContains('.test-security div.security-permission-current', 'FALSE');
$this
->assertElementPresent('.test-security div.security-permission-admin');
$this
->assertElementContains('.test-security div.security-permission-admin', 'TRUE');
$this
->assertElementPresent('.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
->assertElementPresent('.test-security div.security-permission-current');
$this
->assertElementContains('.test-security div.security-permission-current', 'TRUE');
$this
->assertElementPresent('.test-security div.security-permission-admin');
$this
->assertElementContains('.test-security div.security-permission-admin', 'TRUE');
$this
->assertElementPresent('.test-security div.security-permission-nobody');
$this
->assertElementContains('.test-security div.security-permission-nobody', 'FALSE');
}
public function testHasRole() {
$this
->drupalGet('/bamboo-twig-security');
$this
->assertElementPresent('.test-security div.security-role-current');
$this
->assertElementContains('.test-security div.security-role-current', 'FALSE');
$this
->assertElementPresent('.test-security div.security-role-admin');
$this
->assertElementContains('.test-security div.security-role-admin', 'TRUE');
$this
->assertElementPresent('.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
->assertElementPresent('.test-security div.security-role-current');
$this
->assertElementContains('.test-security div.security-role-current', 'TRUE');
$this
->assertElementPresent('.test-security div.security-role-admin');
$this
->assertElementContains('.test-security div.security-role-admin', 'TRUE');
$this
->assertElementPresent('.test-security div.security-role-nobody');
$this
->assertElementContains('.test-security div.security-role-nobody', 'FALSE');
}
}