Projet

Général

Profil

Paste
Télécharger (2,05 ko) Statistiques
| Branche: | Révision:

root / drupal7 / modules / simpletest / tests / upgrade / upgrade.poll.test @ b0dc3a2e

1 85ad3d82 Assos Assos
<?php
2
3
/**
4
 * Upgrade test for poll.module.
5
 *
6
 * Load a bare installation of Drupal 6 and run the upgrade process on it.
7
 *
8
 * The install only contains dblog (although it's optional, it's only so that
9
 * another hook_watchdog module can take its place, the site is not functional
10
 * without watchdog) and update.
11
 */
12
class PollUpgradePathTestCase extends UpgradePathTestCase {
13
  public static function getInfo() {
14
    return array(
15
      'name'  => 'Poll upgrade path',
16
      'description'  => 'Poll upgrade path tests.',
17
      'group' => 'Upgrade path',
18
    );
19
  }
20
21
  public function setUp() {
22
    // Path to the database dump files.
23
    $this->databaseDumpFiles = array(
24
      drupal_get_path('module', 'simpletest') . '/tests/upgrade/drupal-6.filled.database.php',
25
    );
26
    parent::setUp();
27
28
    $this->uninstallModulesExcept(array('poll'));
29
  }
30
31
  /**
32
   * Test a successful upgrade.
33
   */
34
  public function testPollUpgrade() {
35
    $this->assertTrue($this->performUpgrade(), 'The upgrade was completed successfully.');
36
37
    // Check modules page for poll
38
    $this->drupalGet('admin/modules');
39
40
    // Verify that the poll data is still correctly available
41
    for ($i = 0; $i < 12; $i++) {
42
      $this->drupalGet("content/poll/$i");
43
44
      $nbchoices = ($i % 4) + 2;
45
46
      for ($c = 0; $c < $nbchoices; $c++) {
47
        $this->assertText("Choice $c for poll $i", 'Choice text is displayed correctly on poll view');
48
      }
49
50
      // Now check that the votes are correct
51
      $this->clickLink(t('Results'));
52
53
      for ($c = 0; $c < $nbchoices; $c++) {
54
        $this->assertText("Choice $c for poll $i", 'Choice text is displayed correctly on result view');
55
      }
56
57
      $nbvotes = floor (($i % 4) + 5);
58
      $elements = $this->xpath("//div[@class='percent']");
59
      for ($c = 0; $c < $nbchoices; $c++) {
60
        $votes = floor($nbvotes / $nbchoices);
61
        if (($nbvotes % $nbchoices) > $c) $votes++;
62
        $this->assertTrue(preg_match("/$votes vote/", $elements[$c]), 'The number of votes is displayed correctly: expected ' . $votes . ', got ' . $elements[$c]);
63
      }
64
    }
65
  }
66
}