Commit dc8046a8 authored by Jacob Priddy's avatar Jacob Priddy 👌
Browse files

it can create a user

parent 0e975777
Pipeline #1170 passed with stages
in 1 minute and 41 seconds
......@@ -23,8 +23,13 @@ class CreateUser implements CreateUserUseCase {
* @throws Exception
*/
public function create(array $attributes, Presenter $presenter): void {
$expires = $attributes['expires_at'] ?? null;
$expires = $attributes['expires_at'] ? new Carbon($attributes['expires_at']) : null;
$expires = $expires ? new Carbon($expires) : null;
$emplid = $attributes['emplid'] ?? null;
$password = $attributes['password'] ?? '';
// ID, createdAt, and updatedAt will get overwritten
$user = new User(
......@@ -32,9 +37,9 @@ class CreateUser implements CreateUserUseCase {
$attributes['first_name'],
$attributes['last_name'],
$attributes['display_name'],
$attributes['emplid'] ?? null,
$emplid,
$attributes['email'],
$attributes['password'],
$password,
$attributes['doorcode'],
$expires,
null,
......
......@@ -171,4 +171,32 @@ class CreateUserApiTest extends TestCase {
$this->handleTest($data);
$this->response->assertJsonFragment($message);
}
/**
* @test
*/
public function it_creates_a_user(): void {
$this->handleTest(
[
'first_name' => 'first name',
'last_name' => 'last name',
'display_name' => 'display name',
'email' => 'email@imsad.dumb',
'doorcode' => '1234',
]
);
$this->response->assertStatus(200);
$this->response->assertJsonFragment(
[
'first_name' => 'first name',
'last_name' => 'last name',
'display_name' => 'display name',
'emplid' => null,
'email' => 'email@imsad.dumb',
]
);
$this->assertCount(1, $this->usersRepository->all());
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment