upgrade.user.test 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. /**
  3. * Upgrade test for user.module (password token involved).
  4. */
  5. class UserUpgradePathPasswordTokenTestCase extends UpgradePathTestCase {
  6. public static function getInfo() {
  7. return array(
  8. 'name' => 'User upgrade path (password token involved)',
  9. 'description' => 'User upgrade path tests (password token involved).',
  10. 'group' => 'Upgrade path',
  11. );
  12. }
  13. public function setUp() {
  14. // Path to the database dump files.
  15. $this->databaseDumpFiles = array(
  16. drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.bare.database.php',
  17. drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.user-password-token.database.php',
  18. );
  19. parent::setUp();
  20. }
  21. /**
  22. * Test a successful upgrade.
  23. */
  24. public function testUserUpgrade() {
  25. $this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.');
  26. $this->assertEqual(variable_get('user_mail_register_no_approval_required_body'), ', [user:name], [site:name], [site:url], [site:url-brief], [user:mail], [date:medium], [site:login-url], [user:edit-url], [user:one-time-login-url].', 'Existing email templates have been modified (password token involved).');
  27. // Check that a non-md5 hash was untouched.
  28. $pass = db_query('SELECT pass FROM {users} WHERE uid = 3')->fetchField();
  29. $this->assertEqual('$S$DAK00p3Dkojkf4O/UizYxenguXnjv', $pass, 'Pre-existing non-MD5 password hash was not altered');
  30. }
  31. }
  32. /**
  33. * Upgrade test for user.module (password token not involved).
  34. */
  35. class UserUpgradePathNoPasswordTokenTestCase extends UpgradePathTestCase {
  36. public static function getInfo() {
  37. return array(
  38. 'name' => 'User upgrade path (password token not involved)',
  39. 'description' => 'User upgrade path tests (password token not involved).',
  40. 'group' => 'Upgrade path',
  41. );
  42. }
  43. public function setUp() {
  44. // Path to the database dump files.
  45. $this->databaseDumpFiles = array(
  46. drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.bare.database.php',
  47. drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.user-no-password-token.database.php',
  48. );
  49. parent::setUp();
  50. }
  51. /**
  52. * Test a successful upgrade.
  53. */
  54. public function testUserUpgrade() {
  55. $this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.');
  56. $this->assertEqual(variable_get('user_mail_register_no_approval_required_body'), '[user:name], [site:name], [site:url], [site:url-brief], [user:mail], [date:medium], [site:login-url], [user:edit-url], [user:one-time-login-url].', 'Existing email templates have been modified (password token not involved).');
  57. }
  58. }
  59. /**
  60. * Upgrade test for user.module (duplicated permission).
  61. */
  62. class UserUpgradePathDuplicatedPermissionTestCase extends UpgradePathTestCase {
  63. public static function getInfo() {
  64. return array(
  65. 'name' => 'User upgrade path (duplicated permission)',
  66. 'description' => 'User upgrade path tests (duplicated permission).',
  67. 'group' => 'Upgrade path',
  68. );
  69. }
  70. public function setUp() {
  71. // Path to the database dump files.
  72. $this->databaseDumpFiles = array(
  73. drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.bare.database.php',
  74. drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.duplicate-permission.database.php',
  75. );
  76. parent::setUp();
  77. }
  78. /**
  79. * Test a successful upgrade.
  80. */
  81. public function testUserUpgrade() {
  82. $this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.');
  83. }
  84. }