PermissionsLockRestrictedTestCase.php in Permissions Lock 8
File
src/Tests/PermissionsLockRestrictedTestCase.php
View source
<?php
namespace Drupal\permissions_lock\Tests;
use Drupal\simpletest\WebTestBase;
class PermissionsLockRestrictedTestCase extends WebTestBase {
protected $profile = 'standard';
public static function getInfo() {
return [
'name' => 'Restricted',
'description' => 'Tests for restricted users',
'group' => 'Permissions lock',
];
}
public function setUp() {
parent::setUp('permissions_lock');
\Drupal::configFactory()
->getEditable('permissions_lock.settings')
->set('permissions_lock_locked_perm', array_combine([
'access site in maintenance mode',
], [
'access site in maintenance mode',
]))
->save();
\Drupal::configFactory()
->getEditable('permissions_lock.settings')
->set('permissions_lock_locked_roles', [
'2' => '2',
])
->save();
$restricted_user = $this
->drupalCreateUser([
'administer permissions',
]);
$this
->drupalLogin($restricted_user);
}
public function testRestrictedPermission() {
$this
->drupalGet('admin/people/permissions');
$this
->assertResponse(200, t('User has access to the administration page'));
$this
->assertNoText(t('Use the site in maintenance mode'));
}
public function testRestrictedRole() {
$this
->drupalGet('admin/people/permissions');
$this
->assertResponse(200, t('User has access to the administration page'));
$this
->assertNoText(t('authenticated user'));
}
}