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

Add contains()

This commit is contained in:
Daniel St. Jules
2013-07-22 00:52:45 -04:00
parent feb4c5a36d
commit 8ddb4b91b5
3 changed files with 59 additions and 2 deletions

View File

@@ -506,6 +506,32 @@ class StringyTestCase extends PHPUnit_Framework_TestCase {
return $testData;
}
/**
* @dataProvider stringsForContains
*/
public function testContains($expected, $haystack, $needle, $encoding = null) {
$result = S::contains($haystack, $needle, $encoding);
$this->assertEquals($expected, $result);
}
public function stringsForContains() {
$testData = array(
array(true, 'This string contains foo bar', 'foo bar'),
array(true, '12398!@(*%!@# @!%#*&^%', ' @!%#*&^%'),
array(true, 'Ο συγγραφέας είπε', 'συγγραφέας', 'UTF-8'),
array(true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', 'å´¥©', 'UTF-8'),
array(true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', 'å˚ ∆', 'UTF-8'),
array(true, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', 'øœ¬', 'UTF-8'),
array(false, 'This string contains foo bar', 'Foo bar'),
array(false, 'This string contains foo bar', 'foobar'),
array(false, 'This string contains foo bar', 'foo bar '),
array(false, 'Ο συγγραφέας είπε', ' συγγραφέας ', 'UTF-8'),
array(false, 'å´¥©¨ˆßå˚ ∆∂˙©å∑¥øœ¬', ' ßå˚', 'UTF-8')
);
return $testData;
}
}
?>