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:
@@ -807,7 +807,7 @@ abstract class CommonTest extends PHPUnit_Framework_TestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function countProvider()
|
||||
public function countSubstrProvider()
|
||||
{
|
||||
return array(
|
||||
array(0, '', 'foo'),
|
||||
|
@@ -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);
|
||||
}
|
||||
|
@@ -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);
|
||||
|
Reference in New Issue
Block a user