Skip to content

Commit

Permalink
fix(install): fresh installation does not saves current schema version
Browse files Browse the repository at this point in the history
see #794
  • Loading branch information
btry committed Oct 24, 2017
1 parent 86893f4 commit 8eadd7d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
7 changes: 6 additions & 1 deletion install/install.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ public function install(Migration $migration) {
$this->createDefaultDisplayPreferences();
$this->createNotifications();

Config::setConfigurationValues('formcreator', ['schema_version' => PLUGIN_FORMCREATOR_SCHEMA_VERSION]);

return true;
}

Expand Down Expand Up @@ -371,10 +373,13 @@ protected function deleteTicketRelation() {
PluginFormcreatorCommon::setNotification($use_mailing);
}

/**
* Cleanups the database from plugin's itemtypes (tables and relations)
*/
protected function deleteTables() {
global $DB;

// Drop tables
// Keep these itemtypes as string because classes might be not avaiable (if plugin is inactive)
$itemtypes = [
'PluginFormcreatorAnswer',
'PluginFormcreatorCategory',
Expand Down
4 changes: 4 additions & 0 deletions tests/0000_Install/PluginInstallTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ public function testInstallPlugin() {
$PluginDBTest = new PluginDB();
$PluginDBTest->checkInstall("formcreator", "install");

$config = Config::getConfigurationValues('formcreator');
$this->assertArrayHasKey('schema_version', $config);
$this->assertEquals($config['schema_version'], PLUGIN_FORMCREATOR_SCHEMA_VERSION);

// Enable the plugin
$plugin->activate($plugin->fields['id']);
$this->assertTrue($plugin->isActivated("formcreator"), "Cannot enable the plugin");
Expand Down
5 changes: 4 additions & 1 deletion tests/9000_Uninstall/PluginUninstallTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,10 @@ public function testUninstall() {
$rows = $template->find("`itemtype` = 'PluginFormcreatorForm_Answer'");
$this->assertCount(0, $rows);

// TODO: need to find a r eliable way to detect not clenaed
$config = Config::getConfigurationValues('formcreator');
$this->assertArrayNotHasKey('schema_version', $config);

// TODO: need to find a reliable way to detect not clenaed
// - NotificationTemplateTranslation
// - Notification_NotificationTemplate
}
Expand Down

0 comments on commit 8eadd7d

Please sign in to comment.