From 7b93c34c0f22e1a3a679a6e846b812ce87a3b3e5 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 29 Dec 2020 03:48:11 +0100 Subject: [PATCH] Fix phpunits --- htdocs/core/lib/functions.lib.php | 2 +- .../modules/mailings/xinputfile.modules.php | 1 - htdocs/includes/nusoap/lib/nusoap.php | 2 +- test/phpunit/FunctionsLibTest.php | 29 +++++++++++++++++++ test/phpunit/WebservicesInvoicesTest.php | 9 ++++-- 5 files changed, 37 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 33a09f541c6..909f786beec 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3032,7 +3032,7 @@ function dol_print_address($address, $htmlid, $element, $id, $noprint = 0, $char /** * Return true if email syntax is ok. * - * @param string $address email (Ex: "toto@examle.com", "John Do ") + * @param string $address email (Ex: "toto@examle.com". Long form "John Do " will be false) * @param int $acceptsupervisorkey If 1, the special string '__SUPERVISOREMAIL__' is also accepted as valid * @return boolean true if email syntax is OK, false if KO or empty string * @see isValidMXRecord() diff --git a/htdocs/core/modules/mailings/xinputfile.modules.php b/htdocs/core/modules/mailings/xinputfile.modules.php index afc691f3e2e..a31d1c41483 100644 --- a/htdocs/core/modules/mailings/xinputfile.modules.php +++ b/htdocs/core/modules/mailings/xinputfile.modules.php @@ -162,7 +162,6 @@ class mailing_xinputfile extends MailingTargets if (!empty($buffer)) { //print 'xx'.dol_strlen($buffer).empty($buffer)."
\n"; - $id = $cpt; if (isValidEMail($email)) { if ($old <> $email) diff --git a/htdocs/includes/nusoap/lib/nusoap.php b/htdocs/includes/nusoap/lib/nusoap.php index 459f4aeb7b6..7e0ebd94da4 100644 --- a/htdocs/includes/nusoap/lib/nusoap.php +++ b/htdocs/includes/nusoap/lib/nusoap.php @@ -6125,7 +6125,7 @@ class wsdl extends nusoap_base { $rows = sizeof($value); $contents = ''; foreach($value as $k => $v) { - $this->debug("serializing array element: $k, $v of type: $typeDef[arrayType]"); + $this->debug("serializing array element: $k of type: ".$typeDef['arrayType']); //if (strpos($typeDef['arrayType'], ':') ) { if (!in_array($typeDef['arrayType'],$this->typemap['http://www.w3.org/2001/XMLSchema'])) { $contents .= $this->serializeType('item', $typeDef['arrayType'], $v, $use); diff --git a/test/phpunit/FunctionsLibTest.php b/test/phpunit/FunctionsLibTest.php index 7cbb6af5955..8dc903642e0 100644 --- a/test/phpunit/FunctionsLibTest.php +++ b/test/phpunit/FunctionsLibTest.php @@ -131,6 +131,35 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase print __METHOD__."\n"; } + /** + * testIsValidEmail + * + * @return void + */ + public function testIsValidEmail() + { + // Nb of line is same than entry text + + $input="bidon@bademail"; + $result=isValidEmail($input); + print __METHOD__." result=".$result."\n"; + $this->assertFalse($result, 'Check isValidEmail '.$input); + + $input="test@yahoo.com"; + $result=isValidEmail($input); + print __METHOD__." result=".$result."\n"; + $this->assertTrue($result, 'Check isValidEmail '.$input); + + $input="The name of sender "; + $result=isValidEmail($input); + print __METHOD__." result=".$result."\n"; + $this->assertFalse($result, 'Check isValidEmail '.$input); + + $input="1234.abcdefg@domainame.com.br"; + $result=isValidEmail($input); + print __METHOD__." result=".$result."\n"; + $this->assertTrue($result, 'Check isValidEmail '.$input); + } /** * testIsValidMXRecord diff --git a/test/phpunit/WebservicesInvoicesTest.php b/test/phpunit/WebservicesInvoicesTest.php index beb3e844809..ca9d827f2b8 100644 --- a/test/phpunit/WebservicesInvoicesTest.php +++ b/test/phpunit/WebservicesInvoicesTest.php @@ -61,6 +61,9 @@ class WebservicesInvoicesTest extends PHPUnit\Framework\TestCase protected $ns = 'http://www.dolibarr.org/ns/'; + protected $pass = 'admin'; + + /** * Constructor * We save global variables into local variables @@ -248,7 +251,7 @@ class WebservicesInvoicesTest extends PHPUnit\Framework\TestCase 'dolibarrkey'=>$conf->global->WEBSERVICES_KEY, 'sourceapplication'=>'DEMO', 'login'=>'admin', - 'password'=>'admin', + 'password'=>$this->pass, 'entity'=>''); // Test URL @@ -304,7 +307,7 @@ class WebservicesInvoicesTest extends PHPUnit\Framework\TestCase 'dolibarrkey'=>$conf->global->WEBSERVICES_KEY, 'sourceapplication'=>'DEMO', 'login'=>'admin', - 'password'=>'admin', + 'password'=>$this->pass, 'entity'=>''); // Test URL @@ -403,7 +406,7 @@ class WebservicesInvoicesTest extends PHPUnit\Framework\TestCase 'dolibarrkey'=>$conf->global->WEBSERVICES_KEY, 'sourceapplication'=>'DEMO', 'login'=>'admin', - 'password'=>'admin', + 'password'=>$this->pass, 'entity'=>''); // Test URL