forked from Wavyzz/dolibarr
NEW Add phpunit to check the engine is defined into sql create files.
This commit is contained in:
@@ -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.');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user