NEW Add a protection into PHPunit to avoid to forget a var_dump
This commit is contained in:
parent
4de50da0dd
commit
5f0a34166d
@ -210,8 +210,8 @@ function run_sql($sqlfile, $silent = 1, $entity = '', $usesavepoint = 1, $handle
|
|||||||
if (!empty($reg[2])) {
|
if (!empty($reg[2])) {
|
||||||
if (is_numeric($reg[2])) { // This is a version
|
if (is_numeric($reg[2])) { // This is a version
|
||||||
$versionrequest = explode('.', $reg[2]);
|
$versionrequest = explode('.', $reg[2]);
|
||||||
//print var_dump($versionrequest);
|
//var_dump($versionrequest);
|
||||||
//print var_dump($versionarray);
|
//var_dump($versionarray);
|
||||||
if (!count($versionrequest) || !count($versionarray) || versioncompare($versionrequest, $versionarray) > 0) {
|
if (!count($versionrequest) || !count($versionarray) || versioncompare($versionrequest, $versionarray) > 0) {
|
||||||
$qualified = 0;
|
$qualified = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -295,8 +295,8 @@ if ($action == "set") {
|
|||||||
// MySQL
|
// MySQL
|
||||||
if ($choix == 1 && preg_match('/^--\sV([0-9\.]+)/i', $buf, $reg)) {
|
if ($choix == 1 && preg_match('/^--\sV([0-9\.]+)/i', $buf, $reg)) {
|
||||||
$versioncommande = explode('.', $reg[1]);
|
$versioncommande = explode('.', $reg[1]);
|
||||||
//print var_dump($versioncommande);
|
//var_dump($versioncommande);
|
||||||
//print var_dump($versionarray);
|
//var_dump($versionarray);
|
||||||
if (count($versioncommande) && count($versionarray)
|
if (count($versioncommande) && count($versionarray)
|
||||||
&& versioncompare($versioncommande, $versionarray) <= 0) {
|
&& versioncompare($versioncommande, $versionarray) <= 0) {
|
||||||
// Version qualified, delete SQL comments
|
// Version qualified, delete SQL comments
|
||||||
@ -307,8 +307,8 @@ if ($action == "set") {
|
|||||||
// PGSQL
|
// PGSQL
|
||||||
if ($choix == 2 && preg_match('/^--\sPOSTGRESQL\sV([0-9\.]+)/i', $buf, $reg)) {
|
if ($choix == 2 && preg_match('/^--\sPOSTGRESQL\sV([0-9\.]+)/i', $buf, $reg)) {
|
||||||
$versioncommande = explode('.', $reg[1]);
|
$versioncommande = explode('.', $reg[1]);
|
||||||
//print var_dump($versioncommande);
|
//var_dump($versioncommande);
|
||||||
//print var_dump($versionarray);
|
//var_dump($versionarray);
|
||||||
if (count($versioncommande) && count($versionarray)
|
if (count($versioncommande) && count($versionarray)
|
||||||
&& versioncompare($versioncommande, $versionarray) <= 0) {
|
&& versioncompare($versioncommande, $versionarray) <= 0) {
|
||||||
// Version qualified, delete SQL comments
|
// Version qualified, delete SQL comments
|
||||||
|
|||||||
@ -56,7 +56,7 @@ dol_syslog("Call method ".$WS_METHOD);
|
|||||||
$result = $soapclient->call($WS_METHOD,$parameters);
|
$result = $soapclient->call($WS_METHOD,$parameters);
|
||||||
if (! $result)
|
if (! $result)
|
||||||
{
|
{
|
||||||
var_dump($soapclient);
|
//var_dump($soapclient);
|
||||||
print '<h2>Erreur SOAP 1</h2>'.$soapclient->error_str;
|
print '<h2>Erreur SOAP 1</h2>'.$soapclient->error_str;
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -199,6 +199,7 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase
|
|||||||
|| preg_match('/modules\/.*\/doc\/(doc|pdf)_/', $file['relativename'])
|
|| preg_match('/modules\/.*\/doc\/(doc|pdf)_/', $file['relativename'])
|
||||||
|| preg_match('/modules\/(import|mailings|printing)\//', $file['relativename'])
|
|| preg_match('/modules\/(import|mailings|printing)\//', $file['relativename'])
|
||||||
|| in_array($file['name'], array('modules_boxes.php', 'rapport.pdf.php', 'TraceableDB.php'))) {
|
|| in_array($file['name'], array('modules_boxes.php', 'rapport.pdf.php', 'TraceableDB.php'))) {
|
||||||
|
// Check into Class files
|
||||||
if (! in_array($file['name'], array(
|
if (! in_array($file['name'], array(
|
||||||
'api.class.php',
|
'api.class.php',
|
||||||
'commonobject.class.php',
|
'commonobject.class.php',
|
||||||
@ -224,6 +225,7 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase
|
|||||||
//exit;
|
//exit;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
// Check into Include files
|
||||||
if (! in_array($file['name'], array(
|
if (! in_array($file['name'], array(
|
||||||
'objectline_view.tpl.php',
|
'objectline_view.tpl.php',
|
||||||
'extrafieldsinexport.inc.php',
|
'extrafieldsinexport.inc.php',
|
||||||
@ -245,6 +247,25 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if a var_dump has been forgotten
|
||||||
|
if (!preg_match('/test\/phpunit/', $file['fullname'])) {
|
||||||
|
$ok=true;
|
||||||
|
$matches=array();
|
||||||
|
preg_match_all('/(.)\s*var_dump/', $filecontent, $matches, PREG_SET_ORDER);
|
||||||
|
//var_dump($matches);
|
||||||
|
foreach ($matches as $key => $val) {
|
||||||
|
if ($val[1] != '/' && $val[1] != '*') {
|
||||||
|
$ok=false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
//print __METHOD__." Result for checking we don't have non escaped string in sql requests for file ".$file."\n";
|
||||||
|
$this->assertTrue($ok, 'Found string var_dump that is not just after /* or // in '.$file['relativename']);
|
||||||
|
//exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check get_class followed by __METHOD__
|
||||||
$ok=true;
|
$ok=true;
|
||||||
$matches=array();
|
$matches=array();
|
||||||
preg_match_all('/'.preg_quote('get_class($this)."::".__METHOD__', '/').'/', $filecontent, $matches, PREG_SET_ORDER);
|
preg_match_all('/'.preg_quote('get_class($this)."::".__METHOD__', '/').'/', $filecontent, $matches, PREG_SET_ORDER);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user