seed(\Database\Seeders\TemplateSeeder::class); Role::firstOrCreate(['name' => 'Full Administrator', 'guard_name' => 'admin']); $this->admin = User::factory()->create(); $this->admin->assignRole('Full Administrator'); $this->customer = Customer::factory()->create([ 'password' => Hash::make('old-password'), ]); } public function test_reset_password_sends_email_and_does_not_leak_password_in_response(): void { Mail::fake(); $oldHash = $this->customer->password; $response = $this->actingAs($this->admin, 'admin') ->postJson("/api/v1/administrator/customers/{$this->customer->uuid}/reset-password"); $response->assertOk(); $response->assertJsonMissingPath('data.new_password'); $response->assertJsonMissing(['new_password']); Mail::assertSent(PasswordResetByAdmin::class, function (PasswordResetByAdmin $mail) { return $mail->hasTo($this->customer->email); }); $this->assertNotSame($oldHash, $this->customer->fresh()->password); } }