From de94451a880d8c40a4e86d30479e79367dc1037d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Sep 2022 14:56:13 +0200 Subject: [PATCH] Add more phpunit to avoid empty and hasRight --- test/phpunit/CodingPhpTest.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/phpunit/CodingPhpTest.php b/test/phpunit/CodingPhpTest.php index 9c9af971616..6af80a304ae 100644 --- a/test/phpunit/CodingPhpTest.php +++ b/test/phpunit/CodingPhpTest.php @@ -552,6 +552,15 @@ class CodingPhpTest extends PHPUnit\Framework\TestCase } $this->assertTrue($ok, 'Found code empty($user->hasRight in file '.$file['relativename'].'. empty() must not be used with hasRight.'); + // Test we don't have empty(DolibarrApiAccess::$user->hasRight + $ok=true; + $matches=array(); + preg_match_all('/empty\(DolibarrApiAccess::\$user->hasRight/', $filecontent, $matches, PREG_SET_ORDER); + foreach ($matches as $key => $val) { + $ok=false; + break; + } + $this->assertTrue($ok, 'Found code empty(DolibarrApiAccess::$user->hasRight in file '.$file['relativename'].'. empty() must not be used with hasRight.'); // Test we don't have @var array( $ok=true;