PermissionsTest.php in Devel PHP 8
File
tests/src/Functional/PermissionsTest.php
View source
<?php
declare (strict_types=1);
namespace Drupal\Tests\devel_php\Functional;
use Drupal\Core\Url;
use Drupal\Tests\BrowserTestBase;
class PermissionsTest extends BrowserTestBase {
protected $defaultTheme = 'stark';
public static $modules = [
'devel',
'devel_php',
];
public function testPermissionToExecuteCode() {
$url = Url::fromRoute('devel_php.execute_php');
$this
->drupalGet($url);
$this
->assertSession()
->statusCodeEquals(403);
$user = $this
->drupalCreateUser();
$this
->drupalLogin($user);
$this
->drupalGet($url);
$this
->assertSession()
->statusCodeEquals(403);
$user = $this
->drupalCreateUser([
'execute php code',
]);
$this
->drupalLogin($user);
$this
->drupalGet($url);
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->elementExists('xpath', "//form[@id='devel-execute-form']");
}
}