added it_check_if_user_exist_and_return_name_with_avatar, it_check_non_existed_user_and_return_not_found test

This commit is contained in:
Peter Papp
2021-03-14 10:56:50 +01:00
parent 9c3c044623
commit 5778de20f2
6 changed files with 88 additions and 106 deletions

View File

@@ -2,6 +2,7 @@
namespace Tests\Feature\Accounts;
use App\Models\Setting;
use App\Models\User;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Laravel\Sanctum\Sanctum;
@@ -38,6 +39,22 @@ class AuthTest extends TestCase
*/
public function it_register_user()
{
collect([
[
'name' => 'storage_default',
'value' => 12,
],
[
'name' => 'registration',
'value' => 1,
],
])->each(function ($setting) {
Setting::create([
'name' => $setting['name'],
'value' => $setting['value'],
]);
});
$this->postJson('/register', [
'email' => 'john@doe.com',
'password' => 'SecretPassword',
@@ -46,17 +63,41 @@ class AuthTest extends TestCase
])->assertStatus(201);
$this->assertDatabaseHas('users', [
'email' => 'john@doe.com',
'email' => 'john@doe.com',
]);
$this->assertDatabaseHas('user_settings', [
'name' => 'John Doe',
'name' => 'John Doe',
'storage_capacity' => 12,
]);
Storage::disk('local')
->assertExists('files/' . User::first()->id);
}
/**
* @test
*/
public function it_check_if_user_exist_and_return_name_with_avatar()
{
$user = User::factory(User::class)
->create(['email' => 'john@doe.com']);
$this->postJson('/api/user/check', [
'email' => $user->email,
])->assertStatus(200);
}
/**
* @test
*/
public function it_check_non_existed_user_and_return_not_found()
{
$this->postJson('/api/user/check', [
'email' => 'jane@doe.com',
])->assertStatus(404);
}
/**
* @test
*/