presseportale/tests/Feature/Web/SeedCategoryDescriptionsTest.php
Kevin Adametz 4616bb7aad web: Jahresarchiv je Branche, Kategoriebeschreibungen, Portalname im Titel (Roadmap 2.3)
- /de/category/{slug}/archiv/{jahr} (CategoryArchivePageData,
  CategoryArchiveController, View kategorie-archiv): 30 Meldungen je
  Seite, neueste zuerst, Jahresleiste mit Zahlen; ohne Jahr das juengste
  Jahr mit Meldungen. Canonical mit ?page=N auf Folgeseiten, hreflang
  nur auf Seite 1, CollectionPage + BreadcrumbList. Gecacht bis Seite 3.
  Leere Jahre, unbekannte Kategorien, leere Folgeseiten: 404.
- Branchenseite: Jahresleiste unter dem Feed (archiveYears, eine
  gruppierte Query); Sitemap listet alle Jahresarchive.
- categories:seed-descriptions {--dry-run} {--force}: fuellt leere DE/EN
  Beschreibungen aus database/seeders/data/category-descriptions.php
  (14 Kategorien, sachlich, ohne Werbeaussagen), leert den Seiten-Cache.
- Branchenseite: Titel trug config('app.name') ("– pressekonto") statt
  des Portalnamens — jetzt presseecho/businessportal24.
- Protokoll Teil 5 (2.3 mit Befund: 0 von 14 Beschreibungen, Sonstiges =
  28 % des Bestands), Roadmap 2.3 abgehakt.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-09-17 10:25:29 +00:00

44 lines
2 KiB
PHP

<?php
use App\Enums\Portal;
use App\Models\Category;
use Tests\TestCase;
/**
* `categories:seed-descriptions` (Roadmap 2.3): füllt nur leere Felder,
* --force überschreibt, Dry-Run schreibt nichts.
*/
test('the command fills empty descriptions from the data file and keeps existing ones', function () {
/** @var TestCase $this */
$handel = Category::factory()->create(['portal' => Portal::Both, 'is_active' => true]);
$handel->translations()->create(['locale' => 'de', 'name' => 'Handel', 'slug' => 'handel', 'description' => null]);
$handel->translations()->create(['locale' => 'en', 'name' => 'Commerce', 'slug' => 'commerce', 'description' => 'Own text']);
$this->artisan('categories:seed-descriptions', ['--dry-run' => true])
->expectsOutputToContain('[Dry-Run] Nichts geschrieben.')
->assertSuccessful();
expect($handel->translations()->where('locale', 'de')->value('description'))->toBeNull();
$this->artisan('categories:seed-descriptions')->assertSuccessful();
expect($handel->translations()->where('locale', 'de')->value('description'))->toStartWith('Pressemitteilungen aus dem Handel')
->and($handel->translations()->where('locale', 'en')->value('description'))->toBe('Own text');
$this->artisan('categories:seed-descriptions', ['--force' => true])->assertSuccessful();
expect($handel->translations()->where('locale', 'en')->value('description'))->toStartWith('Press releases from retail');
});
test('every data file entry has a german and an english text within the admin limit', function () {
/** @var array<string, array<string, string>> $texts */
$texts = require database_path('seeders/data/category-descriptions.php');
expect($texts)->toHaveCount(14);
foreach ($texts as $slug => $byLocale) {
expect($byLocale)->toHaveKeys(['de', 'en']);
expect(mb_strlen($byLocale['de']))->toBeLessThanOrEqual(1000);
expect(mb_strlen($byLocale['en']))->toBeLessThanOrEqual(1000);
}
});