User management (#185)

This commit is contained in:
Saeed Vaziry
2024-04-29 20:58:04 +02:00
committed by GitHub
parent 35f896eab1
commit d846acaa8d
106 changed files with 1490 additions and 434 deletions

View File

@ -2,6 +2,7 @@
namespace Tests\Unit\Commands;
use App\Models\Project;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Tests\TestCase;
@ -27,7 +28,36 @@ public function test_create_user(): void
$user = User::query()->where('email', 'john@doe.com')->first();
$this->assertDatabaseHas('projects', [
'name' => 'default',
]);
}
public function test_create_user_and_project(): void
{
Project::query()->delete();
User::query()->delete();
$this->artisan('user:create', [
'name' => 'John Doe',
'email' => 'john@doe.com',
'password' => 'password',
])->expectsOutput('User created!');
$this->assertDatabaseHas('users', [
'name' => 'John Doe',
'email' => 'john@doe.com',
]);
/** @var User $user */
$user = User::query()->where('email', 'john@doe.com')->first();
$this->assertDatabaseHas('projects', [
'name' => 'default',
]);
$this->assertDatabaseHas('user_project', [
'user_id' => $user->id,
'project_id' => $user->refresh()->current_project_id,
]);
}