Skip to content

Commit

Permalink
Add test for slug looping
Browse files Browse the repository at this point in the history
  • Loading branch information
Tofandel authored and ifox committed Oct 14, 2024
1 parent d29a8b3 commit 4c403c1
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/integration/SlugTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,27 @@ public function testBasicSlugModelDuplicate(): void
}
}

public function testSlugLooping(): void
{
$model = $this->module->getRepository()->create([
'title' => 'My title',
'slug' => ['en' => 'my-title'],
]);

$this->assertEquals('my-title', $model->getSlug());

$this->module->getRepository()->update($model->id, ['title' => 'My title 2']);

$this->assertEquals('my-title-2', $model->fresh()->getSlug());

$this->assertCount(2, $model->slugs()->get());

$this->module->getRepository()->update($model->id, ['title' => 'My title']);

$this->assertEquals('my-title', $model->fresh()->getSlug());
$this->assertCount(2, $model->slugs()->get());
}

public function testCanReuseSoftDeletedSlug(): void
{
$model = $this->module->getRepository()->create([
Expand Down

0 comments on commit 4c403c1

Please sign in to comment.