Skip to content

Commit

Permalink
Test transforms with context
Browse files Browse the repository at this point in the history
  • Loading branch information
ausi committed Oct 31, 2017
1 parent 0a0a41e commit 4cf5c71
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/SlugGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ private function applyTransformRule(string $text, string $rule, string $locale,
*/
private function transformWithContext(\Transliterator $transliterator, string $text, int $index, int $length): string
{
$left = mb_substr(substr($text, 0, $index), -1, 1, 'UTF-8');
$left = mb_substr(substr($text, 0, $index), -1, null, 'UTF-8');
$right = mb_substr(substr($text, $index + $length), 0, 1, 'UTF-8');

$leftLength = strlen($left);
Expand Down
8 changes: 8 additions & 0 deletions tests/SlugGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,14 @@ public function getGenerate(): array
'',
['validChars' => ''],
],
[
'contextöcontextöcontext',
'CONTEXTöCONTEXTöCONTEXT',
[
'validChars' => 'A-Zö',
'preTransforms' => ['ö > OOOO'],
],
],
];
}

Expand Down

0 comments on commit 4cf5c71

Please sign in to comment.