diff --git a/cake/libs/inflector.php b/cake/libs/inflector.php index d847bbd9d..de50a8230 100644 --- a/cake/libs/inflector.php +++ b/cake/libs/inflector.php @@ -521,7 +521,6 @@ class Inflector { $map = $replacement; $replacement = '_'; } - $quotedReplacement = preg_quote($replacement, '/'); $default = array( @@ -544,7 +543,7 @@ class Inflector { sprintf('/^[%s]+|[%s]+$/', $quotedReplacement, $quotedReplacement) => '', ); - $map = array_merge($default, $map); + $map = array_merge($map, $default); return preg_replace(array_keys($map), array_values($map), $string); } } diff --git a/cake/tests/cases/libs/inflector.test.php b/cake/tests/cases/libs/inflector.test.php index f83cb8389..585133eec 100644 --- a/cake/tests/cases/libs/inflector.test.php +++ b/cake/tests/cases/libs/inflector.test.php @@ -236,12 +236,24 @@ class InflectorTest extends CakeTestCase { * @return void */ function testInflectorSlugWithMap() { - $result = Inflector::slug('replace every r', array('/r/' => '_')); - $expected = '_eplace_eve_y__'; + $result = Inflector::slug('replace every r', array('/r/' => '1')); + $expected = '1eplace_eve1y_1'; $this->assertEqual($result, $expected); - $result = Inflector::slug('replace every r', '_', array('/r/' => '_')); - $expected = '_eplace_eve_y__'; + $result = Inflector::slug('replace every r', '_', array('/r/' => '1')); + $expected = '1eplace_eve1y_1'; + $this->assertEqual($result, $expected); + } + +/** + * testInflectorSlugWithMapOverridingDefault method + * + * @access public + * @return void + */ + function testInflectorSlugWithMapOverridingDefault() { + $result = Inflector::slug('Testing æ ø å', '-', array('/å/' => 'aa', '/ø/' => 'oe')); + $expected = 'Testing-ae-oe-aa'; $this->assertEqual($result, $expected); }