File tree Expand file tree Collapse file tree 4 files changed +50
-13
lines changed
tests/Feature/Controllers Expand file tree Collapse file tree 4 files changed +50
-13
lines changed Original file line number Diff line number Diff line change @@ -10,14 +10,12 @@ class LoginController extends Controller
1010{
1111 public function show (Request $ request )
1212 {
13- $ isProd = app ()->environment ('production ' );
14-
15- return inertia ('Login/Show ' , [
16- 'email ' => ! $ isProd ? config ('app.seed.emails.super ' , '' ) : '' ,
17- 'password ' => ! $ isProd ? '12345 ' : '' ,
18- 'remember ' => ! $ isProd ? true : false ,
13+ return inertia ('Login/Show ' , app ()->environment ('local ' , 'testing ' ) ? [
14+ 'email ' => config ('app.seed.emails.super ' ),
15+ 'password ' => '12345 ' ,
16+ 'remember ' => true ,
1917 'redirect ' => $ request ->query ('redirect ' , '' ),
20- ]);
18+ ] : [] );
2119 }
2220
2321 public function store (LoginStoreRequest $ request )
@@ -29,8 +27,6 @@ public function store(LoginStoreRequest $request)
2927 ])
3028 );
3129
32- $ request ->session ()->regenerate ();
33-
3430 if ($ request ->validated ('redirect ' )) {
3531 return redirect ()->to ($ request ->validated ('redirect ' ));
3632 }
Original file line number Diff line number Diff line change 55use App \Enums \Role ;
66use App \Http \Requests \Register \RegisterStoreRequest ;
77use App \Models \User ;
8- use Illuminate \Auth \Events \Registered ;
98
109class RegisterController extends Controller
1110{
1211 public function show ()
1312 {
14- return inertia ('Register/Show ' , app ()->environment ('local ' ) ? [
13+ return inertia ('Register/Show ' , app ()->environment ('local ' , ' testing ' ) ? [
1514 'first_name ' => 'Jim ' ,
1615 'last_name ' => 'Gordon ' ,
1716 'email ' => 'test@test.com ' ,
@@ -37,8 +36,6 @@ public function store(RegisterStoreRequest $request)
3736
3837 auth ()->guard ()->loginUsingId ($ user ->id );
3938
40- event (new Registered ($ user ));
41-
4239 return redirect ()->route ('home ' );
4340 }
4441}
Original file line number Diff line number Diff line change 1111use function Pest \Laravel \get ;
1212use function Pest \Laravel \post ;
1313
14+ covers (App \Http \Controllers \LoginController::class);
15+
1416describe ('Users ' , function () {
1517 test ("Can't access the login page " , function () {
1618 actingAs (User::factory ()->create ())
2628 ->assertInertia (
2729 fn (Assert $ page ) => $ page
2830 ->component ('Login/Show ' )
31+ ->where ('email ' , config ('app.seed.emails.super ' ))
32+ ->where ('password ' , '12345 ' )
33+ ->where ('remember ' , true )
34+ ->where ('redirect ' , '' )
35+ );
36+ });
37+
38+ test ('Props are not passed to the show page in production ' , function () {
39+ app ()->instance ('env ' , 'production ' );
40+
41+ get (route ('login ' ))
42+ ->assertOk ()
43+ ->assertInertia (
44+ fn (Assert $ page ) => $ page
45+ ->component ('Login/Show ' )
46+ ->missing ('email ' )
47+ ->missing ('password ' )
48+ ->missing ('remember ' )
49+ ->missing ('redirect ' )
2950 );
3051 });
3152
Original file line number Diff line number Diff line change 1212use function Pest \Laravel \get ;
1313use function Pest \Laravel \post ;
1414
15+ covers (App \Http \Controllers \RegisterController::class);
16+
1517describe ('Users ' , function () {
1618 test ("Can't access the register page " , function () {
1719 actingAs (User::factory ()->create ())
2729 ->assertInertia (
2830 fn (Assert $ page ) => $ page
2931 ->component ('Register/Show ' )
32+ ->has ('first_name ' )
33+ ->has ('last_name ' )
34+ ->has ('email ' )
35+ ->has ('password ' )
36+ ->has ('organisation_name ' )
37+ );
38+ });
39+
40+ test ('Props are not passed to the show page in production ' , function () {
41+ app ()->instance ('env ' , 'production ' );
42+
43+ get (route ('register ' ))
44+ ->assertOk ()
45+ ->assertInertia (
46+ fn (Assert $ page ) => $ page
47+ ->component ('Register/Show ' )
48+ ->missing ('first_name ' )
49+ ->missing ('last_name ' )
50+ ->missing ('email ' )
51+ ->missing ('password ' )
52+ ->missing ('organisation_name ' )
3053 );
3154 });
3255
You can’t perform that action at this time.
0 commit comments