1
0
mirror of https://github.com/danielstjules/Stringy.git synced 2025-08-12 00:04:11 +02:00

Add stripWhitespace

This commit is contained in:
Viktor Persson
2016-12-20 19:40:02 +01:00
parent 0607751e17
commit d80347e72a
2 changed files with 42 additions and 0 deletions

View File

@@ -1727,6 +1727,36 @@ class StringyTestCase extends PHPUnit_Framework_TestCase
);
}
/**
* @dataProvider stripWhitespaceProvider()
*/
public function testStripWhitespace($expected, $str, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->stripWhitespace();
$this->assertStringy($result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);
}
public function stripWhitespaceProvider()
{
return array(
array('foobar', ' foo bar '),
array('teststring', 'test string'),
array('Οσυγγραφέας', ' Ο συγγραφέας '),
array('123', ' 123 '),
array('', ' ', 'UTF-8'), // no-break space (U+00A0)
array('', ' ', 'UTF-8'), // spaces U+2000 to U+200A
array('', '', 'UTF-8'), // narrow no-break space (U+202F)
array('', '', 'UTF-8'), // medium mathematical space (U+205F)
array('', ' ', 'UTF-8'), // ideographic space (U+3000)
array('123', '  123  ', 'UTF-8'),
array('', ' '),
array('', ''),
);
}
/**
* @dataProvider substrProvider()
*/