File tree 1 file changed +38
-0
lines changed
1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ namespace Tests \Feature ;
4
+
5
+ use App \Models \User ;
6
+ use Illuminate \Foundation \Testing \RefreshDatabase ;
7
+ use Illuminate \Foundation \Testing \WithFaker ;
8
+ use Illuminate \Support \Facades \Hash ;
9
+ use Tests \TestCase ;
10
+
11
+ class SignupControllerTest extends TestCase
12
+ {
13
+ use RefreshDatabase, WithFaker;
14
+
15
+ /**
16
+ * Test user registration and email verification.
17
+ *
18
+ * @return void
19
+ */
20
+ public function testUserRegistration ()
21
+ {
22
+ $ userData = [
23
+ 'name ' => $ this ->faker ->name ,
24
+ 'email ' => $ this ->faker ->unique ()->safeEmail ,
25
+ 'password ' => 'password123 ' ,
26
+ 'password_confirmation ' => 'password123 ' ,
27
+ ];
28
+
29
+ $ response = $ this ->postJson ('/api/user/signup ' , $ userData );
30
+
31
+ $ response ->assertStatus (200 );
32
+
33
+ $ this ->assertDatabaseHas ('users ' , ['email ' => $ userData ['email ' ]]);
34
+ $ user = User::where ('email ' , $ userData ['email ' ])->first ();
35
+ $ this ->assertTrue (Hash::check ('password123 ' , $ user ->password ));
36
+ }
37
+
38
+ }
You can’t perform that action at this time.
0 commit comments