From 54d157727623774282ecf2aefe16d47193d71a6f Mon Sep 17 00:00:00 2001 From: jperras Date: Sat, 25 Jul 2009 15:10:21 -0400 Subject: [PATCH] Adding tests for Inflector::slug with non-latin characters & removing redundant element in preg_replace map. --- cake/libs/inflector.php | 2 +- cake/tests/cases/libs/inflector.test.php | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/cake/libs/inflector.php b/cake/libs/inflector.php index b9fcf9502..c7df92ad9 100644 --- a/cake/libs/inflector.php +++ b/cake/libs/inflector.php @@ -447,7 +447,7 @@ class Inflector extends Object { '/Ü/' => 'Ue', '/Ö/' => 'Oe', '/ß/' => 'ss', - '/[^\w\s\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}]/mu' => ' ', + '/[^\s\p{Ll}\p{Lm}\p{Lo}\p{Lt}\p{Lu}\p{Nd}]/mu' => ' ', '/\\s+/' => $replacement, sprintf('/^[%s]+|[%s]+$/', $quotedReplacement, $quotedReplacement) => '', ); diff --git a/cake/tests/cases/libs/inflector.test.php b/cake/tests/cases/libs/inflector.test.php index 235dc346d..76c2debfd 100644 --- a/cake/tests/cases/libs/inflector.test.php +++ b/cake/tests/cases/libs/inflector.test.php @@ -204,6 +204,14 @@ class InflectorTest extends CakeTestCase { $result = Inflector::slug('controller/action/りんご/1'); $expected = 'controller_action_りんご_1'; $this->assertEqual($result, $expected); + + $result = Inflector::slug('の話が出たので大丈夫かなあと'); + $expected = 'の話が出たので大丈夫かなあと'; + $this->assertEqual($result, $expected); + + $result = Inflector::slug('posts/view/한국어/page:1/sort:asc'); + $expected = 'posts_view_한국어_page_1_sort_asc'; + $this->assertEqual($result, $expected); } /** * testInflectorSlugWithMap method