File tree Expand file tree Collapse file tree 5 files changed +29
-12
lines changed
tests/Feature/Controllers Expand file tree Collapse file tree 5 files changed +29
-12
lines changed Original file line number Diff line number Diff line change @@ -22,11 +22,9 @@ public function store(ResetPasswordStore $request)
2222 {
2323 $ status = Password::sendResetLink ($ request ->only ('email ' ));
2424
25- if ($ status !== Password::RESET_LINK_SENT ) {
26- throw ValidationException::withMessages ([
27- 'reset_link ' => \__ ($ status ),
28- ]);
29- }
25+ \throw_if ($ status !== Password::RESET_LINK_SENT , ValidationException::withMessages ([
26+ 'reset_link ' => \__ ($ status ),
27+ ]));
3028
3129 \session ()->flash ('success ' , \__ ('passwords.sent ' ));
3230
@@ -53,11 +51,9 @@ public function update(ResetPasswordUpdate $request)
5351 \event (new PasswordReset ($ user ));
5452 });
5553
56- if ($ status !== Password::PASSWORD_RESET ) {
57- throw ValidationException::withMessages ([
58- 'reset ' => __ ($ status ),
59- ]);
60- }
54+ \throw_if ($ status !== Password::PASSWORD_RESET , ValidationException::withMessages ([
55+ 'reset ' => \__ ($ status ),
56+ ]));
6157
6258 \session ()->flash ('success ' , \__ ('passwords.reset ' ));
6359
Original file line number Diff line number Diff line change @@ -14,6 +14,7 @@ public function boot(): void
1414 {
1515 JsonResource::withoutWrapping ();
1616
17+ // @codeCoverageIgnoreStart
1718 Carbon::macro ('inAppTimezone ' , function () {
1819 return $ this ->tz (config ('app.timezone_display ' ));
1920 });
@@ -22,7 +23,6 @@ public function boot(): void
2223 return $ this ->tz (auth ()->user ()?->timezone ?? config ('app.timezone_display ' ));
2324 });
2425
25- // @codeCoverageIgnoreStart
2626 Pulse::users (function ($ ids ) {
2727 return User::findMany ($ ids )->map (fn ($ user ) => [
2828 'id ' => $ user ->id ,
Original file line number Diff line number Diff line change @@ -11,8 +11,10 @@ class AuthServiceProvider extends ServiceProvider
1111{
1212 public function boot (): void
1313 {
14+ // @codeCoverageIgnoreStart
1415 Gate::define ('viewPulse ' , function (User $ user ) {
1516 return $ user ->hasRole (Role::SUPER_ADMIN ->value );
1617 });
18+ // @codeCoverageIgnoreEnd
1719 }
1820}
Original file line number Diff line number Diff line change 66
77use function Pest \Laravel \actingAs ;
88use function Pest \Laravel \get ;
9+ use function Pest \Laravel \withoutExceptionHandling ;
910
1011describe ('Users ' , function () {
1112 test ('Can access the verification page ' , function () {
1718 );
1819 });
1920
21+ test ('Can verify their email address ' , function () {
22+ withoutExceptionHandling ();
23+
24+ $ user = User::factory ()->unverified ()->create ();
25+
26+ expect ($ user ->verified_at )->toBeNull ();
27+
28+ actingAs ($ user )
29+ ->withoutMiddleware (Illuminate \Routing \Middleware \ValidateSignature::class)
30+ ->get (route ('verification.verify ' , [
31+ 'id ' => $ user ->getKey (),
32+ 'hash ' => sha1 ($ user ->getEmailForVerification ()),
33+ ]))
34+ ->assertRedirect (route ('home ' ));
35+
36+ expect ($ user ->refresh ()->email_verified_at )->not ()->toBeNull ();
37+ });
38+
2039 test ('Can send the verificaiton notice ' , function () {
2140 Notification::fake ();
2241
Original file line number Diff line number Diff line change 2020 );
2121});
2222
23- test ('A password reset email can be sent ' , function () {
23+ test ('A password reset email can be requested ' , function () {
2424 Notification::fake ();
2525
2626 $ user = User::factory ()->create ();
You can’t perform that action at this time.
0 commit comments