public function UserRegistrationPasswordAdmin::testRegistrationWithEmailVerificationAndPasswordAdmin in User registration password 8
Implements testRegistrationWithEmailVerificationAndPasswordAdmin().
File
- tests/
src/ Functional/ UserRegistrationPasswordAdmin.php, line 57
Class
- UserRegistrationPasswordAdmin
- Functionality tests for User registration password module.
Namespace
Drupal\Tests\user_registrationpassword\FunctionalCode
public function testRegistrationWithEmailVerificationAndPasswordAdmin() {
// Login with admin user.
$this
->drupalLogin($this->adminUser);
// Test the default options.
$this
->drupalGet('admin/config/people/accounts');
$edit_first = [
'user_register' => UserInterface::REGISTER_VISITORS,
'user_registrationpassword_registration' => UserRegistrationPassword::VERIFICATION_PASS,
];
$this
->drupalPostForm('admin/config/people/accounts', $edit_first, 'Save configuration');
// Load config.
$user_config = \Drupal::configFactory()
->get('user.settings');
// Variable verify_mail.
$this
->assertFalse($user_config
->get('verify_mail'), 'Variable verify_mail set correctly.');
// Variable notify.register_pending_approval.
$this
->assertFalse($user_config
->get('notify.register_pending_approval'), 'Variable notify.register_pending_approval set correctly.');
// Variable notify.register_no_approval_required.
$this
->assertFalse($user_config
->get('notify.register_no_approval_required'), 'Variable notify.register_no_approval_required set correctly.');
// Test the admin approval option.
$this
->drupalGet('admin/config/people/accounts');
$edit_second = [
'user_register' => UserInterface::REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL,
'user_registrationpassword_registration' => UserRegistrationPassword::VERIFICATION_PASS,
];
$this
->drupalPostForm('admin/config/people/accounts', $edit_second, 'Save configuration');
// Load config.
$user_config = \Drupal::configFactory()
->get('user.settings');
// Variable verify_mail.
$this
->assertTrue($user_config
->get('verify_mail'), 'Variable verify_mail set correctly.');
// Variable notify.register_pending_approval.
$this
->assertTrue($user_config
->get('notify.register_pending_approval'), 'Variable notify.register_pending_approval set correctly.');
// Variable notify.register_no_approval_required.
$this
->assertTrue($user_config
->get('notify.register_no_approval_required'), 'Variable notify.register_no_approval_required set correctly.');
// Test the admin only option.
$this
->drupalGet('admin/config/people/accounts');
$edit_third = [
'user_register' => UserInterface::REGISTER_ADMINISTRATORS_ONLY,
'user_registrationpassword_registration' => UserRegistrationPassword::VERIFICATION_PASS,
];
$this
->drupalPostForm('admin/config/people/accounts', $edit_third, 'Save configuration');
// Load config.
$user_config = \Drupal::configFactory()
->get('user.settings');
// Variable verify_mail.
$this
->assertTrue($user_config
->get('verify_mail'), 'Variable verify_mail set correctly.');
// Variable notify.register_pending_approval.
$this
->assertFalse($user_config
->get('notify.register_pending_approval'), 'Variable notify.register_pending_approval set correctly.');
// Variable notify.register_no_approval_required.
$this
->assertFalse($user_config
->get('notify.register_no_approval_required'), 'Variable notify.register_no_approval_required set correctly.');
}