Files
laraundfelix/tests/Feature/FaviconTest.php
T
LarsandClaude Sonnet 5.5 1d1f0ebb1f
CI Feature / test (push) Successful in 3m50s
Binde das Favicon ein und lege Favicon und Kleingrafiken des Brand-Kits ab
Die Datei public/favicon.ico war leer; im head fehlte jeder Icon-Verweis.
- Favicon (ICO, SVG, Apple-Touch-Icon) in public/, gemeinsame Komponente
  x-site.favicon in Website-, Mitglieder- und Vorschau-Layouts
- Verwaltung: Icon per Render-Hook zur Anfragezeit statt ->favicon(asset()),
  weil asset() beim Start den falschen Host liefert
- FaviconTest (Dateien, Verweise, Adresse hinter dem Proxy)
- Brand-Kit: 15_Lara-Felix-Favicon und 16_Lara-Felix-Kleingrafiken (freigegeben)
- KIT_ERGAENZUNG_v2.1_kleingrafiken.md: Prüfung und Umsetzungsvorschlag

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-23 11:27:56 +01:00

73 lines
2.6 KiB
PHP

<?php
namespace Tests\Feature;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
/**
* Favicon des Brand-Kits (15_Lara-Felix-Favicon). Der eigentliche Fehler war eine leere public/favicon.ico:
* Browser fragen sie selbst ab und bekamen nichts.
*/
class FaviconTest extends TestCase
{
use RefreshDatabase;
public function test_the_icon_files_are_real_and_not_empty(): void
{
$ico = file_get_contents(public_path('favicon.ico'));
$this->assertGreaterThan(1000, strlen($ico));
$this->assertSame("\x00\x00\x01\x00", substr($ico, 0, 4), 'favicon.ico ist keine ICO-Datei');
$svg = file_get_contents(public_path('favicon.svg'));
$this->assertStringContainsString('<svg', $svg);
$this->assertStringContainsString('Lara &amp; Felix', $svg);
$png = file_get_contents(public_path('apple-touch-icon.png'));
$this->assertSame("\x89PNG", substr($png, 0, 4));
}
public function test_public_pages_link_the_icons(): void
{
$this->get('/')->assertOk()
->assertSee('href="'.asset('favicon.ico').'" sizes="any"', false)
->assertSee('href="'.asset('favicon.svg').'" type="image/svg+xml"', false)
->assertSee('rel="apple-touch-icon" href="'.asset('apple-touch-icon.png').'"', false);
}
public function test_the_sign_in_page_links_the_icons(): void
{
$this->get(route('login'))->assertOk()
->assertSee(asset('favicon.svg'), false);
}
public function test_the_member_area_links_the_icons(): void
{
$this->actingAs(User::factory()->create())
->get(route('member.dashboard'))
->assertOk()
->assertSee(asset('favicon.svg'), false)
->assertSee(asset('apple-touch-icon.png'), false);
}
public function test_the_administration_login_uses_the_favicon(): void
{
$this->get('/verwaltung/login')->assertOk()
->assertSee('rel="icon" href="'.asset('favicon.svg').'"', false)
->assertSee('rel="apple-touch-icon"', false);
}
public function test_the_administration_icon_follows_the_opened_address_behind_a_proxy(): void
{
config(['app.url' => 'https://CHANGE-ME.example']);
$this->withHeaders(['X-Forwarded-Host' => '', 'X-Forwarded-Port' => '', 'X-Forwarded-Proto' => ''])
->get('http://192.168.2.144:3011/verwaltung/login')
->assertOk()
->assertSee('href="http://192.168.2.144:3011/favicon.svg"', false)
->assertSee('href="http://192.168.2.144:3011/apple-touch-icon.png"', false)
->assertDontSee('CHANGE-ME.example');
}
}