*/
protected function nameToSlug($name)
{
- $slug = str_replace(' ', '-', mb_strtolower($name));
- $slug = preg_replace('/[\+\/\\\?\@\}\{\.\,\=\[\]\#\&\!\*\'\;\:\$\%]/', '', $slug);
+ $slug = preg_replace('/[\+\/\\\?\@\}\{\.\,\=\[\]\#\&\!\*\'\;\:\$\%]/', '', mb_strtolower($name));
+ $slug = preg_replace('/\s{2,}/', ' ', $slug);
+ $slug = str_replace(' ', '-', $slug);
if ($slug === "") $slug = substr(md5(rand(1, 500)), 0, 5);
return $slug;
}
public function test_entity_creation()
{
-
// Test Creation
$book = $this->bookCreation();
$chapter = $this->chapterCreation($book);
}
+ public function test_slug_format()
+ {
+ $entityRepo = app(EntityRepo::class);
+ $book = $entityRepo->createFromInput('book', [
+ 'name' => 'PartA / PartB / PartC'
+ ]);
+
+ $this->assertEquals('parta-partb-partc', $book->slug);
+ }
+
}