forked from Wavyzz/dolibarr
fix tests
This commit is contained in:
@@ -3173,12 +3173,12 @@ function dol_substr($string, $start, $length, $stringencoding = '', $trunconbyte
|
||||
|
||||
|
||||
/**
|
||||
* Truncate a string to a particular length adding '...' if string larger than length.
|
||||
* If length = max length+1, we do no truncate to avoid having just 1 char replaced with '...'.
|
||||
* Truncate a string to a particular length adding '…' if string larger than length.
|
||||
* If length = max length+1, we do no truncate to avoid having just 1 char replaced with '…'.
|
||||
* MAIN_DISABLE_TRUNC=1 can disable all truncings
|
||||
*
|
||||
* @param string $string String to truncate
|
||||
* @param int $size Max string size visible (excluding …). 0 for no limit. WARNING: Final string size can have 3 more chars (if we added ..., or if size was max+1 or max+2 or max+3 so it does not worse to replace with ...)
|
||||
* @param int $size Max string size visible (excluding …). 0 for no limit. WARNING: Final string size can have 3 more chars (if we added …, or if size was max+1 so it does not worse to replace with ...)
|
||||
* @param string $trunc Where to trunc: 'right', 'left', 'middle' (size must be a 2 power), 'wrap'
|
||||
* @param string $stringencoding Tell what is source string encoding
|
||||
* @param int $nodot Truncation do not add … after truncation. So it's an exact truncation.
|
||||
|
||||
@@ -765,21 +765,21 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase
|
||||
*/
|
||||
public function testDolTrunc()
|
||||
{
|
||||
// Default trunc (will add ... if truncation truncation or keep last char if only one char)
|
||||
// Default trunc (will add … if truncation truncation or keep last char if only one char)
|
||||
$input="éeéeéeàa";
|
||||
$after=dol_trunc($input, 3);
|
||||
$this->assertEquals("éeé...", $after, 'Test A1');
|
||||
$this->assertEquals("éeé…", $after, 'Test A1');
|
||||
$after=dol_trunc($input, 2);
|
||||
$this->assertEquals("ée...", $after, 'Test A2');
|
||||
$this->assertEquals("ée…", $after, 'Test A2');
|
||||
$after=dol_trunc($input, 1);
|
||||
$this->assertEquals("é...", $after, 'Test A3');
|
||||
$this->assertEquals("é…", $after, 'Test A3');
|
||||
$input="éeéeé";
|
||||
$after=dol_trunc($input, 3);
|
||||
$this->assertEquals("éeéeé", $after, 'Test B1');
|
||||
$after=dol_trunc($input, 2);
|
||||
$this->assertEquals("éeéeé", $after, 'Test B2');
|
||||
$after=dol_trunc($input, 1);
|
||||
$this->assertEquals("é...", $after, 'Test B3');
|
||||
$this->assertEquals("é…", $after, 'Test B3');
|
||||
$input="éeée";
|
||||
$after=dol_trunc($input, 3);
|
||||
$this->assertEquals("éeée", $after, 'Test C1');
|
||||
@@ -794,7 +794,7 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase
|
||||
$this->assertEquals("éeé", $after, 'Test D');
|
||||
$after=dol_trunc($input, 1);
|
||||
$this->assertEquals("éeé", $after, 'Test E');
|
||||
// Trunc with no ...
|
||||
// Trunc with no …
|
||||
$input="éeéeéeàa";
|
||||
$after=dol_trunc($input, 3, 'right', 'UTF-8', 1);
|
||||
$this->assertEquals("éeé", $after, 'Test F');
|
||||
@@ -809,7 +809,7 @@ class FunctionsLibTest extends PHPUnit\Framework\TestCase
|
||||
$this->assertEquals("é", $after, 'Test J');
|
||||
$input="éeéeéeàa";
|
||||
$after=dol_trunc($input, 4, 'middle');
|
||||
$this->assertEquals("ée...àa", $after, 'Test K');
|
||||
$this->assertEquals("ée…àa", $after, 'Test K');
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user