コード例 #1
0
 /**
  * Test that the "slugged" event is fired.
  *
  * @todo Figure out how to accurately test Eloquent model events
  */
 public function testSluggedEvent()
 {
     $this->markTestIncomplete('Event tests are not yet reliable.');
     $post = Post::create(['title' => 'My Test Post']);
     $this->assertEquals('my-test-post', $post->slug);
     $this->assertEquals('I have been slugged!', $post->subtitle);
 }
コード例 #2
0
 /**
  * Test that we generate unique slugs in a static context.
  *
  * @test
  */
 public function testStaticSlugGeneratorWhenEntriesExist()
 {
     $post = Post::create(['title' => 'My Test Post']);
     $this->assertEquals('my-test-post', $post->slug);
     $slug = SlugService::createSlug(Post::class, 'slug', 'My Test Post');
     $this->assertEquals('my-test-post-1', $slug);
 }
コード例 #3
0
 /**
  * Test that the slug is regenerated if the field is emptied manually.
  *
  * @test
  */
 public function testSlugDoesChangeWhenEmptiedManually()
 {
     $post = Post::create(['title' => 'My First Post']);
     $post->save();
     $this->assertEquals('my-first-post', $post->slug);
     $post->slug = null;
     $post->update(['title' => 'A New Title']);
     $this->assertEquals('a-new-title', $post->slug);
 }
コード例 #4
0
 /**
  * Test uniqueness after deletion.
  *
  * @test
  */
 public function testUniqueAfterDelete()
 {
     $post1 = Post::create(['title' => 'A post title']);
     $this->assertEquals('a-post-title', $post1->slug);
     $post2 = Post::create(['title' => 'A post title']);
     $this->assertEquals('a-post-title-1', $post2->slug);
     $post1->delete();
     $post3 = Post::create(['title' => 'A post title']);
     $this->assertEquals('a-post-title', $post3->slug);
 }
コード例 #5
0
 /**
  * Test that models aren't *re*slugged if the slug field is defined (issue #32)
  *
  * @test
  */
 public function testDoesNotNeedSluggingWithUpdateWhenSlugIsSet()
 {
     $post = Post::create(['title' => 'My first post', 'slug' => 'custom-slug']);
     $this->assertEquals('custom-slug', $post->slug);
     $post->title = 'A New Title';
     $post->save();
     $this->assertEquals('custom-slug', $post->slug);
     $post->title = 'A Another New Title';
     $post->slug = 'new-custom-slug';
     $post->save();
     $this->assertEquals('new-custom-slug', $post->slug);
 }
コード例 #6
0
 /**
  * Test subscript characters in slug field
  */
 public function testSubscriptCharacters()
 {
     $post = new Post(['title' => 'RDA-125-15/30/45m³/h CAV']);
     $post->save();
     $this->assertEquals('rda-125-15-30-45m3-h-cav', $post->slug);
 }