mirror of
https://github.com/10h30/Test-Laravel-Auth-Basics.git
synced 2026-07-11 10:46:16 +09:00
Password validation rule
This commit is contained in:
@@ -6,6 +6,7 @@ use App\Models\User;
|
||||
use App\Providers\RouteServiceProvider;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
use Tests\TestCase;
|
||||
use Illuminate\Support\Facades\Event;
|
||||
use Illuminate\Support\Facades\URL;
|
||||
@@ -130,4 +131,27 @@ class AuthenticationTest extends TestCase
|
||||
$response->assertRedirect();
|
||||
$response->assertSessionHasNoErrors();
|
||||
}
|
||||
|
||||
public function test_password_at_least_one_uppercase_lowercase_letter()
|
||||
{
|
||||
$user = [
|
||||
'name' => 'New name',
|
||||
'email' => 'new@email.com',
|
||||
];
|
||||
|
||||
$invalidPassword = '12345678';
|
||||
$validPassword = 'a12345678';
|
||||
|
||||
$this->post('/register', $user + [
|
||||
'password' => $invalidPassword,
|
||||
'password_confirmation' => $invalidPassword
|
||||
]);
|
||||
$this->assertDatabaseMissing('users', $user);
|
||||
|
||||
$this->post('/register', $user + [
|
||||
'password' => $validPassword,
|
||||
'password_confirmation' => $validPassword
|
||||
]);
|
||||
$this->assertDatabaseHas('users', $user);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user