mirror of
https://github.com/danielstjules/Stringy.git
synced 2025-08-13 16:53:59 +02:00
Fix for collapseWhitespace() not being able to handle multibyte space characters
This commit is contained in:
@@ -173,6 +173,8 @@ abstract class CommonTest extends PHPUnit_Framework_TestCase
|
||||
array('test string', 'test string'),
|
||||
array('Ο συγγραφέας', ' Ο συγγραφέας '),
|
||||
array('123', ' 123 '),
|
||||
array('1 2 3', ' 1 2 3 ', 'UTF-8'), // ideographic spaces
|
||||
array('', ' ', 'UTF-8'), // thin space and space
|
||||
array('', ' '),
|
||||
array('', ''),
|
||||
);
|
||||
|
@@ -111,9 +111,9 @@ class StaticStringyTestCase extends CommonTest
|
||||
/**
|
||||
* @dataProvider stringsForCollapseWhitespace
|
||||
*/
|
||||
public function testCollapseWhitespace($expected, $str)
|
||||
public function testCollapseWhitespace($expected, $str, $encoding = null)
|
||||
{
|
||||
$result = S::collapseWhitespace($str);
|
||||
$result = S::collapseWhitespace($str, $encoding);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
@@ -145,9 +145,9 @@ class StringyTestCase extends CommonTest
|
||||
/**
|
||||
* @dataProvider stringsForCollapseWhitespace
|
||||
*/
|
||||
public function testCollapseWhitespace($expected, $str)
|
||||
public function testCollapseWhitespace($expected, $str, $encoding = null)
|
||||
{
|
||||
$stringy = S::create($str);
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->collapseWhitespace();
|
||||
$this->assertInstanceOf('Stringy\Stringy', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
|
Reference in New Issue
Block a user