fix tests

This commit is contained in:
Frédéric FRANCE 2021-02-21 15:40:03 +01:00
parent 548820011a
commit 5ceb8163de
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
2 changed files with 6 additions and 6 deletions

View File

@ -3197,12 +3197,12 @@ function dol_trunc($string, $size = 40, $trunc = 'right', $stringencoding = 'UTF
$stringencoding = 'UTF-8';
}
// reduce for small screen
// if ($conf->dol_optimize_smallscreen == 1 && $display == 1) $size = round($size / 3);
if ($conf->dol_optimize_smallscreen == 1 && $display == 1) $size = round($size / 3);
// We go always here
if ($trunc == 'right') {
$newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string;
if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 2))) {
if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3))) {
// If nodot is 0 and size is 1 chars more, we don't trunc and don't add …
return dol_substr($newstring, 0, $size, $stringencoding).($nodot ? '' : '…');
} else {
@ -3220,7 +3220,7 @@ function dol_trunc($string, $size = 40, $trunc = 'right', $stringencoding = 'UTF
}
} elseif ($trunc == 'left') {
$newstring = dol_textishtml($string) ? dol_string_nohtmltag($string, 1) : $string;
if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 2))) {
if (dol_strlen($newstring, $stringencoding) > ($size + ($nodot ? 0 : 3))) {
// If nodot is 0 and size is 1 chars more, we don't trunc and don't add …
return '…'.dol_substr($newstring, dol_strlen($newstring, $stringencoding) - $size, $size, $stringencoding);
} else {

View File

@ -773,11 +773,11 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase
$this->assertEquals("ée…", $after, 'Test A2');
$after=dol_trunc($input, 1);
$this->assertEquals("é…", $after, 'Test A3');
$input="éeéeé";
$input="éeée";
$after=dol_trunc($input, 3);
$this->assertEquals("éeéeé", $after, 'Test B1');
$this->assertEquals("éeée", $after, 'Test B1');
$after=dol_trunc($input, 2);
$this->assertEquals("éeéeé", $after, 'Test B2');
$this->assertEquals("ée", $after, 'Test B2');
$after=dol_trunc($input, 1);
$this->assertEquals("é…", $after, 'Test B3');
$input="éeée";