mirror of
https://github.com/danielstjules/Stringy.git
synced 2025-08-22 12:53:20 +02:00
Update replace() to correctly apply preg_quote to pattern and replacement
This commit is contained in:
@@ -925,12 +925,14 @@ abstract class CommonTest extends PHPUnit_Framework_TestCase
|
||||
$testData = array(
|
||||
array('', '', '', ''),
|
||||
array('foo', '', '', 'foo'),
|
||||
array('foo', '\s', '\s', 'foo'),
|
||||
array('foo bar', 'foo bar', '', ''),
|
||||
array('bar', 'foo bar', 'foo ', ''),
|
||||
array('far bar', 'foo bar', 'foo', 'far'),
|
||||
array('bar bar', 'foo bar foo bar', 'foo ', ''),
|
||||
array('', '', '', '', 'UTF-8'),
|
||||
array('fòô', '', '', 'fòô', 'UTF-8'),
|
||||
array('fòô', '\s', '\s', 'fòô', 'UTF-8'),
|
||||
array('fòô bàř', 'fòô bàř', '', '', 'UTF-8'),
|
||||
array('bàř', 'fòô bàř', 'fòô ', '', 'UTF-8'),
|
||||
array('far bàř', 'fòô bàř', 'fòô', 'far', 'UTF-8'),
|
||||
|
@@ -565,10 +565,10 @@ class StaticStringyTestCase extends CommonTest
|
||||
/**
|
||||
* @dataProvider stringsForReplace
|
||||
*/
|
||||
public function testReplace($expected, $str, $search, $replace,
|
||||
public function testReplace($expected, $str, $search, $replacement,
|
||||
$encoding = null)
|
||||
{
|
||||
$result = S::replace($str, $search, $replace, $encoding);
|
||||
$result = S::replace($str, $search, $replacement, $encoding);
|
||||
$this->assertInternalType('string', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
}
|
||||
|
@@ -666,11 +666,11 @@ class StringyTestCase extends CommonTest
|
||||
/**
|
||||
* @dataProvider stringsForReplace
|
||||
*/
|
||||
public function testReplace($expected, $str, $search, $replace,
|
||||
public function testReplace($expected, $str, $search, $replacement,
|
||||
$encoding = null)
|
||||
{
|
||||
$stringy = S::create($str, $encoding);
|
||||
$result = $stringy->replace($search, $replace);
|
||||
$result = $stringy->replace($search, $replacement);
|
||||
$this->assertInstanceOf('Stringy\Stringy', $result);
|
||||
$this->assertEquals($expected, $result);
|
||||
$this->assertEquals($str, $stringy);
|
||||
|
Reference in New Issue
Block a user