![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/job-board.corals.io/vendor/cviebrock/eloquent-sluggable/tests/ |
<?php namespace Cviebrock\EloquentSluggable\Tests; use Cviebrock\EloquentSluggable\Services\SlugService; use Cviebrock\EloquentSluggable\Tests\Models\Post; /** * Class StaticTests * * @package Tests */ class StaticTests extends TestCase { /** * Test that we can generate a slug statically. */ public function testStaticSlugGenerator(): void { $slug = SlugService::createSlug(Post::class, 'slug', 'My Test Post'); self::assertEquals('my-test-post', $slug); } /** * Test that we generate unique slugs in a static context. */ public function testStaticSlugGeneratorWhenEntriesExist(): void { $post = Post::create(['title' => 'My Test Post']); self::assertEquals('my-test-post', $post->slug); $slug = SlugService::createSlug(Post::class, 'slug', 'My Test Post'); self::assertEquals('my-test-post-2', $slug); } /** * Test that we can generate a slug statically with different configuration. */ public function testStaticSlugGeneratorWithConfig(): void { $config = [ 'separator' => '.' ]; $slug = SlugService::createSlug(Post::class, 'slug', 'My Test Post', $config); self::assertEquals('my.test.post', $slug); } /** * Test passing an invalid attribute to static method */ public function testStaticSlugWithInvalidAttribute(): void { $this->expectException(\InvalidArgumentException::class); SlugService::createSlug(Post::class, 'foo', 'My Test Post'); } }