From f0948377096db60ee7c121fb4a94d9af0c359a93 Mon Sep 17 00:00:00 2001 From: Dan Brown Date: Sat, 11 Nov 2017 16:15:08 +0000 Subject: [PATCH] Added test to cover multi-byte slugs Also removed check for 'mb_' functions since mbstring is a dependancy --- app/Repos/EntityRepo.php | 2 +- tests/Entity/EntityTest.php | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/Repos/EntityRepo.php b/app/Repos/EntityRepo.php index 25d229be1..944c0bcfc 100644 --- a/app/Repos/EntityRepo.php +++ b/app/Repos/EntityRepo.php @@ -553,7 +553,7 @@ class EntityRepo */ protected function nameToSlug($name) { - $slug = str_replace(' ', '-', function_exists('mb_strtolower') ? mb_strtolower($name) : strtolower($name)); + $slug = str_replace(' ', '-', mb_strtolower($name)); $slug = preg_replace('/[\+\/\\\?\@\}\{\.\,\=\[\]\#\&\!\*\'\;\:\$\%]/', '', $slug); if ($slug === "") $slug = substr(md5(rand(1, 500)), 0, 5); return $slug; diff --git a/tests/Entity/EntityTest.php b/tests/Entity/EntityTest.php index 07f1926c5..3f23475a0 100644 --- a/tests/Entity/EntityTest.php +++ b/tests/Entity/EntityTest.php @@ -257,4 +257,15 @@ class EntityTest extends BrowserKitTest ->seeInElement('#recently-updated-pages', $page->name); } + public function test_slug_multi_byte_lower_casing() + { + $entityRepo = app(EntityRepo::class); + $book = $entityRepo->createFromInput('book', [ + 'name' => 'КНИГА' + ]); + + $this->assertEquals('книга', $book->slug); + } + + }