F
Filamentβ€’7mo ago
Frittenfred

handlerecordcreation testing ?

Hello Together, i'm writing tests for the UserResource. i want to test if when i create a user, a password forgotten email has been send. i have in my CreateUser.php a handlerecordcreation wich executes this code : protected function handleRecordCreation(array $data): Model { if ($data['start_password_forgotten']) { $email = ['email' => $data['email']]; unset($data['start_password_forgotten']); $user = static::getModel()::create($data); UserResource::sendPasswordForgottenEmail($email); } else { unset($data['start_password_forgotten']); $user = static::getModel()::create($data); } return $user; } sendPasswordForgottenEmail sends the password via the broker with fortify. in my Test im writing this code to check : public function test_if_created_user_sends_password_forgotten_email() { $this->actingAs(User::factory()->create()->assignRole(UserRoleEnum::ADMINISTRATOR->value)); $user = User::factory()->make(); Mail::fake(); Livewire::test(UserResource\Pages\CreateUser::class) ->fillForm([ 'name' => $user->name, 'email' => $user->email, 'start_password_forgotten' => true, ]) ->call('create'); Mail::assertSentCount(1); } but there is no email been send, even if i add the 'start_password_forgotten' attribute. so that means that the call() method not starts the handleRecordCreation(). is there a other possibility access it and test it ? am i missing something ?
1 Reply
Frittenfred
Frittenfredβ€’7mo ago
nevermind, password forgotten sends a notification, not a email. problem is solved πŸ™‚
Want results from more Discord servers?
Add your server