Skip to content

Commit 965a9ec

Browse files
Test User Registration
1 parent a5be445 commit 965a9ec

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
}

0 commit comments

Comments
 (0)