2
0
forked from Wavyzz/dolibarr

Add phpunit testDolStringIsGoodIso

This commit is contained in:
Laurent Destailleur
2019-08-27 12:25:24 +02:00
parent c2c9e1d042
commit 36c936357c
2 changed files with 22 additions and 1 deletions

View File

@@ -5635,7 +5635,7 @@ function dol_string_is_good_iso($s)
$ok=1;
for($scursor=0;$scursor<$len;$scursor++)
{
$ordchar=ord($s{$scursor});
$ordchar=ord($s[$scursor]);
//print $scursor.'-'.$ordchar.'<br>';
if ($ordchar < 32 && $ordchar != 13 && $ordchar != 10) { $ok=0; break; }
if ($ordchar > 126 && $ordchar < 160) { $ok=0; break; }

View File

@@ -1260,4 +1260,25 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase
return true;
}
/**
* testDolStringIsGoodIso
*
* @return boolean
*/
public function testDolStringIsGoodIso()
{
global $conf, $langs;
$chaine='This is an ISO string';
$result = dol_string_is_good_iso($chaine);
$this->assertEquals($result, 1);
$chaine='This is a not ISO string '.chr(0);
$result = dol_string_is_good_iso($chaine);
$this->assertEquals($result, 0);
return true;
}
}