From e4e18710dc06e4616727ad945e9f193e6ab094b2 Mon Sep 17 00:00:00 2001 From: Antonio Ramirez Date: Sat, 1 Jun 2013 17:31:55 +0200 Subject: [PATCH] fix functionality, keep each function to do what it supposed to do --- framework/yii/helpers/base/Inflector.php | 3 ++- tests/unit/framework/helpers/InflectorTest.php | 2 -- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/framework/yii/helpers/base/Inflector.php b/framework/yii/helpers/base/Inflector.php index 561468a..7454e4e 100644 --- a/framework/yii/helpers/base/Inflector.php +++ b/framework/yii/helpers/base/Inflector.php @@ -470,6 +470,7 @@ class Inflector public static function slug($string, $replacement = '-') { $map = array( + '/[^\w\s]/' => ' ', '/\\s+/' => $replacement, '/(?<=[a-z])([A-Z])/' => $replacement . '\\1', str_replace(':rep', preg_quote($replacement, '/'), '/^[:rep]+|[:rep]+$/') => '' @@ -512,7 +513,7 @@ class Inflector */ public static function ascii($string) { - $map = static::$transliteration + array('/[^\w\s]/' => ' '); + $map = static::$transliteration; return preg_replace(array_keys($map), array_values($map), $string); } } diff --git a/tests/unit/framework/helpers/InflectorTest.php b/tests/unit/framework/helpers/InflectorTest.php index 5a99346..f7de66f 100644 --- a/tests/unit/framework/helpers/InflectorTest.php +++ b/tests/unit/framework/helpers/InflectorTest.php @@ -143,8 +143,6 @@ class InflectorTest extends TestCase Inflector::ascii("Perché l'erba è verde?", "'")); $this->assertEquals("Peux-tu m aider s il te plait", Inflector::ascii("Peux-tu m'aider s'il te plaît?", "'")); - $this->assertEquals("Tank-efter-nu-forrn-vi-foser-dig-bort", - Inflector::slug(Inflector::ascii("Tänk efter nu – förr'n vi föser dig bort"))); $this->assertEquals("Custom delimiter example", Inflector::ascii("Custom`delimiter*example", array('*', '`'))); }