Permalink
Browse files

Adding tests for Inflector::slug with non-latin characters & removing…

… redundant element in preg_replace map.
  • Loading branch information...
jperras committed Jul 25, 2009
1 parent 659c1a6 commit 54d157727623774282ecf2aefe16d47193d71a6f
Showing with 9 additions and 1 deletion.
  1. +1 −1 cake/libs/inflector.php
  2. +8 −0 cake/tests/cases/libs/inflector.test.php
View
@@ -447,7 +447,7 @@ function slug($string, $replacement = '_', $map = array()) {
'/Ü/' => '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) => '',
);
@@ -204,6 +204,14 @@ function testInflectorSlug() {
$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

0 comments on commit 54d1577

Please sign in to comment.