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

Add between

This commit is contained in:
Daniel St. Jules
2015-07-24 13:34:07 -07:00
parent 9d5a06cf37
commit 342ef7c3dd
3 changed files with 72 additions and 0 deletions

View File

@@ -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()
*/