diff options
author | Thomas Steur <thomas.steur@googlemail.com> | 2014-04-04 01:32:52 +0400 |
---|---|---|
committer | Thomas Steur <thomas.steur@googlemail.com> | 2014-04-04 01:32:52 +0400 |
commit | 980ed357aa267d76ff4caa4c6099bacca250773c (patch) | |
tree | 64120a3081b8876868b1811b4adf7ff1fa679072 /plugins | |
parent | 81bd53ab3632a56222fb9d2da9efd0056d30ab6b (diff) |
added tests for custom variables install/uninstall
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/CustomVariables/Model.php | 10 | ||||
-rw-r--r-- | plugins/CustomVariables/tests/ModelTest.php | 27 |
2 files changed, 33 insertions, 4 deletions
diff --git a/plugins/CustomVariables/Model.php b/plugins/CustomVariables/Model.php index c2cddd7b59..9fbb7d46c9 100644 --- a/plugins/CustomVariables/Model.php +++ b/plugins/CustomVariables/Model.php @@ -114,8 +114,9 @@ class Model return null; } - Db::exec(sprintf('ALTER TABLE %s DROP COLUMN custom_var_k%d', $dbTable, $index)); - Db::exec(sprintf('ALTER TABLE %s DROP COLUMN custom_var_v%d', $dbTable, $index)); + Db::exec(sprintf('ALTER TABLE %s ', $dbTable) + . sprintf('DROP COLUMN custom_var_k%d,', $index) + . sprintf('DROP COLUMN custom_var_v%d;', $index)); return $index; } @@ -126,8 +127,9 @@ class Model $index = $this->getHighestCustomVarIndex() + 1; $maxLen = CustomVariables::getMaxLengthCustomVariables(); - Db::exec(sprintf('ALTER TABLE %s ADD COLUMN custom_var_k%d VARCHAR(%d) DEFAULT NULL', $dbTable, $index, $maxLen)); - Db::exec(sprintf('ALTER TABLE %s ADD COLUMN custom_var_v%d VARCHAR(%d) DEFAULT NULL', $dbTable, $index, $maxLen)); + Db::exec(sprintf('ALTER TABLE %s ', $dbTable) + . sprintf('ADD COLUMN custom_var_k%d VARCHAR(%d) DEFAULT NULL,', $index, $maxLen) + . sprintf('ADD COLUMN custom_var_v%d VARCHAR(%d) DEFAULT NULL;', $index, $maxLen)); return $index; } diff --git a/plugins/CustomVariables/tests/ModelTest.php b/plugins/CustomVariables/tests/ModelTest.php index 14d8647bf0..870228e7cd 100644 --- a/plugins/CustomVariables/tests/ModelTest.php +++ b/plugins/CustomVariables/tests/ModelTest.php @@ -38,6 +38,33 @@ class ModelTest extends \DatabaseTestCase $this->assertEquals(array('log_link_visit_action', 'log_visit', 'log_conversion'), Model::getScopes()); } + public function test_Install_Uninstall() + { + $this->assertEquals(5, $this->getPageScope()->getCurrentNumCustomVars()); + $this->assertEquals(5, $this->getVisitScope()->getCurrentNumCustomVars()); + $this->assertEquals(5, $this->getConversionScope()->getCurrentNumCustomVars()); + + Model::uninstall(); + + $this->assertEquals(0, $this->getPageScope()->getCurrentNumCustomVars()); + $this->assertEquals(0, $this->getVisitScope()->getCurrentNumCustomVars()); + $this->assertEquals(0, $this->getConversionScope()->getCurrentNumCustomVars()); + + $this->getPageScope()->addCustomVariable(); + $this->getPageScope()->addCustomVariable(); + $this->getVisitScope()->addCustomVariable(); + + $this->assertEquals(2, $this->getPageScope()->getCurrentNumCustomVars()); + $this->assertEquals(1, $this->getVisitScope()->getCurrentNumCustomVars()); + $this->assertEquals(0, $this->getConversionScope()->getCurrentNumCustomVars()); + + Model::install(); + + $this->assertEquals(5, $this->getPageScope()->getCurrentNumCustomVars()); + $this->assertEquals(5, $this->getVisitScope()->getCurrentNumCustomVars()); + $this->assertEquals(5, $this->getConversionScope()->getCurrentNumCustomVars()); + } + public function testGetCustomVariableIndexFromFieldName() { $this->assertSame(0, Model::getCustomVariableIndexFromFieldName('custom_var_k0')); |