Skip to content
Extraits de code Groupes Projets
Valider 980ed357 rédigé par Thomas Steur's avatar Thomas Steur
Parcourir les fichiers

added tests for custom variables install/uninstall

parent 81bd53ab
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -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;
}
......
......@@ -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'));
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter