Projet

Général

Profil

Paste
Télécharger (3,52 ko) Statistiques
| Branche: | Révision:

root / drupal7 / modules / simpletest / tests / upgrade / upgrade.user.test @ f7a2490e

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

    
14
  public function setUp() {
15
    // Path to the database dump files.
16
    $this->databaseDumpFiles = array(
17
      drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.bare.database.php',
18
      drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.user-password-token.database.php',
19
    );
20
    parent::setUp();
21
  }
22

    
23
  /**
24
   * Test a successful upgrade.
25
   */
26
  public function testUserUpgrade() {
27
    $this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.');
28
    $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).');
29
    // Check that a non-md5 hash was untouched.
30
    $pass = db_query('SELECT pass FROM {users} WHERE uid = 3')->fetchField();
31
    $this->assertEqual('$S$DAK00p3Dkojkf4O/UizYxenguXnjv', $pass, 'Pre-existing non-MD5 password hash was not altered');
32
  }
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

    
47
  public function setUp() {
48
    // Path to the database dump files.
49
    $this->databaseDumpFiles = array(
50
      drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.bare.database.php',
51
      drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.user-no-password-token.database.php',
52
    );
53
    parent::setUp();
54
  }
55

    
56
  /**
57
   * Test a successful upgrade.
58
   */
59
  public function testUserUpgrade() {
60
    $this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.');
61
    $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).');
62
  }
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

    
77
  public function setUp() {
78
    // Path to the database dump files.
79
    $this->databaseDumpFiles = array(
80
      drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.bare.database.php',
81
      drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.duplicate-permission.database.php',
82
    );
83
    parent::setUp();
84
  }
85

    
86
  /**
87
   * Test a successful upgrade.
88
   */
89
  public function testUserUpgrade() {
90
    $this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.');
91
  }
92
}