email_registration.test 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <?php
  2. /**
  3. * @file
  4. * email registration simpletest
  5. */
  6. class EmailRegistrationTestCase extends DrupalWebTestCase {
  7. /**
  8. * Implementation of getInfo().
  9. */
  10. public static function getInfo() {
  11. return array(
  12. 'name' => t('Email registration.'),
  13. 'description' => t('Test the email registration module.'),
  14. 'group' => t('Email registration'),
  15. );
  16. }
  17. /**
  18. * Implementation of setUp().
  19. */
  20. function setUp() {
  21. parent::setUp('email_registration');
  22. // Configure to allow set password.
  23. variable_set('user_email_verification', FALSE);
  24. }
  25. /**
  26. * Test various behaviors for anonymous users.
  27. */
  28. function testRegistration() {
  29. variable_set('user_register', USER_REGISTER_VISITORS);
  30. // Try to register a user.
  31. $name = $this->randomName();
  32. $pass = $this->randomName(10);
  33. $register = array(
  34. 'mail' => $name . '@example.com',
  35. 'pass[pass1]' => $pass,
  36. 'pass[pass2]' => $pass,
  37. );
  38. $this->drupalPost('/user/register', $register, t('Create new account'));
  39. $this->drupalLogout();
  40. $login = array(
  41. 'name' => $name . '@example.com',
  42. 'pass' => $pass,
  43. );
  44. $this->drupalPost('user/login', $login, t('Log in'));
  45. // Really basic confirmation that the user was created and logged in.
  46. $this->assertRaw('<title>' . $name . ' | Drupal</title>', t('User properly created, logged in.'));
  47. // Now try the immediate login.
  48. $this->drupalLogout();
  49. variable_set('user_email_verification', 0);
  50. $name = $this->randomName();
  51. $pass = $this->randomName(10);
  52. $register = array(
  53. 'mail' => $name . '@example.com',
  54. 'pass[pass1]' => $pass,
  55. 'pass[pass2]' => $pass,
  56. );
  57. $this->drupalPost('/user/register', $register, t('Create new account'));
  58. $this->assertRaw('Registration successful. You are now logged in.', t('User properly created, immediately logged in.'));
  59. }
  60. }