upgrade.user.test 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. if ($this->skipUpgradeTest) {
  26. return;
  27. }
  28. $this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.');
  29. $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).');
  30. // Check that a non-md5 hash was untouched.
  31. $pass = db_query('SELECT pass FROM {users} WHERE uid = 3')->fetchField();
  32. $this->assertEqual('$S$DAK00p3Dkojkf4O/UizYxenguXnjv', $pass, 'Pre-existing non-MD5 password hash was not altered');
  33. }
  34. }
  35. /**
  36. * Upgrade test for user.module (password token not involved).
  37. */
  38. class UserUpgradePathNoPasswordTokenTestCase extends UpgradePathTestCase {
  39. public static function getInfo() {
  40. return array(
  41. 'name' => 'User upgrade path (password token not involved)',
  42. 'description' => 'User upgrade path tests (password token not involved).',
  43. 'group' => 'Upgrade path',
  44. );
  45. }
  46. public function setUp() {
  47. // Path to the database dump files.
  48. $this->databaseDumpFiles = array(
  49. drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.bare.database.php',
  50. drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.user-no-password-token.database.php',
  51. );
  52. parent::setUp();
  53. }
  54. /**
  55. * Test a successful upgrade.
  56. */
  57. public function testUserUpgrade() {
  58. if ($this->skipUpgradeTest) {
  59. return;
  60. }
  61. $this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.');
  62. $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).');
  63. }
  64. }
  65. /**
  66. * Upgrade test for user.module (duplicated permission).
  67. */
  68. class UserUpgradePathDuplicatedPermissionTestCase extends UpgradePathTestCase {
  69. public static function getInfo() {
  70. return array(
  71. 'name' => 'User upgrade path (duplicated permission)',
  72. 'description' => 'User upgrade path tests (duplicated permission).',
  73. 'group' => 'Upgrade path',
  74. );
  75. }
  76. public function setUp() {
  77. // Path to the database dump files.
  78. $this->databaseDumpFiles = array(
  79. drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.bare.database.php',
  80. drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.duplicate-permission.database.php',
  81. );
  82. parent::setUp();
  83. }
  84. /**
  85. * Test a successful upgrade.
  86. */
  87. public function testUserUpgrade() {
  88. if ($this->skipUpgradeTest) {
  89. return;
  90. }
  91. $this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.');
  92. }
  93. }