Skip to content
Snippets Groups Projects
Commit 9b4c929d authored by Laurent Destailleur's avatar Laurent Destailleur
Browse files

NEW Add phpunit to check the engine is defined into sql create files.

parent 7ad92c3a
No related branches found
No related tags found
No related merge requests found
......@@ -337,3 +337,8 @@ drop table tmp_c_shipment_mode;
-- VMYSQL4.1 update llx_expensereport_det as ed set date = (select date_debut from llx_expensereport as e where ed.fk_expensereport = e.rowid) where DATE(STR_TO_DATE(date, '%Y-%m-%d')) < '1000-00-00';
-- VMYSQL4.1 SET sql_mode = 'NO_ZERO_DATE';
-- Backport a change of value into the hourly rate.
-- update llx_projet_task_time as ptt set ptt.thm = (SELECT thm from llx_user as u where ptt.fk_user = u.rowid) where (ptt.thm is null)
\ No newline at end of file
......@@ -28,4 +28,4 @@ CREATE TABLE llx_advtargetemailing
datec datetime NOT NULL,
fk_user_mod integer NOT NULL,
tms timestamp NOT NULL
)ENGINE=InnoDB;
)ENGINE=innodb;
......@@ -23,4 +23,4 @@ CREATE TABLE llx_product_attribute
label VARCHAR(255) NOT NULL,
rang INT DEFAULT 0 NOT NULL,
entity INT DEFAULT 1 NOT NULL
);
)ENGINE=innodb;
......@@ -25,4 +25,4 @@ CREATE TABLE llx_product_attribute_combination
variation_price_percentage INT NULL,
variation_weight FLOAT NOT NULL,
entity INT DEFAULT 1 NOT NULL
);
\ No newline at end of file
)ENGINE=innodb;
\ No newline at end of file
......@@ -22,4 +22,4 @@ CREATE TABLE llx_product_attribute_combination2val
fk_prod_combination INT NOT NULL,
fk_prod_attr INT NOT NULL,
fk_prod_attr_val INT NOT NULL
);
\ No newline at end of file
)ENGINE=innodb;
\ No newline at end of file
......@@ -23,4 +23,4 @@ CREATE TABLE llx_product_attribute_value
ref VARCHAR(255) DEFAULT NULL,
value VARCHAR(255) DEFAULT NULL,
entity INT DEFAULT 1 NOT NULL
);
\ No newline at end of file
)ENGINE=innodb;
\ No newline at end of file
......@@ -23,4 +23,4 @@ CREATE TABLE llx_product_pricerules
fk_level INT NOT NULL, -- Price variations are made over price of X
var_percent FLOAT NOT NULL, -- Price variation over based price
var_min_percent FLOAT NOT NULL -- Min price discount over general price
);
\ No newline at end of file
)ENGINE=innodb;
......@@ -143,16 +143,16 @@ class CodingSqlTest extends PHPUnit_Framework_TestCase
$listofsqldir = array(DOL_DOCUMENT_ROOT.'/install/mysql/tables', DOL_DOCUMENT_ROOT.'/install/mysql/migration');
foreach ($listofsqldir as $dir)
foreach ($listofsqldir as $dir)
{
print 'Process dir '.$dir."\n";
$filesarray = scandir($dir);
foreach($filesarray as $key => $file)
foreach($filesarray as $key => $file)
{
if (! preg_match('/\.sql$/',$file))
continue;
print 'Check sql file '.$file."\n";
$filecontent=file_get_contents($dir.'/'.$file);
......@@ -167,7 +167,7 @@ class CodingSqlTest extends PHPUnit_Framework_TestCase
$result=strpos($filecontent,'ON DELETE CASCADE');
print __METHOD__." Result for checking we don't have 'ON DELETE CASCADE' = ".$result."\n";
$this->assertTrue($result===false, 'Found ON DELETE CASCADE into '.$file.'. Bad.');
if ($dir == DOL_DOCUMENT_ROOT.'/install/mysql/migration')
{
// Test for migration files only
......@@ -176,16 +176,20 @@ class CodingSqlTest extends PHPUnit_Framework_TestCase
else
{
if (preg_match('/\.key\.sql$/',$file))
{
// Test for files key files only
{
// Test for key files only
}
else
{
// Test for files non key files only
// Test for non key files only
$result=(strpos($filecontent,'KEY ') && strpos($filecontent,'PRIMARY KEY ') == 0);
print __METHOD__." Result for checking we don't have ' KEY ' instead of a sql file to create index = ".$result."\n";
$this->assertTrue($result===false, 'Found KEY into '.$file.'. Bad.');
$result=stripos($filecontent,'ENGINE=innodb');
print __METHOD__." Result for checking we have the ENGINE=innodb string = ".$result."\n";
$this->assertGreaterThan(0, $result, 'The ENGINE=innodb was not found into '.$file.'. Add it or just fix syntax to match case.');
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment