- App\Support\StructuredData: Portal-Organization als Publisher mit @id und Logo (ImageObject), Newsroom-@id; NewsArticle.author auf der Meldung und Organization auf der Newsroom-Seite beschreiben jetzt dieselbe Entitaet. Startseiten nutzen denselben Publisher. - /sitemap-news.xml je Spoke (NewsSitemapController): im Archiv sichtbare Meldungen der letzten 48 h, max. 1.000, news:publication mit Portalname und Sprache; 15 min gecacht, mit den anderen Sitemaps geleert; in robots.txt der Spokes. Hub liefert leere Liste. - /llms.txt je Host (LlmsTxtController): sachliche Beschreibung, URL-Aufbau, aktive Kategorien, Seiten fuer Unternehmen, Rechtliches; Hub verweist auf beide Portale. Keine Aussagen ueber KI-Nennungen. - Protokoll Teil 5 (Block 2) inkl. Betreiber-Schritten fuer das Publisher Center und Befund zu 2.5/E5; Roadmap 2.1/2.7 abgehakt. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
74 lines
3.3 KiB
PHP
74 lines
3.3 KiB
PHP
<?php
|
|
|
|
use App\Enums\Portal;
|
|
use App\Models\Category;
|
|
use App\Models\Company;
|
|
use App\Models\PressRelease;
|
|
use App\Support\WebCaches;
|
|
use Illuminate\Support\Facades\Cache;
|
|
use Tests\TestCase;
|
|
|
|
/**
|
|
* Google-News-Sitemap je Spoke (Roadmap 2.2): nur Meldungen der letzten
|
|
* 48 Stunden, mit Publikationsname und Sprache.
|
|
*/
|
|
function newsSitemapRelease(Portal $portal, string $slug, array $attributes = []): PressRelease
|
|
{
|
|
return PressRelease::factory()
|
|
->published()
|
|
->forPortal($portal)
|
|
->for(Category::factory()->create(['portal' => $portal]))
|
|
->for(Company::factory()->businessportal24()->create())
|
|
->create(['slug' => $slug, ...$attributes]);
|
|
}
|
|
|
|
test('the news sitemap lists only releases of the last 48 hours of the own portal', function () {
|
|
/** @var TestCase $this */
|
|
newsSitemapRelease(Portal::Businessportal24, 'frisch', ['title' => 'Frische Meldung & mehr', 'published_at' => now()->subHours(3)]);
|
|
newsSitemapRelease(Portal::Both, 'beide-portale', ['published_at' => now()->subHours(20)]);
|
|
newsSitemapRelease(Portal::Businessportal24, 'zu-alt', ['published_at' => now()->subDays(3)]);
|
|
newsSitemapRelease(Portal::Presseecho, 'fremdes-portal', ['published_at' => now()->subHour()]);
|
|
newsSitemapRelease(Portal::Businessportal24, 'terminiert', ['published_at' => now()->addHour()]);
|
|
|
|
$response = $this->get('https://businessportal24.test/sitemap-news.xml')->assertSuccessful();
|
|
|
|
expect($response->headers->get('Content-Type'))->toContain('application/xml');
|
|
|
|
$xml = (string) $response->getContent();
|
|
expect($xml)
|
|
->toContain('xmlns:news="http://www.google.com/schemas/sitemap-news/0.9"')
|
|
->toContain('<loc>https://businessportal24.test/de/press-release/frisch</loc>')
|
|
->toContain('<news:name>businessportal24</news:name>')
|
|
->toContain('<news:language>de</news:language>')
|
|
->toContain('<news:title>Frische Meldung & mehr</news:title>')
|
|
->toContain('<loc>https://businessportal24.test/de/press-release/beide-portale</loc>');
|
|
|
|
$this->assertStringNotContainsString('zu-alt', $xml);
|
|
$this->assertStringNotContainsString('fremdes-portal', $xml);
|
|
$this->assertStringNotContainsString('terminiert', $xml);
|
|
});
|
|
|
|
test('the hub serves an empty news sitemap and does not advertise it in robots.txt', function () {
|
|
/** @var TestCase $this */
|
|
newsSitemapRelease(Portal::Presseecho, 'nicht-im-hub', ['published_at' => now()->subHour()]);
|
|
|
|
$xml = (string) $this->get('https://pressekonto.test/sitemap-news.xml')->assertSuccessful()->getContent();
|
|
expect($xml)->toContain('<urlset');
|
|
$this->assertStringNotContainsString('<url>', $xml);
|
|
|
|
$robots = (string) $this->get('https://pressekonto.test/robots.txt')->getContent();
|
|
$this->assertStringNotContainsString('sitemap-news.xml', $robots);
|
|
|
|
$this->get('https://presseecho.test/robots.txt')
|
|
->assertSee('Sitemap: https://presseecho.test/sitemap-news.xml', false);
|
|
});
|
|
|
|
test('the news sitemap is cached per host and cleared with the other sitemaps', function () {
|
|
/** @var TestCase $this */
|
|
$this->get('https://presseecho.test/sitemap-news.xml')->assertSuccessful();
|
|
expect(Cache::has('web.sitemap-news.presseecho.test'))->toBeTrue();
|
|
|
|
WebCaches::forgetSitemaps();
|
|
|
|
expect(Cache::has('web.sitemap-news.presseecho.test'))->toBeFalse();
|
|
});
|