public function AdminLoginPathRouteTest::testAdminRoute in Admin Login Path 2.x
Same name and namespace in other branches
- 8 tests/src/Functional/AdminLoginPathRouteTest.php \Drupal\Tests\admin_login_path\Functional\AdminLoginPathRouteTest::testAdminRoute()
Asserts that login routes are correctly marked as admin routes.
File
- tests/
src/ Functional/ AdminLoginPathRouteTest.php, line 30
Class
- AdminLoginPathRouteTest
- Tests the functionality of the Admin Login Path route subscriber.
Namespace
Drupal\Tests\admin_login_path\FunctionalCode
public function testAdminRoute() {
$login_routes = [
'user.login',
'user.register',
'user.pass',
'user.cancel_confirm',
'user.reset.login',
'user.reset',
'user.reset.form',
];
foreach ($login_routes as $route_name) {
$route = \Drupal::service('router.route_provider')
->getRouteByName($route_name);
$is_admin = \Drupal::service('router.admin_context')
->isAdminRoute($route);
$this
->assertTrue($is_admin, new FormattableMarkup('Admin route correctly marked for "@title" page.', [
'@title' => $route
->getDefault('_title'),
]));
}
}