You are here

function QuizUpgradeTestCase::test740Beta2Upgrade in Quiz 7.6

Same name and namespace in other branches
  1. 7.5 tests/QuizUpgradeTestCase.test \QuizUpgradeTestCase::test740Beta2Upgrade()

Test an upgrade to Quiz from 7.x-4.0-beta2

File

tests/QuizUpgradeTestCase.test, line 41

Class

QuizUpgradeTestCase

Code

function test740Beta2Upgrade() {
  $this->databaseDumpFiles = array(
    drupal_get_path('module', 'quiz') . '/tests/upgrade/quiz-beta2.php.gz',
  );
  parent::setUp();
  $this
    ->uninstallModulesExcept(array_merge($this->quiz_modules, $this->other_modules));
  $this
    ->assertTrue($this
    ->performUpgrade(), 'The upgrade was completed successfully.');
  drupal_get_schema(NULL, TRUE);
  foreach ($this->quiz_modules as $module) {
    $schema = drupal_get_schema_unprocessed($module);
    foreach ($schema as $table => $info) {
      $this
        ->assertTrue(db_table_exists($table), "{$table} exists");
      foreach ($info['fields'] as $field_name => $field_info) {
        $this
          ->assertTrue(db_field_exists($table, $field_name), "{$table} has {$field_name}");
      }
      if (isset($info['indexes'])) {
        foreach ($info['indexes'] as $index_name => $columns) {
          $this
            ->assertTrue(db_index_exists($table, $index_name), "{$table} has index {$index_name}");
        }
      }
      if (isset($info['unique keys'])) {
        foreach ($info['unique keys'] as $index_name => $columns) {
          $this
            ->assertTrue(db_index_exists($table, $index_name), "{$table} has unique key {$index_name}");
        }
      }
    }
  }
}