Files
SkinbaseNova/tests/Feature/Http/LegacyPhotoM17B1MiddlewareTest.php
T
klevze b9beb8f5c5 Speed legacy photo serving and skip tracking on download routes.
Tighten thumbnail/legacy photo handling and exclude download/photo traffic from session visitor tracking so those hot paths stay cheap.
2026-08-29 12:25:37 +02:00

41 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
use App\Services\Traffic\OnlineVisitorRepository;
use Illuminate\Support\Facades\Config;
beforeEach(function (): void {
Config::set('skinbase-sessions.enabled', true);
Config::set('skinbase-sessions.debug_header', true);
Config::set('skinbase-sessions.skip_anonymous_public_get', true);
});
it('skips session for anonymous GET and HEAD /photo/* without a session cookie', function (): void {
$this->get('/photo/0_6.png')
->assertNotFound()
->assertHeader('X-Skinbase-Session', 'skipped');
$this->head('/photo/0_6.png')
->assertNotFound()
->assertHeader('X-Skinbase-Session', 'skipped');
});
it('starts session for /photo/* when a session cookie is already present', function (): void {
$cookie = (string) config('session.cookie');
$this->withCookie($cookie, 'existing-session-cookie')
->get('/photo/0_6.png')
->assertNotFound()
->assertHeader('X-Skinbase-Session', 'started');
});
it('does not record presence for /photo/* requests', function (): void {
$this->mock(OnlineVisitorRepository::class, function ($mock): void {
$mock->shouldReceive('track')->never();
});
$this->get('/photo/0_6.png')->assertNotFound();
$this->head('/photo/0_6.png')->assertNotFound();
});