Skip to content

Commit

Permalink
Add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanmitchell committed Nov 20, 2024
1 parent 790b85c commit 2d9befb
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions tests/Terms/TermTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

namespace Tests\Terms;

use Illuminate\Foundation\Testing\RefreshDatabase;
use PHPUnit\Framework\Attributes\Test;
use Statamic\Eloquent\Taxonomies\Taxonomy;
use Statamic\Eloquent\Taxonomies\TermModel;
use Statamic\Facades\Term as TermFacade;
use Tests\TestCase;

class TermTest extends TestCase
{
use RefreshDatabase;

#[Test]
public function it_doesnt_create_a_new_model_when_slug_is_changed()
{
Taxonomy::make('test')->title('test')->save();

$term = tap(TermFacade::make('test-term')->taxonomy('test')->data([]))->save();

$this->assertCount(1, TermModel::all());
$this->assertSame('test-term', TermModel::first()->slug);

$term->slug('new-slug');
$term->save();

$this->assertCount(1, TermModel::all());
$this->assertSame('new-slug', TermModel::first()->slug);
}
}

0 comments on commit 2d9befb

Please sign in to comment.