public function testDuplicateSlug() { $post1 = SluggablePost::create(['title' => 'Pace yourself']); $post2 = SluggablePost::create(['title' => 'Pace yourself']); $post3 = SluggablePost::create(['title' => 'Pace yourself']); $this->assertEquals('pace-yourself', $post1->slug); $this->assertEquals('pace-yourself-2', $post2->slug); $this->assertEquals('pace-yourself-3', $post3->slug); }
public function testSuffixCollision() { $post1 = SluggablePost::create(['title' => 'Type 1']); $post2 = SluggablePost::create(['title' => 'Type 2']); $post3 = SluggablePost::create(['title' => 'Type 3']); $post4 = SluggablePost::create(['title' => 'Type 3']); $post5 = SluggablePost::create(['title' => 'Type 3']); $this->assertEquals('type-1', $post1->slug); $this->assertEquals('type-2', $post2->slug); $this->assertEquals('type-3', $post3->slug); $this->assertEquals('type-3-2', $post4->slug); $this->assertEquals('type-3-3', $post5->slug); }