Skip to content

Commit 8668ada

Browse files
add test
Co-Authored-By: Bart Waardenburg <bartwaardenburg@gmail.com>
1 parent 28bed54 commit 8668ada

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tests/Terms/TermTest.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,41 @@ public function it_applies_taxonomy_wheres_using_pluck_count_and_get()
117117
$this->assertSame(1, $taxonomy->queryTerms()->count());
118118
$this->assertSame($term->slug(), $taxonomy->queryTerms()->get()->pluck('slug')->first());
119119
}
120+
121+
#[Test]
122+
public function it_does_not_cache_null_taxonomy_lookups()
123+
{
124+
$taxonomy = TaxonomyFacade::findByHandle('future');
125+
$this->assertNull($taxonomy);
126+
127+
// Create taxonomy directly in DB, bypassing TaxonomyRepository::save().
128+
$modelClass = app('statamic.eloquent.taxonomies.model');
129+
$modelClass::create([
130+
'handle' => 'future',
131+
'title' => 'Future Taxonomy',
132+
'sites' => ['en'],
133+
'settings' => [],
134+
]);
135+
136+
$taxonomy = TaxonomyFacade::findByHandle('future');
137+
138+
$this->assertNotNull($taxonomy);
139+
$this->assertEquals('future', $taxonomy->handle());
140+
}
141+
142+
#[Test]
143+
public function it_queries_terms_with_taxonomy_available()
144+
{
145+
Taxonomy::make('tags')->title('Tags')->save();
146+
TermFacade::make('test-tag')->taxonomy('tags')->data(['title' => 'Test Tag'])->save();
147+
148+
Blink::flush();
149+
150+
$terms = TermFacade::query()->get();
151+
152+
$this->assertCount(1, $terms);
153+
$this->assertEquals('test-tag', $terms->first()->slug());
154+
$this->assertNotNull($terms->first()->taxonomy());
155+
$this->assertEquals('tags', $terms->first()->taxonomy()->handle());
156+
}
120157
}

0 commit comments

Comments
 (0)