Adding tests for Inflector::slug with non-latin characters & removing redundant element in preg_replace map.

This commit is contained in:
jperras 2009-07-25 15:10:21 -04:00
parent 659c1a65bc
commit 54d1577276
2 changed files with 9 additions and 1 deletions

View file

@ -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) => '',
);

View file

@ -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