AdminLoginPathRouteTest.php in Admin Login Path 2.x
File
tests/src/Functional/AdminLoginPathRouteTest.php
View source
<?php
namespace Drupal\Tests\admin_login_path\Functional;
use Drupal\Tests\BrowserTestBase;
use Drupal\Component\Render\FormattableMarkup;
class AdminLoginPathRouteTest extends BrowserTestBase {
protected $defaultTheme = 'stark';
public static $modules = [
'admin_login_path',
];
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'),
]));
}
}
}