1 user.test UserRegistrationTestCase::testRegistrationDefaultValues()

File

core/modules/user/tests/user.test, line 200
Tests for user.module.

Class

UserRegistrationTestCase

Code

function testRegistrationDefaultValues() {
  $config_user_settings = config('system.core');

  // Allow registration by site visitors without administrator approval.
  $config_user_settings->set('user_register', USER_REGISTER_VISITORS)->save();

  // Don't require email verification.
  $config_user_settings->set('user_email_verification', FALSE)->save();

  // Set the default timezone to Brussels.
  $config_system_date = config('system.date')
    ->set('user_configurable_timezones', 1)
    ->set('default_timezone', 'Europe/Brussels')
    ->save();

  // Check that the account information fieldset's options are not displayed
  // is a fieldset if there is not more than one fieldset in the form.
  $this->backdropGet('user/register');
  $this->assertNoRaw('<fieldset id="edit-account"><legend>Account information</legend>', 'Account settings fieldset was hidden.');

  $edit = array();
  $edit['name'] = $name = $this->randomName();
  $edit['mail'] = $mail = $edit['name'] . '@example.com';
  $edit['pass'] = $new_pass = $this->randomName();
  $this->backdropPost(NULL, $edit, t('Create new account'));

  // Check user fields.
  $accounts = user_load_multiple(array(), array('name' => $name, 'mail' => $mail));
  $new_user = reset($accounts);
  $this->assertEqual($new_user->name, $name, 'Username matches.');
  $this->assertEqual($new_user->mail, $mail, 'Email address matches.');
  $this->assertEqual($new_user->signature, '', 'Correct signature field.');
  $this->assertTrue(($new_user->created > REQUEST_TIME - 20), 'Correct creation time.');
  $this->assertEqual($new_user->changed, $new_user->created, 'Correct changed time.');
  $this->assertEqual($new_user->status, $config_user_settings->get('user_register') == USER_REGISTER_VISITORS ? 1 : 0, 'Correct status field.');
  $this->assertEqual($new_user->timezone, $config_system_date->get('default_timezone'), 'Correct time zone field.');
  $this->assertEqual($new_user->language, '', 'Correct language field.');
  $this->assertEqual($new_user->picture, 0, 'Correct picture field.');
  $this->assertEqual($new_user->init, $mail, 'Correct init field.');
}