You are here

protected function UserRegistrationPasswordUserRegisterForm::setUp in User registration password 8

Overrides BrowserTestBase::setUp

File

./UserRegistrationPasswordUserRegisterForm.php, line 26

Class

UserRegistrationPasswordUserRegisterForm
Functionality tests for User registration password module.

Namespace

Drupal\Tests\user_registrationpassword\Functional

Code

protected function setUp() {
  parent::setUp();
  $user_config = \Drupal::configFactory()
    ->getEditable('user.settings');
  $config = \Drupal::configFactory()
    ->getEditable('user_registrationpassword.settings');
  $user_config
    ->set('register', UserInterface::REGISTER_VISITORS)
    ->save();
  $config
    ->set('registration', UserRegistrationPassword::VERIFICATION_PASS)
    ->save();

  // Create a new user entity.
  $entity = \Drupal::entityTypeManager()
    ->getStorage('user')
    ->create([]);

  // Build a form object for the user: register form.
  $formObject = \Drupal::entityTypeManager()
    ->getFormObject('user', 'register')
    ->setEntity($entity);

  // Build the form.
  $this->registerForm = \Drupal::formBuilder()
    ->getForm($formObject);
}