UserRegistrationPasswordAdmin.php in User registration password 8
File
tests/src/Functional/UserRegistrationPasswordAdmin.php
View source
<?php
namespace Drupal\Tests\user_registrationpassword\Functional;
use Drupal\Tests\BrowserTestBase;
use Drupal\user\UserInterface;
use Drupal\user_registrationpassword\UserRegistrationPassword;
class UserRegistrationPasswordAdmin extends BrowserTestBase {
protected $defaultTheme = 'stark';
public static $modules = [
'user_registrationpassword',
];
protected $adminUser;
protected $regularUser;
protected function setUp() {
parent::setUp();
$this->adminUser = $this
->drupalCreateUser([
'administer account settings',
'administer users',
]);
$this->regularUser = $this
->drupalCreateUser();
}
public function testRegistrationWithEmailVerificationAndPasswordAdmin() {
$this
->drupalLogin($this->adminUser);
$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');
$user_config = \Drupal::configFactory()
->get('user.settings');
$this
->assertFalse($user_config
->get('verify_mail'), 'Variable verify_mail set correctly.');
$this
->assertFalse($user_config
->get('notify.register_pending_approval'), 'Variable notify.register_pending_approval set correctly.');
$this
->assertFalse($user_config
->get('notify.register_no_approval_required'), 'Variable notify.register_no_approval_required set correctly.');
$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');
$user_config = \Drupal::configFactory()
->get('user.settings');
$this
->assertTrue($user_config
->get('verify_mail'), 'Variable verify_mail set correctly.');
$this
->assertTrue($user_config
->get('notify.register_pending_approval'), 'Variable notify.register_pending_approval set correctly.');
$this
->assertTrue($user_config
->get('notify.register_no_approval_required'), 'Variable notify.register_no_approval_required set correctly.');
$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');
$user_config = \Drupal::configFactory()
->get('user.settings');
$this
->assertTrue($user_config
->get('verify_mail'), 'Variable verify_mail set correctly.');
$this
->assertFalse($user_config
->get('notify.register_pending_approval'), 'Variable notify.register_pending_approval set correctly.');
$this
->assertFalse($user_config
->get('notify.register_no_approval_required'), 'Variable notify.register_no_approval_required set correctly.');
}
}