$length -= $eLength;
$string = substr( $string, 0, $length ); // xyz...
$string = $this->removeBadCharLast( $string );
+ $string = rtrim( $string );
$string = $string . $ellipsis;
} else {
$length += $eLength;
$string = substr( $string, $length ); // ...xyz
$string = $this->removeBadCharFirst( $string );
+ $string = ltrim( $string );
$string = $ellipsis . $string;
}
}
$this->getLang()->truncate( "123456789", -5, 'XXXXXXXXXXXXXXX' ),
'truncate suffix, large ellipsis'
);
+ $this->assertEquals(
+ "123XXX",
+ $this->getLang()->truncate( "123 ", 9, 'XXX' ),
+ 'truncate prefix, with spaces'
+ );
+ $this->assertEquals(
+ "12345XXX",
+ $this->getLang()->truncate( "12345 8", 11, 'XXX' ),
+ 'truncate prefix, with spaces and non-space ending'
+ );
+ $this->assertEquals(
+ "XXX234",
+ $this->getLang()->truncate( "1 234", -8, 'XXX' ),
+ 'truncate suffix, with spaces'
+ );
+ $this->assertEquals(
+ "12345XXX",
+ $this->getLang()->truncate( "1234567890", 5, 'XXX', false ),
+ 'truncate without adjustment'
+ );
}
/**