feat: ship creator journey v2 and profile updates
This commit is contained in:
65
tests/Unit/ContentTypeSlugResolverTest.php
Normal file
65
tests/Unit/ContentTypeSlugResolverTest.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
use App\Models\ContentType;
|
||||
use App\Models\ContentTypeSlugHistory;
|
||||
use App\Services\ContentTypes\ContentTypeSlugResolver;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
|
||||
uses(Tests\TestCase::class, RefreshDatabase::class);
|
||||
|
||||
beforeEach(function () {
|
||||
Cache::flush();
|
||||
});
|
||||
|
||||
it('resolves current, historical, and virtual content type slugs', function () {
|
||||
$contentType = ContentType::query()->create([
|
||||
'name' => 'Digital Art',
|
||||
'slug' => 'digital-art',
|
||||
'description' => 'Digital art uploads',
|
||||
'order' => 1,
|
||||
]);
|
||||
|
||||
ContentTypeSlugHistory::query()->create([
|
||||
'content_type_id' => $contentType->id,
|
||||
'old_slug' => 'concept-art',
|
||||
]);
|
||||
|
||||
$resolver = app(ContentTypeSlugResolver::class);
|
||||
|
||||
$current = $resolver->resolve('digital-art');
|
||||
$historical = $resolver->resolve('concept-art');
|
||||
$virtual = $resolver->resolve('artworks', allowVirtual: true);
|
||||
|
||||
expect($current->found())->toBeTrue()
|
||||
->and($current->requiresRedirect())->toBeFalse()
|
||||
->and($current->contentType?->slug)->toBe('digital-art')
|
||||
->and($historical->found())->toBeTrue()
|
||||
->and($historical->requiresRedirect())->toBeTrue()
|
||||
->and($historical->redirectSlug)->toBe('digital-art')
|
||||
->and($historical->contentType?->id)->toBe($contentType->id)
|
||||
->and($virtual->found())->toBeTrue()
|
||||
->and($virtual->isVirtual)->toBeTrue()
|
||||
->and($virtual->virtualType)->toBe('artworks');
|
||||
});
|
||||
|
||||
it('reports reserved and historical slug conflicts', function () {
|
||||
$contentType = ContentType::query()->create([
|
||||
'name' => 'Photography',
|
||||
'slug' => 'photography',
|
||||
'description' => 'Photography uploads',
|
||||
'order' => 1,
|
||||
]);
|
||||
|
||||
ContentTypeSlugHistory::query()->create([
|
||||
'content_type_id' => $contentType->id,
|
||||
'old_slug' => 'photos',
|
||||
]);
|
||||
|
||||
$resolver = app(ContentTypeSlugResolver::class);
|
||||
|
||||
expect($resolver->isReservedSlug('help'))->toBeTrue()
|
||||
->and($resolver->isReservedSlug('photography'))->toBeFalse()
|
||||
->and($resolver->historicalSlugExists('photos'))->toBeTrue()
|
||||
->and($resolver->historicalSlugExists('photos', $contentType->id))->toBeFalse();
|
||||
});
|
||||
Reference in New Issue
Block a user