Commit 778cfdc0 authored by Jacob Priddy's avatar Jacob Priddy 👌
Browse files

Merge branch '7-don-t-need-to-return-everything-for-a-user-on-get-all-users' into 'master'

Resolve "don't need to return everything for a user on get all users"

Closes #7

See merge request kretschmar/doorcode!13
parents b71a799d 2e250839
Pipeline #2281 passed with stages
in 1 minute and 47 seconds
......@@ -2,6 +2,7 @@
namespace Source\UseCases\Users\GetAllUsers;
use Carbon\Carbon;
use Source\Entities\User;
use Source\UseCases\BasePresenter;
......@@ -12,8 +13,15 @@ class APIPresenter extends BasePresenter implements Presenter
/** @inheritDoc */
public function present(ResponseModel $responseModel): void
{
$this->viewModel['users'] = array_map(function (User $user) {
return $this->formatUser($user);
$this->viewModel['users'] = array_map(static function (User $user) {
return [
'id' => $user->getId(),
'first_name' => $user->getFirstName(),
'last_name' => $user->getLastName(),
'display_name' => $user->getDisplayName(),
'email' => $user->getEmail(),
'expired' => $user->getExpiresAt() < Carbon::now(),
];
}, $responseModel->getUsers());
}
......
......@@ -66,23 +66,17 @@ class PresenterTest extends TestCase
$this->handleTest();
$this->assertEquals(
[
'users' => [
[
'id' => 0,
'first_name' => 'first',
'last_name' => 'last',
'display_name' => 'display',
'emplid' => 'emplid',
'email' => 'email',
'expires_at' => 'Feb 2, 2020',
'created_at' => null,
'updated_at' => null,
],
$this->assertEquals([
'users' => [
[
'id' => 0,
'first_name' => 'first',
'last_name' => 'last',
'display_name' => 'display',
'email' => 'email',
'expired' => true,
],
],
$this->response
);
], $this->response);
}
}
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