mirror of
https://github.com/danielstjules/Stringy.git
synced 2025-08-11 07:44:12 +02:00
Add between
This commit is contained in:
@@ -1002,6 +1002,41 @@ class StringyTestCase extends PHPUnit_Framework_TestCase
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider betweenProvider()
|
||||
*/
|
||||
public function testBetween($expected, $str, $start, $end, $offset = null,
|
||||
$encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->between($start, $end, $offset);
|
||||
$this->assertStringy($result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
}
|
||||
|
||||
public function betweenProvider()
|
||||
{
|
||||
return array(
|
||||
array('', 'foo', '{', '}'),
|
||||
array('', '{foo', '{', '}'),
|
||||
array('foo', '{foo}', '{', '}'),
|
||||
array('{foo', '{{foo}', '{', '}'),
|
||||
array('', '{}foo}', '{', '}'),
|
||||
array('foo', '}{foo}', '{', '}'),
|
||||
array('foo', 'A description of {foo} goes here', '{', '}'),
|
||||
array('bar', '{foo} and {bar}', '{', '}', 1),
|
||||
array('', 'fòô', '{', '}', 0, 'UTF-8'),
|
||||
array('', '{fòô', '{', '}', 0, 'UTF-8'),
|
||||
array('fòô', '{fòô}', '{', '}', 0, 'UTF-8'),
|
||||
array('{fòô', '{{fòô}', '{', '}', 0, 'UTF-8'),
|
||||
array('', '{}fòô}', '{', '}', 0, 'UTF-8'),
|
||||
array('fòô', '}{fòô}', '{', '}', 0, 'UTF-8'),
|
||||
array('fòô', 'A description of {fòô} goes here', '{', '}', 0, 'UTF-8'),
|
||||
array('bàř', '{fòô} and {bàř}', '{', '}', 1, 'UTF-8')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider containsProvider()
|
||||
*/
|
||||
|
Reference in New Issue
Block a user