1
0
mirror of https://github.com/danielstjules/Stringy.git synced 2025-08-16 18:24:03 +02:00

Added $caseSensitive to count()

This commit is contained in:
Daniel St. Jules
2013-09-14 14:57:18 -04:00
parent d862f9c24c
commit 41ea0277b2
6 changed files with 40 additions and 18 deletions

View File

@@ -907,7 +907,14 @@ abstract class CommonTest extends PHPUnit_Framework_TestCase
array(0, '', 'fòô', 'UTF-8'),
array(0, 'fòô', 'bàř', 'UTF-8'),
array(1, 'fòô bàř', 'fòô', 'UTF-8'),
array(2, 'fôòô bàř', 'ô', 'UTF-8')
array(2, 'fôòô bàř', 'ô', 'UTF-8'),
array(0, 'fÔÒÔ bàř', 'ô', 'UTF-8'),
array(0, 'foo', 'BAR', false),
array(1, 'foo bar', 'FOo', false),
array(2, 'foo bar', 'O', false),
array(1, 'fòô bàř', 'fÒÔ', false, 'UTF-8'),
array(2, 'fôòô bàř', 'Ô', false, 'UTF-8'),
array(2, 'συγγραφέας', 'Σ', false, 'UTF-8')
);
return $testData;

View File

@@ -554,9 +554,10 @@ class StaticStringyTestCase extends CommonTest
/**
* @dataProvider stringsForCount
*/
public function testCount($expected, $str, $substring, $encoding = null)
public function testCount($expected, $str, $substring, $caseSensitive = true,
$encoding = null)
{
$result = S::count($str, $substring, $encoding);
$result = S::count($str, $substring, $caseSensitive, $encoding);
$this->assertInternalType('int', $result);
$this->assertEquals($expected, $result);
}

View File

@@ -653,10 +653,11 @@ class StringyTestCase extends CommonTest
/**
* @dataProvider stringsForCount
*/
public function testCount($expected, $str, $substring, $encoding = null)
public function testCount($expected, $str, $substring, $caseSensitive = true,
$encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->count($substring);
$result = $stringy->count($substring, $caseSensitive);
$this->assertInternalType('int', $result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);