* fix password reset bug * upgrade to laravel 11 * composer.lock * fix migration issues * use ValidationRule Contract * rename password_resets table * implemented casts as protected function * update env variables * fix optional property * fix validation issues * use <env> on php unit xml * fix pint * cmposer.lock * composer json fixes * fix composer dependencies, remove faker * remove unused class * remove test class * fix default value for mysql migration * linting * expression syntax fix --------- Co-authored-by: Julien Nahum <julien@nahum.net>
63 lines
1.7 KiB
PHP
63 lines
1.7 KiB
PHP
<?php
|
|
|
|
use App\Models\User;
|
|
|
|
it('can register', function () {
|
|
$this->postJson('/register', [
|
|
'name' => 'Test User',
|
|
'email' => 'test@test.app',
|
|
'hear_about_us' => 'google',
|
|
'password' => 'secret',
|
|
'password_confirmation' => 'secret',
|
|
'agree_terms' => true,
|
|
])
|
|
->assertSuccessful()
|
|
->assertJsonStructure(['id', 'name', 'email']);
|
|
$this->assertDatabaseHas('users', [
|
|
'name' => 'Test User',
|
|
'email' => 'test@test.app',
|
|
]);
|
|
});
|
|
|
|
it('cannot register with existing email', function () {
|
|
User::factory()->create(['email' => 'test@test.app']);
|
|
|
|
$this->postJson('/register', [
|
|
'name' => 'Test User',
|
|
'email' => 'test@test.app',
|
|
'password' => 'secret',
|
|
'password_confirmation' => 'secret',
|
|
])
|
|
->assertStatus(422)
|
|
->assertJsonValidationErrors(['email']);
|
|
});
|
|
|
|
it('cannot register with disposable email', function () {
|
|
// Select random email
|
|
$email = [
|
|
'dumliyupse@gufum.com',
|
|
'kcs79722@zslsz.com',
|
|
'pfizexwxtdifxupdhr@tpwlb.com',
|
|
'qvj86ypqfm@email.edu.pl',
|
|
][rand(0, 3)];
|
|
|
|
$this->postJson('/register', [
|
|
'name' => 'Test disposable',
|
|
'email' => $email,
|
|
'hear_about_us' => 'google',
|
|
'password' => 'secret',
|
|
'password_confirmation' => 'secret',
|
|
'agree_terms' => true,
|
|
])
|
|
->assertStatus(422)
|
|
->assertJsonValidationErrors(['email'])
|
|
->assertJson([
|
|
'message' => 'Disposable email addresses are not allowed.',
|
|
'errors' => [
|
|
'email' => [
|
|
'Disposable email addresses are not allowed.',
|
|
],
|
|
],
|
|
]);
|
|
});
|