You should separate that 2 http endpoints to 2 different tests. First test should test register endpoint and 2nd test should test /verify-email endpoint.
The best place to learn is Laravel testing documentation https://laravel.com/docs/8.x/testing
Things you should consider to use:
Factories: https://laravel.com/docs/8.x/database-testing#defining-model-factories
$user = User::factory()->create([
"name" => "John Doe",
"email" => "[email protected]",
"password" => "test@123",
"confirm_password" => "test@123"
]);
Fakes: https://laravel.com/docs/8.x/mocking#mail-fake (you can use Listeners/Events fakes as well)
Mail::assertSent(VerifyEmail::class, function ($mail) use ($user) {
return $mail->hasTo($user->email) &&
$mail->hasCc('...') &&
$mail->hasBcc('...');
});
Database assertions: https://laravel.com/docs/8.x/database-testing#available-assertions
$this->assertDatabaseHas('users', [
'email' => '[email protected]',
]);
for register endpoint you can check email and what is in database after your test
forverify-email you can use factories to populate data and use db assertions to check if it is as you expect after calling the endpoint.
your test should also cover scenarios when assertStatus will not be Response::HTTP_OK