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

Add startsWith()

This commit is contained in:
Daniel St. Jules
2013-07-18 01:29:52 -04:00
parent 057f0310a7
commit 1311f69e10
3 changed files with 82 additions and 18 deletions

View File

@@ -390,6 +390,33 @@ class StringyTestCase extends PHPUnit_Framework_TestCase {
return $testData;
}
/**
* @dataProvider stringsForStartsWith
*/
public function testStartsWith($expected, $string, $substring,
$caseSensitive = true, $encoding = null) {
$result = S::startsWith($string, $substring, $caseSensitive, $encoding);
$this->assertEquals($expected, $result);
}
public function stringsForStartsWith() {
$testData = array(
array(true, 'foo bars', 'foo bar'),
array(true, 'FOO bars', 'foo bar', false),
array(true, 'FOO bars', 'foo BAR', false),
array(true, 'FÒÔ bàřs', 'fòô bàř', false, 'UTF-8'),
array(true, 'fòô bàřs', 'fòô BÀŘ', false, 'UTF-8'),
array(false, 'foo bar', 'bar'),
array(false, 'foo bar', 'foo bars'),
array(false, 'FOO bar', 'foo bars'),
array(false, 'FOO bars', 'foo BAR'),
array(false, 'FÒÔ bàřs', 'fòô bàř', true, 'UTF-8'),
array(false, 'fòô bàřs', 'fòô BÀŘ', true, 'UTF-8'),
);
return $testData;
}
}
?>