Files
eatvio-infra/tests/Feature/RegistrationTest.php
2023-12-12 15:10:41 +03:00

71 lines
1.9 KiB
PHP

<?php
namespace Tests\Feature;
use App\Providers\RouteServiceProvider;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Laravel\Fortify\Features;
use Laravel\Jetstream\Jetstream;
use Tests\TestCase;
class RegistrationTest extends TestCase
{
use RefreshDatabase;
public function test_registration_screen_can_be_rendered(): void
{
if (! Features::enabled(Features::registration())) {
$this->markTestSkipped('Registration support is not enabled.');
return;
}
$response = $this->get('/register');
$response->assertStatus(200);
}
public function test_registration_screen_cannot_be_rendered_if_support_is_disabled(): void
{
if (Features::enabled(Features::registration())) {
$this->markTestSkipped('Registration support is enabled.');
return;
}
$response = $this->get('/register');
$response->assertStatus(404);
}
public function test_new_users_can_register(): void
{
if (! Features::enabled(Features::registration())) {
$this->markTestSkipped('Registration support is not enabled.');
return;
}
$response = $this->post('/register', [
'first_name' => 'Test User_first_name',
'last_name' => 'User_last_name',
'email' => 'test@example.com',
'birthdate' => '27-07-2000',
'gender' => 'male',
'has_hypo' => 0,
'has_hyper' => 1,
'country' => 'ru',
'city' => 'Msk',
'lang' => 'ru',
'weight' => 90,
'height' => 180,
'password' => 'password',
'password_confirmation' => 'password',
'terms' => Jetstream::hasTermsAndPrivacyPolicyFeature(),
]);
$this->assertAuthenticated();
$response->assertRedirect(RouteServiceProvider::HOME);
}
}