You are here

email_registration.test in Email Registration 6

Same filename and directory in other branches
  1. 7 email_registration.test

email registration simpletest

File

email_registration.test
View source
<?php

/**
 * @file
 * email registration simpletest
 */
class EmailRegistrationTestCase extends DrupalWebTestCase {

  /**
   * Implementation of getInfo().
   */
  public static function getInfo() {
    return array(
      'name' => t('Email registration.'),
      'description' => t('Test the email registration module.'),
      'group' => t('Email registration'),
    );
  }

  /**
   * Implementation of setUp().
   */
  function setUp() {
    parent::setUp('email_registration');

    // Configure to allow set password.
    variable_set('user_email_verification', FALSE);
  }

  /**
   * Test various behaviors for anonymous users.
   */
  function testRegistration() {

    // Try to register a user.
    $name = $this
      ->randomName();
    $pass = $this
      ->randomName(10);
    $register = array(
      'mail' => $name . '@example.com',
      'pass[pass1]' => $pass,
      'pass[pass2]' => $pass,
    );
    $this
      ->drupalPost('/user/register', $register, t('Create new account'));
    $this
      ->drupalLogout();
    $login = array(
      'name' => $name . '@example.com',
      'pass' => $pass,
    );
    $this
      ->drupalPost('user/login', $login, t('Log in'));

    // Really basic confirmation that the user was created and logged in.
    $this
      ->assertRaw('<h2>' . $name . '</h2>', t('User properly created, logged in.'));

    // Now try the immediate login.
    $this
      ->drupalLogout();
    variable_set('user_email_verification', 0);
    $name = $this
      ->randomName();
    $pass = $this
      ->randomName(10);
    $register = array(
      'mail' => $name . '@example.com',
      'pass[pass1]' => $pass,
      'pass[pass2]' => $pass,
    );
    $this
      ->drupalPost('/user/register', $register, t('Create new account'));
    $this
      ->assertRaw('Registration successful. You are now logged in.', t('User properly created, immediately logged in.'));
  }

}

Classes

Namesort descending Description
EmailRegistrationTestCase @file email registration simpletest