protected function RedirectTest::setUp in Login And Logout Redirect Per Role 8
Overrides BrowserTestBase::setUp
File
- tests/
src/ Functional/ RedirectTest.php, line 63
Class
- RedirectTest
- Tests redirects after login and logout.
Namespace
Drupal\Tests\login_redirect_per_role\FunctionalCode
protected function setUp() : void {
parent::setUp();
$role1 = $this
->drupalCreateRole([]);
$role2 = $this
->drupalCreateRole([]);
$role3 = $this
->drupalCreateRole([]);
$role4 = $this
->drupalCreateRole([]);
$this->user1 = $this
->createUser([], NULL, FALSE, [
'roles' => $role1,
]);
$this->user2 = $this
->createUser([], NULL, FALSE, [
'roles' => $role2,
]);
$this->user3 = $this
->createUser([], NULL, FALSE, [
'roles' => $role3,
]);
$this->user4 = $this
->createUser([], NULL, FALSE, [
'roles' => $role4,
]);
$this
->config('login_redirect_per_role.settings')
->set("login.{$role1}", [
'allow_destination' => TRUE,
'redirect_url' => '/login-url-role1',
'weight' => 0,
])
->set("logout.{$role1}", [
'allow_destination' => TRUE,
'redirect_url' => '/logout-url-role1',
'weight' => 0,
])
->set("login.{$role2}", [
'allow_destination' => FALSE,
'redirect_url' => '/login-url-role2',
'weight' => 0,
])
->set("logout.{$role2}", [
'allow_destination' => FALSE,
'redirect_url' => '/logout-url-role2',
'weight' => 0,
])
->set("login.{$role3}", [
'allow_destination' => FALSE,
'redirect_url' => '[site:valid-path]',
'weight' => 0,
])
->set("logout.{$role3}", [
'allow_destination' => FALSE,
'redirect_url' => '[site:invalid-path]',
'weight' => 0,
])
->set("login.{$role4}", [
'allow_destination' => FALSE,
'redirect_url' => '<front>',
'weight' => 0,
])
->set("logout.{$role4}", [
'allow_destination' => FALSE,
'redirect_url' => '<front>',
'weight' => 0,
])
->save();
$this->state = $this->container
->get('state');
}