12-05-2026 Frontend dev
This commit is contained in:
parent
405df0a122
commit
5b8bdf4182
779 changed files with 480564 additions and 6241 deletions
87
tests/Feature/HasUniqueSlugTest.php
Normal file
87
tests/Feature/HasUniqueSlugTest.php
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
|
||||
use App\Enums\Portal;
|
||||
use App\Models\Company;
|
||||
use App\Models\PressRelease;
|
||||
use Tests\TestCase;
|
||||
|
||||
test('press release slug is unique within portal and language scope', function () {
|
||||
/** @var TestCase $this */
|
||||
$base = (new PressRelease)->generateUniqueSlug('Test Mitteilung', [
|
||||
'portal' => Portal::Presseecho->value,
|
||||
'language' => 'de',
|
||||
]);
|
||||
|
||||
expect($base)->toBe('test-mitteilung');
|
||||
|
||||
PressRelease::factory()->create([
|
||||
'portal' => Portal::Presseecho->value,
|
||||
'language' => 'de',
|
||||
'slug' => 'test-mitteilung',
|
||||
]);
|
||||
|
||||
$next = (new PressRelease)->generateUniqueSlug('Test Mitteilung', [
|
||||
'portal' => Portal::Presseecho->value,
|
||||
'language' => 'de',
|
||||
]);
|
||||
|
||||
expect($next)->toBe('test-mitteilung-2');
|
||||
|
||||
// Same slug allowed in another portal
|
||||
$foreign = (new PressRelease)->generateUniqueSlug('Test Mitteilung', [
|
||||
'portal' => Portal::Businessportal24->value,
|
||||
'language' => 'de',
|
||||
]);
|
||||
|
||||
expect($foreign)->toBe('test-mitteilung');
|
||||
|
||||
// Same slug allowed in another language
|
||||
$en = (new PressRelease)->generateUniqueSlug('Test Mitteilung', [
|
||||
'portal' => Portal::Presseecho->value,
|
||||
'language' => 'en',
|
||||
]);
|
||||
|
||||
expect($en)->toBe('test-mitteilung');
|
||||
});
|
||||
|
||||
test('press release editing keeps own slug stable', function () {
|
||||
/** @var TestCase $this */
|
||||
$pr = PressRelease::factory()->create([
|
||||
'portal' => Portal::Presseecho->value,
|
||||
'language' => 'de',
|
||||
'slug' => 'meine-mitteilung',
|
||||
]);
|
||||
|
||||
$regenerated = $pr->generateUniqueSlug('Meine Mitteilung', [
|
||||
'portal' => Portal::Presseecho->value,
|
||||
'language' => 'de',
|
||||
]);
|
||||
|
||||
expect($regenerated)->toBe('meine-mitteilung');
|
||||
});
|
||||
|
||||
test('company slug is unique within portal scope', function () {
|
||||
/** @var TestCase $this */
|
||||
Company::factory()->create([
|
||||
'portal' => Portal::Presseecho->value,
|
||||
'slug' => 'acme-gmbh',
|
||||
]);
|
||||
|
||||
$slug = (new Company)->generateUniqueSlug('Acme GmbH', ['portal' => Portal::Presseecho->value]);
|
||||
expect($slug)->toBe('acme-gmbh-2');
|
||||
|
||||
$other = (new Company)->generateUniqueSlug('Acme GmbH', ['portal' => Portal::Businessportal24->value]);
|
||||
expect($other)->toBe('acme-gmbh');
|
||||
});
|
||||
|
||||
test('blank source falls back to model defined fallback', function () {
|
||||
/** @var TestCase $this */
|
||||
$prSlug = (new PressRelease)->generateUniqueSlug('---', [
|
||||
'portal' => Portal::Presseecho->value,
|
||||
'language' => 'de',
|
||||
]);
|
||||
expect($prSlug)->toBe('pressemitteilung');
|
||||
|
||||
$coSlug = (new Company)->generateUniqueSlug('!!!', ['portal' => Portal::Presseecho->value]);
|
||||
expect($coSlug)->toBe('company');
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue