Initial commit

This commit is contained in:
Julien Nahum
2022-09-20 21:59:52 +02:00
commit f8e6cd4dd6
479 changed files with 77078 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
<?php
use App\Models\User;
it('can login to Forms', function () {
$user = User::factory()->create();
$this->postJson('/api/login', [
'email' => $user->email,
'password' => 'password',
])
->assertSuccessful()
->assertJsonStructure(['token', 'expires_in'])
->assertJson(['token_type' => 'bearer']);
});
it('can fetch current user', function () {
$this->actingAs(User::factory()->create())
->getJson('/api/user')
->assertSuccessful()
->assertJsonStructure(['id', 'name', 'email']);
});
it('can log out', function () {
$this->postJson('/api/login', [
'email' => User::factory()->create()->email,
'password' => 'password',
])->assertSuccessful();
$this->assertAuthenticated();
$this->postJson("/api/logout")
->assertSuccessful();
$this->assertGuest();
$this->getJson("/api/user")
->assertStatus(401);
});