PermissionsLockUnrestrictedTestCase.php in Permissions Lock 8
File
src/Tests/PermissionsLockUnrestrictedTestCase.php
View source
<?php
namespace Drupal\permissions_lock\Tests;
use Drupal\simpletest\WebTestBase;
class PermissionsLockUnrestrictedTestCase extends WebTestBase {
protected $profile = 'standard';
public static function getInfo() {
return [
'name' => 'Unrestricted',
'description' => 'Tests for unrestricted 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();
$unrestricted_user = $this
->drupalCreateUser([
'administer permissions',
'manage permissions unrestricted',
]);
$this
->drupalLogin($unrestricted_user);
}
public function testUnrestrictedPermission() {
$this
->drupalGet('admin/people/permissions');
$this
->assertResponse(200, $this
->t('User has access to the administration page'));
$this
->assertText(t('Use the site in maintenance mode'));
}
public function testUnrestrictedRole() {
$this
->drupalGet('admin/people/permissions');
$this
->assertResponse(200, $this
->t('User has access to the administration page'));
$this
->assertText(t('authenticated user'));
}
}