protected function RedirectTest::register in Login Destination 8.2
Same name and namespace in other branches
- 8 tests/src/Functional/RedirectTest.php \Drupal\Tests\login_destination\Functional\RedirectTest::register()
Registers a new user.
Parameters
string $password: (optional) The password for the new user.
Return value
\Drupal\user\Entity\User The user that was registered.
2 calls to RedirectTest::register()
- RedirectTest::testNoRedirectAfterRegistering in tests/
src/ Functional/ RedirectTest.php - Tests no redirect after registering in without compatible destination rule.
- RedirectTest::testRedirectAfterRegistering in tests/
src/ Functional/ RedirectTest.php - Tests redirecting after registering without email verification.
File
- tests/
src/ Functional/ RedirectTest.php, line 90
Class
- RedirectTest
- Tests redirects.
Namespace
Drupal\Tests\login_destination\FunctionalCode
protected function register($password = NULL) {
$name = $this
->randomMachineName();
$mail = $name . '@example.com';
$edit = [
'name' => $name,
'mail' => $mail,
];
if ($password) {
$edit += [
'pass[pass1]' => $password,
'pass[pass2]' => $password,
];
}
$this
->drupalPostForm('user/register', $edit, 'Create new account');
$storage = $this->container
->get('entity_type.manager')
->getStorage('user');
$storage
->resetCache();
$accounts = $storage
->loadByProperties([
'name' => $name,
'mail' => $mail,
]);
$new_user = reset($accounts);
return $new_user;
}