create(); $response = $this ->actingAs($user) ->get('/profile'); $response->assertOk(); } public function test_profile_information_can_be_updated(): void { $user = User::factory()->create(); $response = $this ->actingAs($user) ->patch('/profile', [ 'name' => 'Test User', 'email' => 'test@example.com', ]); $response ->assertSessionHasNoErrors() ->assertRedirect('/profile'); $user->refresh(); $this->assertSame('Test User', $user->name); $this->assertSame('test@example.com', $user->email); $this->assertNull($user->email_verified_at); } public function test_email_verification_status_is_unchanged_when_the_email_address_is_unchanged(): void { $user = User::factory()->create(); $response = $this ->actingAs($user) ->patch('/profile', [ 'name' => 'Test User', 'email' => $user->email, ]); $response ->assertSessionHasNoErrors() ->assertRedirect('/profile'); $this->assertNotNull($user->refresh()->email_verified_at); } public function test_profile_picture_upload_works_with_jpg(): void { $user = User::factory()->create(); \Illuminate\Support\Facades\Storage::fake('public'); $file = \Illuminate\Http\UploadedFile::fake()->create('avatar.jpg', 100, 'image/jpeg'); $response = $this ->actingAs($user) ->patch('/profile', [ 'name' => 'Test User', 'email' => 'test@example.com', 'profile_picture' => $file, ]); $response->assertSessionHasNoErrors()->assertRedirect('/profile'); $user->refresh(); $this->assertNotNull($user->profile_picture); $this->assertStringContainsString('/storage/avatars/', $user->profile_picture); $filename = str_replace('/storage/', '', $user->profile_picture); \Illuminate\Support\Facades\Storage::disk('public')->assertExists($filename); } public function test_profile_picture_upload_rejects_non_jpg(): void { $user = User::factory()->create(); $file = \Illuminate\Http\UploadedFile::fake()->create('avatar.png', 100, 'image/png'); $response = $this ->actingAs($user) ->from('/profile') ->patch('/profile', [ 'name' => 'Test User', 'email' => 'test@example.com', 'profile_picture' => $file, ]); $response->assertSessionHasErrors('profile_picture'); $this->assertNull($user->refresh()->profile_picture); } }