예제 #1
0
 /**
  * Test upgrade step runner.
  */
 public function test_migrate_runupgradesteps()
 {
     global $DB;
     // Ensure indicator record not present.
     $this->assertEmpty($DB->get_record('config_plugins', array('plugin' => 'testcomponent', 'name' => 'upgradestepran')));
     // Run migration.
     $oldcomponent = 'oldcomponent';
     $newcomponent = 'newcomponent';
     $upgradestepfuncname = 'local_elisprogram_tests_migrate_upgradestep';
     $migrator = new \local_eliscore\install\migration\migrator($oldcomponent, $newcomponent, $upgradestepfuncname);
     $migrator->run_old_upgrade_steps_if_necessary();
     // Upgrade step should not have run as we have not "installed" oldcomponent.
     $this->assertEmpty($DB->get_record('config_plugins', array('plugin' => 'testcomponent', 'name' => 'upgradestepran')));
     // Add version for testcomponent.
     $rec = new \stdClass();
     $rec->plugin = 'oldcomponent';
     $rec->name = 'version';
     $rec->value = 20140213;
     $DB->insert_record('config_plugins', $rec);
     // Run migration.
     $oldcomponent = 'oldcomponent';
     $newcomponent = 'newcomponent';
     $upgradestepfuncname = 'local_elisprogram_tests_migrate_upgradestep';
     $migrator = new \local_eliscore\install\migration\migrator($oldcomponent, $newcomponent, $upgradestepfuncname);
     $migrator->run_old_upgrade_steps_if_necessary();
     // Ensure indicator record present.
     $this->assertNotEmpty($DB->get_record('config_plugins', array('plugin' => 'testcomponent', 'name' => 'upgradestepran')));
 }