diff --git a/app/Domain/EmployeesMilestoneRetriever.php b/app/Domain/EmployeesMilestonesRetriever.php similarity index 97% rename from app/Domain/EmployeesMilestoneRetriever.php rename to app/Domain/EmployeesMilestonesRetriever.php index d3084e2e..787c9117 100644 --- a/app/Domain/EmployeesMilestoneRetriever.php +++ b/app/Domain/EmployeesMilestonesRetriever.php @@ -8,7 +8,7 @@ use Illuminate\Support\Collection; use Toby\Eloquent\Models\User; -class EmployeesMilestoneRetriever +class EmployeesMilestonesRetriever { public function __construct( protected VacationTypeConfigRetriever $configRetriever, diff --git a/app/Infrastructure/Http/Controllers/EmployeesMilestonesController.php b/app/Infrastructure/Http/Controllers/EmployeesMilestonesController.php index ace7b3e9..c35977e6 100644 --- a/app/Infrastructure/Http/Controllers/EmployeesMilestonesController.php +++ b/app/Infrastructure/Http/Controllers/EmployeesMilestonesController.php @@ -6,12 +6,12 @@ use Illuminate\Http\Request; use Inertia\Response; -use Toby\Domain\EmployeesMilestoneRetriever; +use Toby\Domain\EmployeesMilestonesRetriever; use Toby\Infrastructure\Http\Resources\EmployeeMilestoneResource; class EmployeesMilestonesController extends Controller { - public function index(Request $request, EmployeesMilestoneRetriever $employeesMilestoneRetriever): Response + public function index(Request $request, EmployeesMilestonesRetriever $employeesMilestoneRetriever): Response { $searchText = $request->query("search"); $sort = $request->query("sort"); diff --git a/app/Infrastructure/Http/Requests/UserRequest.php b/app/Infrastructure/Http/Requests/UserRequest.php index 76b6ca9f..13b72757 100644 --- a/app/Infrastructure/Http/Requests/UserRequest.php +++ b/app/Infrastructure/Http/Requests/UserRequest.php @@ -22,7 +22,7 @@ public function rules(): array "position" => ["required"], "employmentForm" => ["required", new Enum(EmploymentForm::class)], "employmentDate" => ["required", "date_format:Y-m-d"], - "birthday" => ["nullable", "date_format:Y-m-d", "before:today"], + "birthday" => ["required", "nullable", "date_format:Y-m-d", "before:today"], "slackId" => [], "nextMedicalExamDate" => ["nullable", "after:lastMedicalExamDate"], "nextOhsTrainingDate" => ["nullable", "after:lastOhsTrainingDate"], diff --git a/tests/Feature/EmployeesMilestonesTest.php b/tests/Feature/EmployeesMilestonesTest.php index 3495d2b6..a5d3054d 100644 --- a/tests/Feature/EmployeesMilestonesTest.php +++ b/tests/Feature/EmployeesMilestonesTest.php @@ -8,20 +8,20 @@ use Illuminate\Support\Carbon; use Inertia\Testing\AssertableInertia as Assert; use Tests\FeatureTestCase; -use Toby\Domain\EmployeesMilestoneRetriever; +use Toby\Domain\EmployeesMilestonesRetriever; use Toby\Eloquent\Models\User; class EmployeesMilestonesTest extends FeatureTestCase { use DatabaseMigrations; - protected EmployeesMilestoneRetriever $employeesMilestoneRetriever; + protected EmployeesMilestonesRetriever $employeesMilestonesRetriever; protected function setUp(): void { parent::setUp(); - $this->employeesMilestoneRetriever = $this->app->make(EmployeesMilestoneRetriever::class); + $this->employeesMilestonesRetriever = $this->app->make(EmployeesMilestonesRetriever::class); } public function testUserCanSeeEmployeesMilestonesList(): void @@ -57,13 +57,13 @@ public function testSortingByBirthdays(): void ->employee() ->create(); - $sortedUsersByUpcomingBirthday = $this->employeesMilestoneRetriever->getResults(null, "birthday-asc")->values(); + $sortedUsersByUpcomingBirthday = $this->employeesMilestonesRetriever->getResults(null, "birthday-asc")->values(); $this->assertEquals($user1->id, $sortedUsersByUpcomingBirthday[0]->id); $this->assertEquals($user3->id, $sortedUsersByUpcomingBirthday[1]->id); $this->assertEquals($user2->id, $sortedUsersByUpcomingBirthday[2]->id); - $sortedUsersByFurthestBirthday = $this->employeesMilestoneRetriever->getResults(null, "birthday-desc")->values(); + $sortedUsersByFurthestBirthday = $this->employeesMilestonesRetriever->getResults(null, "birthday-desc")->values(); $this->assertEquals($user2->id, $sortedUsersByFurthestBirthday[0]->id); $this->assertEquals($user3->id, $sortedUsersByFurthestBirthday[1]->id); @@ -87,13 +87,13 @@ public function testSortingBySeniority(): void ->employee() ->create(); - $sortedUsersByLongestSeniority = $this->employeesMilestoneRetriever->getResults(null, "seniority-asc")->values(); + $sortedUsersByLongestSeniority = $this->employeesMilestonesRetriever->getResults(null, "seniority-asc")->values(); $this->assertEquals($user3->id, $sortedUsersByLongestSeniority[0]->id); $this->assertEquals($user2->id, $sortedUsersByLongestSeniority[1]->id); $this->assertEquals($user1->id, $sortedUsersByLongestSeniority[2]->id); - $sortedUsersByShortestSeniority = $this->employeesMilestoneRetriever->getResults(null, "seniority-desc")->values(); + $sortedUsersByShortestSeniority = $this->employeesMilestonesRetriever->getResults(null, "seniority-desc")->values(); $this->assertEquals($user1->id, $sortedUsersByShortestSeniority[0]->id); $this->assertEquals($user2->id, $sortedUsersByShortestSeniority[1]->id); diff --git a/tests/Feature/UserTest.php b/tests/Feature/UserTest.php index 3326be34..c52b15bf 100644 --- a/tests/Feature/UserTest.php +++ b/tests/Feature/UserTest.php @@ -101,6 +101,7 @@ public function testAdminCanCreateUser(): void "email" => "john.doe@example.com", "employmentForm" => EmploymentForm::B2bContract->value, "employmentDate" => Carbon::now()->toDateString(), + "birthday" => Carbon::create(1990, 5, 31)->toDateString(), ]) ->assertSessionHasNoErrors(); @@ -121,6 +122,7 @@ public function testAdminCanCreateUser(): void "position" => "Test position", "employment_form" => EmploymentForm::B2bContract->value, "employment_date" => Carbon::now()->toDateString(), + "birthday" => Carbon::create(1990, 5, 31)->toDateString(), ]); } @@ -137,6 +139,7 @@ public function testItCreatesProperPermissionsWhileCreatingUser(): void "email" => "john.doe@example.com", "employmentForm" => EmploymentForm::B2bContract->value, "employmentDate" => Carbon::now()->toDateString(), + "birthday" => Carbon::create(1990, 5, 31)->toDateString(), ]) ->assertSessionHasNoErrors(); @@ -165,6 +168,7 @@ public function testAdminCanEditUser(): void "last_name" => $user->profile->last_name, "employment_form" => $user->profile->employment_form->value, "employment_date" => $user->profile->employment_date->toDateString(), + "birthday" => $user->profile->birthday->toDateString(), ]); $this->actingAs($admin) @@ -176,6 +180,7 @@ public function testAdminCanEditUser(): void "position" => "Test position", "employmentForm" => EmploymentForm::B2bContract->value, "employmentDate" => Carbon::now()->toDateString(), + "birthday" => Carbon::create(1990, 5, 31)->toDateString(), ]) ->assertSessionHasNoErrors(); @@ -192,6 +197,7 @@ public function testAdminCanEditUser(): void "position" => "Test position", "employment_form" => EmploymentForm::B2bContract->value, "employment_date" => Carbon::now()->toDateString(), + "birthday" => Carbon::create(1990, 5, 31)->toDateString(), ]); } @@ -239,6 +245,7 @@ public function testChangingUserRoleUpdatesPermissions(): void "position" => "Test position", "employmentForm" => EmploymentForm::B2bContract->value, "employmentDate" => Carbon::now()->toDateString(), + "birthday" => Carbon::create(1990, 5, 31)->toDateString(), ]) ->assertSessionHasNoErrors();