login()->loginNami(); $this->postJson(route('user.store'), UserRequestFactory::new()->name('Max Muster')->email('max@muster.de')->create()) ->assertOk(); $this->assertDatabaseHas('users', [ 'email' => 'max@muster.de', 'firstname' => 'Max', 'lastname' => 'Muster', ]); $this->assertDatabaseHas('password_resets', ['email' => 'max@muster.de']); Mail::assertQueued( WelcomeMail::class, fn ($mail) => Hash::check($mail->token, DB::table('password_resets')->where('email', 'max@muster.de')->first()->token) ); } public function testItNeedsNameAndEmail(): void { Mail::fake(); $this->login()->loginNami(); User::factory()->email('jane@doe.de')->create(); $this->postJson(route('user.store'), UserRequestFactory::new()->name('')->email('max@muster.de')->create())->assertJsonValidationErrors('firstname'); $this->postJson(route('user.store'), UserRequestFactory::new()->name('Max Muster')->email('maxusterde')->create())->assertJsonValidationErrors('email'); $this->postJson(route('user.store'), UserRequestFactory::new()->name('Max Muster')->email('')->create())->assertJsonValidationErrors('email'); $this->postJson(route('user.store'), UserRequestFactory::new()->email('jane@doe.de')->create())->assertJsonValidationErrors('email'); } public function testWelcomeMailHasPasswordResetLink(): void { app(InvoiceSettings::class)->fill(['from_long' => 'Stamm BiPi'])->save(); (new WelcomeMail(User::factory()->email('max@muster.de')->name('Max Muster')->create(), 'RESETToken')) ->assertSeeInHtml('Hallo Max Muster') ->assertSeeInHtml(url('')) ->assertSeeInHtml('Stamm BiPi') ->assertSeeInHtml('max@muster.de') ->assertSeeInHtml(route('password.reset', ['token' => 'RESETToken', 'email' => 'max@muster.de'])); } }