RouterPermissionTest.php in Drupal 9
File
core/modules/system/tests/src/Functional/Routing/RouterPermissionTest.php
View source
<?php
namespace Drupal\Tests\system\Functional\Routing;
use Drupal\Tests\BrowserTestBase;
class RouterPermissionTest extends BrowserTestBase {
protected static $modules = [
'router_test',
];
protected $defaultTheme = 'stark';
public function testPermissionAccess() {
$this
->drupalGet('router_test/test7');
$this
->assertSession()
->statusCodeEquals(403);
$this
->drupalGet('router_test/test8');
$this
->assertSession()
->statusCodeEquals(403);
$user = $this
->drupalCreateUser([
'access test7',
]);
$this
->drupalLogin($user);
$this
->drupalGet('router_test/test7');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->responseNotContains('Access denied');
$this
->assertSession()
->pageTextContains('test7text');
}
}