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

Renamed count to countSubstr, implemented Countable interface

This commit is contained in:
Daniel St. Jules
2014-02-03 23:41:57 -05:00
parent 7313dcc07e
commit 1c13f2ad7e
6 changed files with 53 additions and 27 deletions

View File

@@ -807,7 +807,7 @@ abstract class CommonTest extends PHPUnit_Framework_TestCase
);
}
public function countProvider()
public function countSubstrProvider()
{
return array(
array(0, '', 'foo'),

View File

@@ -565,12 +565,12 @@ class StaticStringyTestCase extends CommonTest
}
/**
* @dataProvider countProvider()
* @dataProvider countSubstrProvider()
*/
public function testCount($expected, $str, $substring, $caseSensitive = true,
$encoding = null)
public function testCountSubstr($expected, $str, $substring,
$caseSensitive = true, $encoding = null)
{
$result = S::count($str, $substring, $caseSensitive, $encoding);
$result = S::countSubstr($str, $substring, $caseSensitive, $encoding);
$this->assertInternalType('int', $result);
$this->assertEquals($expected, $result);
}

View File

@@ -70,6 +70,13 @@ class StringyTestCase extends CommonTest
$this->assertEquals('FÒÔ bÀŘ', $result);
}
public function testCount()
{
$stringy = S::create('Fòô', 'UTF-8');
$this->assertEquals(3, $stringy->count());
$this->assertEquals(3, count($stringy));
}
public function testGetIterator()
{
$stringy = S::create('Fòô Bàř', 'UTF-8');
@@ -721,13 +728,13 @@ class StringyTestCase extends CommonTest
}
/**
* @dataProvider countProvider()
* @dataProvider countSubstrProvider()
*/
public function testCount($expected, $str, $substring, $caseSensitive = true,
$encoding = null)
public function testCountSubstr($expected, $str, $substring,
$caseSensitive = true, $encoding = null)
{
$stringy = S::create($str, $encoding);
$result = $stringy->count($substring, $caseSensitive);
$result = $stringy->countSubstr($substring, $caseSensitive);
$this->assertInternalType('int', $result);
$this->assertEquals($expected, $result);
$this->assertEquals($str, $stringy);