From 5ceb8163de1f7c3399c45bdd8ec1017a84926690 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Sun, 21 Feb 2021 15:40:03 +0100 Subject: [PATCH] fix tests --- htdocs/core/lib/functions.lib.php | 6 +++--- test/phpunit/FunctionsLibTest.php | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 3604308708b..128f6ffff16 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -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 { diff --git a/test/phpunit/FunctionsLibTest.php b/test/phpunit/FunctionsLibTest.php index fe9d0563167..9d626208af5 100644 --- a/test/phpunit/FunctionsLibTest.php +++ b/test/phpunit/FunctionsLibTest.php @@ -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";