This commit is contained in:
Frédéric FRANCE
2019-01-27 13:07:22 +01:00
parent 7ee086b402
commit 24b073771e
48 changed files with 731 additions and 731 deletions

View File

@@ -30,16 +30,16 @@ require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
require_once dirname(__FILE__).'/../../htdocs/core/lib/security.lib.php';
require_once dirname(__FILE__).'/../../htdocs/core/lib/security2.lib.php';
if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1');
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1');
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1');
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session)
if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER', '1');
if (! defined('NOREQUIREDB')) define('NOREQUIREDB', '1');
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN', '1');
if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK', '1');
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', '1');
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1'); // If there is no menu to show
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1'); // If we don't need to load the html.form.class.php
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
if (! defined("NOLOGIN")) define("NOLOGIN", '1'); // If this page is public (can be called outside logged session)
if (empty($user->id))
{
@@ -152,33 +152,33 @@ class CodingSqlTest extends PHPUnit_Framework_TestCase
foreach($filesarray as $key => $file)
{
if (! preg_match('/\.sql$/',$file))
if (! preg_match('/\.sql$/', $file))
continue;
print 'Check sql file '.$file."\n";
$filecontent=file_get_contents($dir.'/'.$file);
$result=strpos($filecontent,'`');
$result=strpos($filecontent, '`');
print __METHOD__." Result for checking we don't have back quote = ".$result."\n";
$this->assertTrue($result===false, 'Found back quote into '.$file.'. Bad.');
$result=strpos($filecontent,'"');
$result=strpos($filecontent, '"');
if ($result)
{
$result=(! strpos($filecontent,'["') && ! strpos($filecontent,'{"'));
$result=(! strpos($filecontent, '["') && ! strpos($filecontent, '{"'));
}
print __METHOD__." Result for checking we don't have double quote = ".$result."\n";
$this->assertTrue($result===false, 'Found double quote that is not [" neither {" (used for json content) into '.$file.'. Bad.');
$result=strpos($filecontent,'int(');
$result=strpos($filecontent, 'int(');
print __METHOD__." Result for checking we don't have 'int(' instead of 'integer' = ".$result."\n";
$this->assertTrue($result===false, 'Found int(x) or tinyint(x) instead of integer or tinyint into '.$file.'. Bad.');
$result=strpos($filecontent,'ON DELETE CASCADE');
$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.');
$result=strpos($filecontent,'NUMERIC(');
$result=strpos($filecontent, 'NUMERIC(');
print __METHOD__." Result for checking we don't have 'NUMERIC(' = ".$result."\n";
$this->assertTrue($result===false, 'Found NUMERIC( into '.$file.'. Bad.');
@@ -192,18 +192,18 @@ class CodingSqlTest extends PHPUnit_Framework_TestCase
}
else
{
if (preg_match('/\.key\.sql$/',$file))
if (preg_match('/\.key\.sql$/', $file))
{
// Test for key files only
}
else
{
// Test for non key files only
$result=(strpos($filecontent,'KEY ') && strpos($filecontent,'PRIMARY KEY') == 0);
$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');
$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.');
}
@@ -229,17 +229,17 @@ class CodingSqlTest extends PHPUnit_Framework_TestCase
$filesarray = scandir(DOL_DOCUMENT_ROOT.'/../dev/initdata');
foreach($filesarray as $key => $file) {
if (! preg_match('/\.sql$/',$file))
if (! preg_match('/\.sql$/', $file))
continue;
print 'Check sql file '.$file."\n";
$filecontent=file_get_contents(DOL_DOCUMENT_ROOT.'/../dev/initdata/'.$file);
$result=strpos($filecontent,'@gmail.com');
$result=strpos($filecontent, '@gmail.com');
print __METHOD__." Result for checking we don't have personal data = ".$result."\n";
$this->assertTrue($result===false, 'Found a bad key into file '.$file);
$result=strpos($filecontent,'eldy@');
$result=strpos($filecontent, 'eldy@');
print __METHOD__." Result for checking we don't have personal data = ".$result."\n";
$this->assertTrue($result===false, 'Found a bad key into file '.$file);
}