class RouterPermissionTest
Same name in this branch
- 11.x core/modules/system/tests/src/Functional/Routing/RouterPermissionTest.php \Drupal\Tests\system\Functional\Routing\RouterPermissionTest
Same name and namespace in other branches
- 10 core/modules/system/tests/src/Functional/Routing/RouterPermissionTest.php \Drupal\Tests\system\Functional\Routing\RouterPermissionTest
- 9 core/modules/system/tests/src/Functional/Routing/RouterPermissionTest.php \Drupal\Tests\system\Functional\Routing\RouterPermissionTest
- 8.9.x core/modules/system/tests/src/Functional/Routing/RouterPermissionTest.php \Drupal\Tests\system\Functional\Routing\RouterPermissionTest
- main core/modules/system/tests/src/Functional/Routing/RouterPermissionTest.php \Drupal\Tests\system\Functional\Routing\RouterPermissionTest
- main core/modules/system/tests/src/Kernel/Routing/RouterPermissionTest.php \Drupal\Tests\system\Kernel\Routing\RouterPermissionTest
Function Tests for the routing permission system.
Attributes
#[Group('Routing')]
#[RunTestsInSeparateProcesses]
Hierarchy
- class \Drupal\KernelTests\KernelTestBase implements \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\Tests\DrupalTestCaseTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait, \Drupal\Tests\BrowserHtmlDebugTrait, \Drupal\Tests\HttpKernelUiHelperTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\system\Kernel\Routing\RouterPermissionTest uses \Drupal\Tests\user\Traits\UserCreationTrait extends \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of RouterPermissionTest
File
-
core/
modules/ system/ tests/ src/ Kernel/ Routing/ RouterPermissionTest.php, line 15
Namespace
Drupal\Tests\system\Kernel\RoutingView source
class RouterPermissionTest extends KernelTestBase {
use UserCreationTrait {
createUser as drupalCreateUser;
}
/**
* {@inheritdoc}
*/
protected static $modules = [
'router_test',
'system',
'user',
];
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$this->installEntitySchema('user');
}
/**
* Tests permission requirements on routes.
*/
public function testPermissionAccess() : void {
// Ensure 403 Access Denied for a route without permission.
$this->drupalGet('router_test/test7');
$this->assertSession()
->statusCodeEquals(403);
// Ensure 403 Access Denied by default if no access specified.
$this->drupalGet('router_test/test8');
$this->assertSession()
->statusCodeEquals(403);
$user = $this->drupalCreateUser([
'access test7',
]);
$this->setCurrentUser($user);
$this->drupalGet('router_test/test7');
$this->assertSession()
->statusCodeEquals(200);
$this->assertSession()
->responseNotContains('Access denied');
$this->assertSession()
->pageTextContains('test7text');
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.