PollUpgradePathTestCase::testPollUpgrade

7 upgrade.poll.test public PollUpgradePathTestCase::testPollUpgrade()
7 upgrade.node.test public PollUpgradePathTestCase::testPollUpgrade()

Test a successful upgrade.

File

modules/simpletest/tests/upgrade/upgrade.poll.test, line 34

Code

public function testPollUpgrade() {
  $this->assertTrue($this->performUpgrade(), t('The upgrade was completed successfully.'));

  // Check modules page for poll
  $this->drupalGet('admin/modules');

  // Verify that the poll data is still correctly available
  for ($i = 0; $i < 12; $i++) {
    $this->drupalGet("content/poll/$i");

    $nbchoices = ($i % 4) + 2;

    for ($c = 0; $c < $nbchoices; $c++) {
      $this->assertText("Choice $c for poll $i", t('Choice text is displayed correctly on poll view'));
    }

    // Now check that the votes are correct
    $this->clickLink(t('Results'));

    for ($c = 0; $c < $nbchoices; $c++) {
      $this->assertText("Choice $c for poll $i", t('Choice text is displayed correctly on result view'));
    }

    $nbvotes = floor(($i % 4) + 5);
    $elements = $this->xpath("//div[@class='percent']");
    for ($c = 0; $c < $nbchoices; $c++) {
      $votes = floor($nbvotes / $nbchoices);
      if (($nbvotes % $nbchoices) > $c) {
        $votes++;
      }
      $this->assertTrue(preg_match("/$votes vote/", $elements[$c]), t('The number of votes is displayed correctly: expected ' . $votes . ', got ' . $elements[$c]));
    }
  }
}
Login or register to post comments