create(); $this->actingAs($user) ->post('/profil/titelbild', ['cover' => UploadedFile::fake()->image('berge.jpg', 2400, 1600)]) ->assertRedirect() ->assertSessionHasNoErrors(); $user->refresh(); $this->assertStringStartsWith("covers/{$user->id}/", $user->cover_path); [$width, $height] = getimagesizefromstring(Storage::disk('uploads')->get($user->cover_path)); $this->assertSame([1600, 500], [$width, $height]); $this->get("/personen/{$user->id}")->assertInertia(fn (Assert $page) => $page ->where('person.cover_url', $user->coverUrl()) ->where('auth.user.cover_url', $user->coverUrl())); // Neues Bild ersetzt das alte, Entfernen räumt auf $old = $user->cover_path; $this->post('/profil/titelbild', ['cover' => UploadedFile::fake()->image('see.png', 1800, 900)])->assertSessionHasNoErrors(); Storage::disk('uploads')->assertMissing($old); $current = $user->fresh()->cover_path; $this->delete('/profil/titelbild')->assertRedirect(); Storage::disk('uploads')->assertMissing($current); $this->assertNull($user->fresh()->cover_path); } public function test_only_images_are_accepted(): void { $this->actingAs(User::factory()->create()) ->post('/profil/titelbild', ['cover' => UploadedFile::fake()->create('lebenslauf.pdf', 100, 'application/pdf')]) ->assertSessionHasErrors('cover'); } public function test_default_cover_and_overlay_come_from_the_appearance(): void { $theme = app(Theme::class); $theme->saveDraft(['profile_cover' => 'theme/titel.webp', 'profile_cover_overlay' => 55]); app()->call([$theme, 'publish']); $this->actingAs(User::factory()->create())->get('/')->assertInertia(fn (Assert $page) => $page ->where('branding.profile_cover.image_url', Storage::disk('uploads')->url('theme/titel.webp')) ->where('branding.profile_cover.overlay', 0.55)); // Ungültige Werte fallen auf den Standard zurück $this->assertSame(70, Theme::normalize(['profile_cover_overlay' => 13])['profile_cover_overlay']); $this->assertNull(Theme::normalize(['profile_cover' => '../.env'])['profile_cover']); } public function test_avatar_placeholder_is_shared_with_portal_and_admin(): void { $theme = app(Theme::class); $theme->saveDraft(['avatar_placeholder' => 'theme/platzhalter.png']); app()->call([$theme, 'publish']); $user = User::factory()->create(); $url = Storage::disk('uploads')->url('theme/platzhalter.png'); $this->actingAs($user)->get('/')->assertInertia(fn (Assert $page) => $page->where('branding.avatar_placeholder_url', $url)); $this->assertSame($url, app(InitialsAvatarProvider::class)->get($user)); } }