Commit 16005119 authored by webchick's avatar webchick

Issue #1496534 by cosmicdreams, alexpott, aspilicious, kim.pepper, acrollet,...

Issue #1496534 by cosmicdreams, alexpott, aspilicious, kim.pepper, acrollet, dagmar, beejeebus, wizonesolutions | heyrocker: Convert account settings to configuration system.
parent e599787b
...@@ -1704,7 +1704,7 @@ function comment_preview(Comment $comment) { ...@@ -1704,7 +1704,7 @@ function comment_preview(Comment $comment) {
$comment->picture = $account->picture; $comment->picture = $account->picture;
} }
elseif (empty($comment->name)) { elseif (empty($comment->name)) {
$comment->name = variable_get('anonymous', t('Anonymous')); $comment->name = config('user.settings')->get('anonymous');
} }
$comment->created = !empty($comment->created) ? $comment->created : REQUEST_TIME; $comment->created = !empty($comment->created) ? $comment->created : REQUEST_TIME;
...@@ -1839,7 +1839,7 @@ function theme_comment_post_forbidden($variables) { ...@@ -1839,7 +1839,7 @@ function theme_comment_post_forbidden($variables) {
$destination = array('destination' => "node/$node->nid#comment-form"); $destination = array('destination' => "node/$node->nid#comment-form");
} }
if (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)) { if (config('user.settings')->get('register') != USER_REGISTER_ADMINISTRATORS_ONLY) {
// Users can register themselves. // Users can register themselves.
return t('<a href="@login">Log in</a> or <a href="@register">register</a> to post comments', array('@login' => url('user/login', array('query' => $destination)), '@register' => url('user/register', array('query' => $destination)))); return t('<a href="@login">Log in</a> or <a href="@register">register</a> to post comments', array('@login' => url('user/login', array('query' => $destination)), '@register' => url('user/register', array('query' => $destination))));
} }
......
...@@ -131,7 +131,7 @@ function comment_tokens($type, $tokens, array $data = array(), array $options = ...@@ -131,7 +131,7 @@ function comment_tokens($type, $tokens, array $data = array(), array $options =
break; break;
case 'name': case 'name':
$name = ($comment->uid == 0) ? variable_get('anonymous', t('Anonymous')) : $comment->name; $name = ($comment->uid == 0) ? config('user.settings')->get('anonymous') : $comment->name;
$replacements[$original] = $sanitize ? filter_xss($name) : $name; $replacements[$original] = $sanitize ? filter_xss($name) : $name;
break; break;
......
...@@ -85,7 +85,7 @@ public function form(array $form, array &$form_state, EntityInterface $comment) ...@@ -85,7 +85,7 @@ public function form(array $form, array &$form_state, EntityInterface $comment)
'#default_value' => $author, '#default_value' => $author,
'#maxlength' => 60, '#maxlength' => 60,
'#size' => 30, '#size' => 30,
'#description' => t('Leave blank for %anonymous.', array('%anonymous' => variable_get('anonymous', t('Anonymous')))), '#description' => t('Leave blank for %anonymous.', array('%anonymous' => config('user.settings')->get('anonymous'))),
'#autocomplete_path' => 'user/autocomplete', '#autocomplete_path' => 'user/autocomplete',
); );
} }
...@@ -284,7 +284,7 @@ public function submit(array $form, array &$form_state) { ...@@ -284,7 +284,7 @@ public function submit(array $form, array &$form_state) {
// If the comment was posted by an anonymous user and no author name was // If the comment was posted by an anonymous user and no author name was
// required, use "Anonymous" by default. // required, use "Anonymous" by default.
if ($comment->is_anonymous && (!isset($comment->name) || $comment->name === '')) { if ($comment->is_anonymous && (!isset($comment->name) || $comment->name === '')) {
$comment->name = variable_get('anonymous', t('Anonymous')); $comment->name = config('user.settings')->get('anonymous');
} }
// Validate the comment's subject. If not specified, extract from comment // Validate the comment's subject. If not specified, extract from comment
......
...@@ -21,7 +21,7 @@ public static function getInfo() { ...@@ -21,7 +21,7 @@ public static function getInfo() {
function setUp() { function setUp() {
parent::setUp(); parent::setUp();
variable_set('user_register', USER_REGISTER_VISITORS); config('user.settings')->set('register', USER_REGISTER_VISITORS)->save();
} }
/** /**
......
...@@ -369,7 +369,7 @@ function testCommentNodeCommentStatistics() { ...@@ -369,7 +369,7 @@ function testCommentNodeCommentStatistics() {
$this->assertEqual($node->comment_count, 1, t('The value of node comment_count is 1.')); $this->assertEqual($node->comment_count, 1, t('The value of node comment_count is 1.'));
// Prepare for anonymous comment submission (comment approval enabled). // Prepare for anonymous comment submission (comment approval enabled).
variable_set('user_register', USER_REGISTER_VISITORS); config('user.settings')->set('register', USER_REGISTER_VISITORS)->save();
$this->drupalLogin($this->admin_user); $this->drupalLogin($this->admin_user);
user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array( user_role_change_permissions(DRUPAL_ANONYMOUS_RID, array(
'access comments' => TRUE, 'access comments' => TRUE,
...@@ -556,7 +556,7 @@ function setEnvironment(array $info) { ...@@ -556,7 +556,7 @@ function setEnvironment(array $info) {
} }
// Change user settings. // Change user settings.
variable_set('user_register', $info['user_register']); config('user.settings')->set('register', $info['user_register'])->save();
// Change user permissions. // Change user permissions.
$rid = ($this->loggedInUser ? DRUPAL_AUTHENTICATED_RID : DRUPAL_ANONYMOUS_RID); $rid = ($this->loggedInUser ? DRUPAL_AUTHENTICATED_RID : DRUPAL_ANONYMOUS_RID);
...@@ -648,7 +648,7 @@ function assertCommentLinks(array $info) { ...@@ -648,7 +648,7 @@ function assertCommentLinks(array $info) {
if (!$this->loggedInUser) { if (!$this->loggedInUser) {
if (user_access('post comments', $this->web_user)) { if (user_access('post comments', $this->web_user)) {
// The note depends on whether users are actually able to register. // The note depends on whether users are actually able to register.
if ($info['user_register']) { if ($info['user_register'] != USER_REGISTER_ADMINISTRATORS_ONLY) {
$this->assertText('Log in or register to post comments'); $this->assertText('Log in or register to post comments');
} }
else { else {
......
...@@ -35,7 +35,7 @@ function testCommentPreview() { ...@@ -35,7 +35,7 @@ function testCommentPreview() {
// Login as web user and add a signature and a user picture. // Login as web user and add a signature and a user picture.
$this->drupalLogin($this->web_user); $this->drupalLogin($this->web_user);
variable_set('user_signatures', 1); config('user.settings')->set('signatures', 1)->save();
variable_set('user_pictures', 1); variable_set('user_pictures', 1);
$test_signature = $this->randomName(); $test_signature = $this->randomName();
$edit['signature[value]'] = '<a href="http://example.com/">' . $test_signature. '</a>'; $edit['signature[value]'] = '<a href="http://example.com/">' . $test_signature. '</a>';
......
...@@ -154,7 +154,7 @@ function filter_admin_format_form($form, &$form_state, $format) { ...@@ -154,7 +154,7 @@ function filter_admin_format_form($form, &$form_state, $format) {
// If editing an existing text format, pre-select its current permissions. // If editing an existing text format, pre-select its current permissions.
$form['roles']['#default_value'] = array_keys(filter_get_roles_by_format($format)); $form['roles']['#default_value'] = array_keys(filter_get_roles_by_format($format));
} }
elseif ($admin_role = variable_get('user_admin_role', 0)) { elseif ($admin_role = config('user.settings')->get('admin_role')) {
// If adding a new text format and the site has an administrative role, // If adding a new text format and the site has an administrative role,
// pre-select that role so as to grant administrators access to the new // pre-select that role so as to grant administrators access to the new
// text format permission by default. // text format permission by default.
......
...@@ -54,6 +54,7 @@ protected function prepareEntity(EntityInterface $node) { ...@@ -54,6 +54,7 @@ protected function prepareEntity(EntityInterface $node) {
* Overrides Drupal\entity\EntityFormController::form(). * Overrides Drupal\entity\EntityFormController::form().
*/ */
public function form(array $form, array &$form_state, EntityInterface $node) { public function form(array $form, array &$form_state, EntityInterface $node) {
$user_config = config('user.settings');
// Some special stuff when previewing a node. // Some special stuff when previewing a node.
if (isset($form_state['node_preview'])) { if (isset($form_state['node_preview'])) {
$form['#prefix'] = $form_state['node_preview']; $form['#prefix'] = $form_state['node_preview'];
...@@ -171,7 +172,7 @@ public function form(array $form, array &$form_state, EntityInterface $node) { ...@@ -171,7 +172,7 @@ public function form(array $form, array &$form_state, EntityInterface $node) {
drupal_get_path('module', 'node') . '/node.js', drupal_get_path('module', 'node') . '/node.js',
array( array(
'type' => 'setting', 'type' => 'setting',
'data' => array('anonymous' => variable_get('anonymous', t('Anonymous'))), 'data' => array('anonymous' => $user_config->get('anonymous')),
), ),
), ),
), ),
...@@ -185,7 +186,7 @@ public function form(array $form, array &$form_state, EntityInterface $node) { ...@@ -185,7 +186,7 @@ public function form(array $form, array &$form_state, EntityInterface $node) {
'#autocomplete_path' => 'user/autocomplete', '#autocomplete_path' => 'user/autocomplete',
'#default_value' => !empty($node->name) ? $node->name : '', '#default_value' => !empty($node->name) ? $node->name : '',
'#weight' => -1, '#weight' => -1,
'#description' => t('Leave blank for %anonymous.', array('%anonymous' => variable_get('anonymous', t('Anonymous')))), '#description' => t('Leave blank for %anonymous.', array('%anonymous' => $user_config->get('anonymous'))),
); );
$form['author']['date'] = array( $form['author']['date'] = array(
......
...@@ -33,14 +33,14 @@ public static function getInfo() { ...@@ -33,14 +33,14 @@ public static function getInfo() {
function setUp() { function setUp() {
parent::setUp(); parent::setUp();
variable_set('user_register', USER_REGISTER_VISITORS); config('user.settings')->set('register', USER_REGISTER_VISITORS)->save();
} }
/** /**
* Test OpenID auto-registration with e-mail verification enabled. * Test OpenID auto-registration with e-mail verification enabled.
*/ */
function testRegisterUserWithEmailVerification() { function testRegisterUserWithEmailVerification() {
variable_set('user_email_verification', TRUE); config('user.settings')->set('verify_mail', TRUE)->save();
variable_get('configurable_timezones', 1); variable_get('configurable_timezones', 1);
variable_set('date_default_timezone', 'Europe/Brussels'); variable_set('date_default_timezone', 'Europe/Brussels');
...@@ -97,7 +97,7 @@ function testRegisterUserWithEmailVerification() { ...@@ -97,7 +97,7 @@ function testRegisterUserWithEmailVerification() {
* Test OpenID auto-registration with e-mail verification disabled. * Test OpenID auto-registration with e-mail verification disabled.
*/ */
function testRegisterUserWithoutEmailVerification() { function testRegisterUserWithoutEmailVerification() {
variable_set('user_email_verification', FALSE); config('user.settings')->set('verify_mail', FALSE)->save();
variable_get('configurable_timezones', 1); variable_get('configurable_timezones', 1);
variable_set('date_default_timezone', 'Europe/Brussels'); variable_set('date_default_timezone', 'Europe/Brussels');
...@@ -229,7 +229,7 @@ function testRegisterUserWithoutSreg() { ...@@ -229,7 +229,7 @@ function testRegisterUserWithoutSreg() {
* but no SREG. * but no SREG.
*/ */
function testRegisterUserWithAXButNoSREG() { function testRegisterUserWithAXButNoSREG() {
variable_set('user_email_verification', FALSE); config('user.settings')->set('verify_mail', FALSE)->save();
variable_set('date_default_timezone', 'Europe/Brussels'); variable_set('date_default_timezone', 'Europe/Brussels');
// Tell openid_test.module to respond with these AX fields. // Tell openid_test.module to respond with these AX fields.
......
...@@ -86,7 +86,7 @@ function openid_help($path, $arg) { ...@@ -86,7 +86,7 @@ function openid_help($path, $arg) {
function openid_user_insert($account) { function openid_user_insert($account) {
if (!empty($account->openid_claimed_id)) { if (!empty($account->openid_claimed_id)) {
// The user has registered after trying to log in via OpenID. // The user has registered after trying to log in via OpenID.
if (variable_get('user_email_verification', TRUE)) { if (config('user.settings')->get('verify_mail')) {
drupal_set_message(t('Once you have verified your e-mail address, you may log in via OpenID.')); drupal_set_message(t('Once you have verified your e-mail address, you may log in via OpenID.'));
} }
user_set_authmaps($account, array('authname_openid' => $account->openid_claimed_id)); user_set_authmaps($account, array('authname_openid' => $account->openid_claimed_id));
...@@ -216,9 +216,9 @@ function openid_form_user_register_form_alter(&$form, &$form_state) { ...@@ -216,9 +216,9 @@ function openid_form_user_register_form_alter(&$form, &$form_state) {
$form['account']['mail']['#default_value'] = current($ax_mail_values); $form['account']['mail']['#default_value'] = current($ax_mail_values);
} }
// If user_email_verification is off, hide the password field and just fill // If email verification is off, hide the password field and just fill
// with random password to avoid confusion. // with random password to avoid confusion.
if (!variable_get('user_email_verification', TRUE)) { if (!config('user.settings')->get('verify_mail')) {
$form['account']['pass']['#type'] = 'hidden'; $form['account']['pass']['#type'] = 'hidden';
$form['account']['pass']['#value'] = user_password(); $form['account']['pass']['#value'] = user_password();
} }
...@@ -709,7 +709,7 @@ function openid_authentication($response) { ...@@ -709,7 +709,7 @@ function openid_authentication($response) {
$account = user_external_load($identity); $account = user_external_load($identity);
if (isset($account->uid)) { if (isset($account->uid)) {
if (!variable_get('user_email_verification', TRUE) || $account->login) { if (!config('user.settings')->get('verify_mail') || $account->login) {
// Check if user is blocked. // Check if user is blocked.
$state['values']['name'] = $account->name; $state['values']['name'] = $account->name;
user_login_name_validate(array(), $state); user_login_name_validate(array(), $state);
...@@ -725,7 +725,7 @@ function openid_authentication($response) { ...@@ -725,7 +725,7 @@ function openid_authentication($response) {
// Let other modules act on OpenID login // Let other modules act on OpenID login
module_invoke_all('openid_response', $response, $account); module_invoke_all('openid_response', $response, $account);
} }
elseif (variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)) { elseif (config('user.settings')->get('register') != USER_REGISTER_ADMINISTRATORS_ONLY) {
// Register new user. // Register new user.
// Save response for use in openid_form_user_register_form_alter(). // Save response for use in openid_form_user_register_form_alter().
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
*/ */
function hook_shortcut_default_set($account) { function hook_shortcut_default_set($account) {
// Use a special set of default shortcuts for administrators only. // Use a special set of default shortcuts for administrators only.
if (in_array(variable_get('user_admin_role', 0), $account->roles)) { if (in_array(config('user.settings')->get('admin_role'), $account->roles)) {
return variable_get('mymodule_shortcut_admin_default_set'); return variable_get('mymodule_shortcut_admin_default_set');
} }
} }
......
...@@ -23,7 +23,7 @@ public static function getInfo() { ...@@ -23,7 +23,7 @@ public static function getInfo() {
function setUp() { function setUp() {
parent::setUp(); parent::setUp();
variable_set('user_register', USER_REGISTER_VISITORS); config('user.settings')->set('register', USER_REGISTER_VISITORS)->save();
} }
/** /**
......
...@@ -52,7 +52,7 @@ function setUp() { ...@@ -52,7 +52,7 @@ function setUp() {
), ),
); );
field_create_instance($instance); field_create_instance($instance);
variable_set('user_register', USER_REGISTER_VISITORS); config('user.settings')->set('register', USER_REGISTER_VISITORS)->save();
} }
/** /**
......
...@@ -3785,7 +3785,7 @@ function hook_tokens($type, $tokens, array $data = array(), array $options = arr ...@@ -3785,7 +3785,7 @@ function hook_tokens($type, $tokens, array $data = array(), array $options = arr
// Default values for the chained tokens handled below. // Default values for the chained tokens handled below.
case 'author': case 'author':
$name = ($node->uid == 0) ? variable_get('anonymous', t('Anonymous')) : $node->name; $name = ($node->uid == 0) ? config('user.settings')->get('anonymous') : $node->name;
$replacements[$original] = $sanitize ? filter_xss($name) : $name; $replacements[$original] = $sanitize ? filter_xss($name) : $name;
break; break;
......
admin_role: ''
anonymous: Anonymous
verify_mail: '1'
notify:
cancel_confirm: '1'
password_reset: '1'
status_activated: '1'
status_blocked: '0'
status_cancelled: '0'
register_admin_created: '1'
register_no_approval_required: '1'
register_pending_approval: '1'
register: visitors
signatures: '0'
...@@ -20,6 +20,7 @@ abstract class AccountFormController extends EntityFormController { ...@@ -20,6 +20,7 @@ abstract class AccountFormController extends EntityFormController {
*/ */
public function form(array $form, array &$form_state, EntityInterface $account) { public function form(array $form, array &$form_state, EntityInterface $account) {
global $user; global $user;
$config = config('user.settings');
$language_interface = language(LANGUAGE_TYPE_INTERFACE); $language_interface = language(LANGUAGE_TYPE_INTERFACE);
$register = empty($account->uid); $register = empty($account->uid);
...@@ -101,7 +102,7 @@ public function form(array $form, array &$form_state, EntityInterface $account) ...@@ -101,7 +102,7 @@ public function form(array $form, array &$form_state, EntityInterface $account)
$form['#validate'][] = 'user_validate_current_pass'; $form['#validate'][] = 'user_validate_current_pass';
} }
} }
elseif (!variable_get('user_email_verification', TRUE) || $admin) { elseif (!$config->get('verify_mail') || $admin) {
$form['account']['pass'] = array( $form['account']['pass'] = array(
'#type' => 'password_confirm', '#type' => 'password_confirm',
'#size' => 25, '#size' => 25,
...@@ -114,7 +115,7 @@ public function form(array $form, array &$form_state, EntityInterface $account) ...@@ -114,7 +115,7 @@ public function form(array $form, array &$form_state, EntityInterface $account)
$status = isset($account->status) ? $account->status : 1; $status = isset($account->status) ? $account->status : 1;
} }
else { else {
$status = $register ? variable_get('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL) == USER_REGISTER_VISITORS : $account->status; $status = $register ? $config->get('register') == USER_REGISTER_VISITORS : $account->status;
} }
$form['account']['status'] = array( $form['account']['status'] = array(
...@@ -159,7 +160,7 @@ public function form(array $form, array &$form_state, EntityInterface $account) ...@@ -159,7 +160,7 @@ public function form(array $form, array &$form_state, EntityInterface $account)
'#type' => 'fieldset', '#type' => 'fieldset',
'#title' => t('Signature settings'), '#title' => t('Signature settings'),
'#weight' => 1, '#weight' => 1,
'#access' => (!$register && variable_get('user_signatures', 0)), '#access' => (!$register && $config->get('signatures')),
); );
$form['signature_settings']['signature'] = array( $form['signature_settings']['signature'] = array(
......
...@@ -74,7 +74,7 @@ protected function actions(array $form, array &$form_state) { ...@@ -74,7 +74,7 @@ protected function actions(array $form, array &$form_state) {
public function submit(array $form, array &$form_state) { public function submit(array $form, array &$form_state) {
$admin = $form_state['values']['administer_users']; $admin = $form_state['values']['administer_users'];
if (!variable_get('user_email_verification', TRUE) || $admin) { if (!config('user.settings')->get('verify_mail') || $admin) {
$pass = $form_state['values']['pass']; $pass = $form_state['values']['pass'];
} }
else { else {
...@@ -121,7 +121,7 @@ public function save(array $form, array &$form_state) { ...@@ -121,7 +121,7 @@ public function save(array $form, array &$form_state) {
drupal_set_message(t('Created a new user account for <a href="@url">%name</a>. No e-mail has been sent.', array('@url' => url($uri['path'], $uri['options']), '%name' => $account->name))); drupal_set_message(t('Created a new user account for <a href="@url">%name</a>. No e-mail has been sent.', array('@url' => url($uri['path'], $uri['options']), '%name' => $account->name)));
} }
// No e-mail verification required; log in user immediately. // No e-mail verification required; log in user immediately.
elseif (!$admin && !variable_get('user_email_verification', TRUE) && $account->status) { elseif (!$admin && !config('user.settings')->get('verify_mail') && $account->status) {
_user_mail_notify('register_no_approval_required', $account); _user_mail_notify('register_no_approval_required', $account);
$form_state['uid'] = $account->uid; $form_state['uid'] = $account->uid;
user_login_submit(array(), $form_state); user_login_submit(array(), $form_state);
......
...@@ -250,7 +250,7 @@ function testUserAnonymize() { ...@@ -250,7 +250,7 @@ function testUserAnonymize() {
$this->drupalGet('user/' . $account->uid . '/edit'); $this->drupalGet('user/' . $account->uid . '/edit');
$this->drupalPost(NULL, NULL, t('Cancel account')); $this->drupalPost(NULL, NULL, t('Cancel account'));
$this->assertText(t('Are you sure you want to cancel your account?'), t('Confirmation form to cancel account displayed.')); $this->assertText(t('Are you sure you want to cancel your account?'), t('Confirmation form to cancel account displayed.'));
$this->assertRaw(t('Your account will be removed and all account information deleted. All of your content will be assigned to the %anonymous-name user.', array('%anonymous-name' => variable_get('anonymous', t('Anonymous')))), t('Informs that all content will be attributed to anonymous account.')); $this->assertRaw(t('Your account will be removed and all account information deleted. All of your content will be assigned to the %anonymous-name user.', array('%anonymous-name' => config('user.settings')->get('anonymous'))), t('Informs that all content will be attributed to anonymous account.'));
// Confirm account cancellation. // Confirm account cancellation.
$timestamp = time(); $timestamp = time();
......
...@@ -25,7 +25,7 @@ public static function getInfo() { ...@@ -25,7 +25,7 @@ public static function getInfo() {
function testUserEditedOwnAccount() { function testUserEditedOwnAccount() {
// Change account setting 'Who can register accounts?' to Administrators // Change account setting 'Who can register accounts?' to Administrators
// only. // only.
variable_set('user_register', USER_REGISTER_ADMINISTRATORS_ONLY); config('user.settings')->set('register', USER_REGISTER_ADMINISTRATORS_ONLY)->save();
// Create a new user account and log in. // Create a new user account and log in.
$account = $this->drupalCreateUser(array('change own username')); $account = $this->drupalCreateUser(array('change own username'));
......
...@@ -44,7 +44,7 @@ function testLabelCallback() { ...@@ -44,7 +44,7 @@ function testLabelCallback() {
// Setup a random anonymous name to be sure the name is used. // Setup a random anonymous name to be sure the name is used.
$name = $this->randomName(); $name = $this->randomName();
variable_set('anonymous', $name); config('user.settings')->set('anonymous', $name)->save();
$this->assertEqual($this->anonymous->label(), $name, t('The variable anonymous should be used for name of uid 0')); $this->assertEqual($this->anonymous->label(), $name, t('The variable anonymous should be used for name of uid 0'));
} }
......
...@@ -31,8 +31,7 @@ public static function getInfo() { ...@@ -31,8 +31,7 @@ public static function getInfo() {
function setUp() { function setUp() {
parent::setUp(); parent::setUp();
config('user.settings')->set('register', USER_REGISTER_VISITORS)->save();
variable_set('user_register', USER_REGISTER_VISITORS);
} }
/** /**
......
...@@ -27,16 +27,17 @@ public static function getInfo() { ...@@ -27,16 +27,17 @@ public static function getInfo() {
} }
function testRegistrationWithEmailVerification() { function testRegistrationWithEmailVerification() {
$config = config('user.settings');
// Require e-mail verification. // Require e-mail verification.
variable_set('user_email_verification', TRUE); $config->set('verify_mail', TRUE)->save();
// Set registration to administrator only. // Set registration to administrator only.
variable_set('user_register', USER_REGISTER_ADMINISTRATORS_ONLY); $config->set('register', USER_REGISTER_ADMINISTRATORS_ONLY)->save();
$this->drupalGet('user/register'); $this->drupalGet('user/register');
$this->assertResponse(403, t('Registration page is inaccessible when only administrators can create accounts.')); $this->assertResponse(403, t('Registration page is inaccessible when only administrators can create accounts.'));
// Allow registration by site visitors without administrator approval. // Allow registration by site visitors without administrator approval.
variable_set('user_register', USER_REGISTER_VISITORS); $config->set('register', USER_REGISTER_VISITORS)->save();
$edit = array(); $edit = array();
$edit['name'] = $name = $this->randomName(); $edit['name'] = $name = $this->randomName();
$edit['mail'] = $mail = $edit['name'] . '@example.com'; $edit['mail'] = $mail = $edit['name'] . '@example.com';
...@@ -47,7 +48,7 @@ function testRegistrationWithEmailVerification() { ...@@ -47,7 +48,7 @@ function testRegistrationWithEmailVerification() {
$this->assertTrue($new_user->status, t('New account is active after registration.')); $this->assertTrue($new_user->status, t('New account is active after registration.'));
// Allow registration by site visitors, but require administrator approval. // Allow registration by site visitors, but require administrator approval.
variable_set('user_register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL); $config->set('register', USER_REGISTER_VISITORS_ADMINISTRATIVE_APPROVAL)->save();
$edit = array(); $edit = array();
$edit['name'] = $name = $this->randomName(); $edit['name'] = $name = $this->randomName();
$edit['mail'] = $mail = $edit['name'] . '@example.com'; $edit['mail'] = $mail = $edit['name'] . '@example.com';
...@@ -59,11 +60,14 @@ function testRegistrationWithEmailVerification() { ...@@ -59,11 +60,14 @@ function testRegistrationWithEmailVerification() {
} }
function testRegistrationWithoutEmailVerification() { function testRegistrationWithoutEmailVerification() {
// Don't require e-mail verification. $config = config('user.settings');
variable_set('user_email_verification', FALSE); // Don't require e-mail verification and allow registration by site visitors
// without administrator approval.
$config
->set('verify_mail', FALSE)
->set('register', USER_REGISTER_VISITORS)
->save();
// Allow registration by site visitors without administrator approval.
variable_set('user_register', USER_REGISTER_VISITORS);
$edit = array(); $edit = array();
$edit['name'] = $name = $this->randomName(); $edit['name'] = $name = $this->randomName();
$edit['mail'] = $mail = $edit['name'] . '@example.com';