forked from Wavyzz/dolibarr
Add phpunit testDolStringIsGoodIso
This commit is contained in:
@@ -5635,7 +5635,7 @@ function dol_string_is_good_iso($s)
|
|||||||
$ok=1;
|
$ok=1;
|
||||||
for($scursor=0;$scursor<$len;$scursor++)
|
for($scursor=0;$scursor<$len;$scursor++)
|
||||||
{
|
{
|
||||||
$ordchar=ord($s{$scursor});
|
$ordchar=ord($s[$scursor]);
|
||||||
//print $scursor.'-'.$ordchar.'<br>';
|
//print $scursor.'-'.$ordchar.'<br>';
|
||||||
if ($ordchar < 32 && $ordchar != 13 && $ordchar != 10) { $ok=0; break; }
|
if ($ordchar < 32 && $ordchar != 13 && $ordchar != 10) { $ok=0; break; }
|
||||||
if ($ordchar > 126 && $ordchar < 160) { $ok=0; break; }
|
if ($ordchar > 126 && $ordchar < 160) { $ok=0; break; }
|
||||||
|
|||||||
@@ -1260,4 +1260,25 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase
|
|||||||
|
|
||||||
return true;
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user