#22 - cr fixes

This commit is contained in:
Adrian Hopek 2022-02-15 13:19:41 +01:00
parent 09da5cacda
commit 26b9d2da0c
15 changed files with 158 additions and 145 deletions

View File

@ -73,7 +73,7 @@ class CalendarGenerator
{ {
return Vacation::query() return Vacation::query()
->whereBetween("date", [$period->start, $period->end]) ->whereBetween("date", [$period->start, $period->end])
->whereRelation("vacationRequest", "state", VacationRequestState::APPROVED->value) ->whereRelation("vacationRequest", "state", VacationRequestState::Approved->value)
->get() ->get()
->groupBy(fn(Vacation $vacation) => $vacation->date->toDateString()); ->groupBy(fn(Vacation $vacation) => $vacation->date->toDateString());
} }

View File

@ -6,10 +6,10 @@ namespace Toby\Domain\Enums;
enum EmploymentForm: string enum EmploymentForm: string
{ {
case EMPLOYMENT_CONTRACT = "employment_contract"; case EmploymentContract = "employment_contract";
case COMMISSION_CONTRACT = "commission_contract"; case ComissionContract = "commission_contract";
case B2B_CONTRACT = "b2b_contract"; case B2bContract = "b2b_contract";
case BOARD_MEMBER_CONTRACT = "board_member_contract"; case BoardMemberContract = "board_member_contract";
public function label(): string public function label(): string
{ {

View File

@ -6,10 +6,10 @@ namespace Toby\Domain\Enums;
enum Role: string enum Role: string
{ {
case EMPLOYEE = "employee"; case Employee = "employee";
case ADMINISTRATOR = "administrator"; case Administrator = "administrator";
case TECHNICAL_APPROVER = "technical_approver"; case TechnicalApprover = "technical_approver";
case ADMINISTRATIVE_APPROVER = "administrative_approver"; case AdministrativeApprover = "administrative_approver";
public function label(): string public function label(): string
{ {

View File

@ -6,14 +6,14 @@ namespace Toby\Domain\Enums;
enum VacationRequestState: string enum VacationRequestState: string
{ {
case CREATED = "created"; case Created = "created";
case CANCELED = "canceled"; case Canceled = "canceled";
case REJECTED = "rejected"; case Rejected = "rejected";
case APPROVED = "approved"; case Approved = "approved";
case WAITING_FOR_TECHNICAL = "waiting_for_technical"; case WaitingForTechnical = "waiting_for_technical";
case WAITING_FOR_ADMINISTRATIVE = "waiting_for_administrative"; case WaitingForAdministrative = "waiting_for_administrative";
case ACCEPTED_BY_TECHNICAL = "accepted_by_technical"; case AcceptedByTechnical = "accepted_by_technical";
case ACCEPTED_BY_ADMINISTRATIVE = "accepted_by_administrative"; case AcceptedByAdministrative = "accepted_by_administrative";
public function label(): string public function label(): string
{ {
@ -23,24 +23,24 @@ enum VacationRequestState: string
public static function pendingStates(): array public static function pendingStates(): array
{ {
return [ return [
self::CREATED, self::Created,
self::WAITING_FOR_TECHNICAL, self::WaitingForTechnical,
self::WAITING_FOR_ADMINISTRATIVE, self::WaitingForAdministrative,
self::ACCEPTED_BY_TECHNICAL, self::AcceptedByTechnical,
self::ACCEPTED_BY_ADMINISTRATIVE, self::AcceptedByAdministrative,
]; ];
} }
public static function successStates(): array public static function successStates(): array
{ {
return [self::APPROVED]; return [self::Approved];
} }
public static function failedStates(): array public static function failedStates(): array
{ {
return [ return [
self::REJECTED, self::Rejected,
self::CANCELED, self::Canceled,
]; ];
} }

View File

@ -6,15 +6,15 @@ namespace Toby\Domain\Enums;
enum VacationType: string enum VacationType: string
{ {
case VACATION = "vacation"; case Vacation = "vacation";
case VACATION_ON_REQUEST = "vacation_on_request"; case OnRequest = "vacation_on_request";
case SPECIAL_VACATION = "special_vacation"; case Special = "special_vacation";
case CHILDCARE_VACATION = "childcare_vacation"; case Childcare = "childcare_vacation";
case TRAINING_VACATION = "training_vacation"; case Training = "training_vacation";
case UNPAID_VACATION = "unpaid_vacation"; case Unpaid = "unpaid_vacation";
case VOLUNTEERING_VACATION = "volunteering_vacation"; case Volunteering = "volunteering_vacation";
case TIME_IN_LIEU = "time_in_lieu"; case TimeInLieu = "time_in_lieu";
case SICK_VACATION = "sick_vacation"; case Sick = "sick_vacation";
public function label(): string public function label(): string
{ {

View File

@ -23,50 +23,50 @@ class VacationRequestStateManager
public function markAsCreated(VacationRequest $vacationRequest): void public function markAsCreated(VacationRequest $vacationRequest): void
{ {
$this->changeState($vacationRequest, VacationRequestState::CREATED); $this->changeState($vacationRequest, VacationRequestState::Created);
$this->dispatcher->dispatch(new VacationRequestCreated($vacationRequest)); $this->dispatcher->dispatch(new VacationRequestCreated($vacationRequest));
} }
public function approve(VacationRequest $vacationRequest): void public function approve(VacationRequest $vacationRequest): void
{ {
$this->changeState($vacationRequest, VacationRequestState::APPROVED); $this->changeState($vacationRequest, VacationRequestState::Approved);
$this->dispatcher->dispatch(new VacationRequestApproved($vacationRequest)); $this->dispatcher->dispatch(new VacationRequestApproved($vacationRequest));
} }
public function reject(VacationRequest $vacationRequest): void public function reject(VacationRequest $vacationRequest): void
{ {
$this->changeState($vacationRequest, VacationRequestState::REJECTED); $this->changeState($vacationRequest, VacationRequestState::Rejected);
} }
public function cancel(VacationRequest $vacationRequest): void public function cancel(VacationRequest $vacationRequest): void
{ {
$this->changeState($vacationRequest, VacationRequestState::CANCELED); $this->changeState($vacationRequest, VacationRequestState::Canceled);
} }
public function acceptAsTechnical(VacationRequest $vacationRequest): void public function acceptAsTechnical(VacationRequest $vacationRequest): void
{ {
$this->changeState($vacationRequest, VacationRequestState::ACCEPTED_BY_TECHNICAL); $this->changeState($vacationRequest, VacationRequestState::AcceptedByTechnical);
$this->dispatcher->dispatch(new VacationRequestAcceptedByTechnical($vacationRequest)); $this->dispatcher->dispatch(new VacationRequestAcceptedByTechnical($vacationRequest));
} }
public function acceptAsAdministrative(VacationRequest $vacationRequest): void public function acceptAsAdministrative(VacationRequest $vacationRequest): void
{ {
$this->changeState($vacationRequest, VacationRequestState::ACCEPTED_BY_ADMINISTRATIVE); $this->changeState($vacationRequest, VacationRequestState::AcceptedByAdministrative);
$this->dispatcher->dispatch(new VacationRequestAcceptedByAdministrative($vacationRequest)); $this->dispatcher->dispatch(new VacationRequestAcceptedByAdministrative($vacationRequest));
} }
public function waitForTechnical(VacationRequest $vacationRequest): void public function waitForTechnical(VacationRequest $vacationRequest): void
{ {
$this->changeState($vacationRequest, VacationRequestState::WAITING_FOR_TECHNICAL); $this->changeState($vacationRequest, VacationRequestState::WaitingForTechnical);
} }
public function waitForAdministrative(VacationRequest $vacationRequest): void public function waitForAdministrative(VacationRequest $vacationRequest): void
{ {
$this->changeState($vacationRequest, VacationRequestState::WAITING_FOR_ADMINISTRATIVE); $this->changeState($vacationRequest, VacationRequestState::WaitingForAdministrative);
} }
protected function changeState(VacationRequest $vacationRequest, VacationRequestState $state): void protected function changeState(VacationRequest $vacationRequest, VacationRequestState $state): void

View File

@ -6,55 +6,55 @@ use Toby\Domain\Enums\VacationType;
use Toby\Domain\VacationTypeConfigRetriever; use Toby\Domain\VacationTypeConfigRetriever;
return [ return [
VacationType::VACATION->value => [ VacationType::Vacation->value => [
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true, VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true, VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true,
VacationTypeConfigRetriever::KEY_BILLABLE => true, VacationTypeConfigRetriever::KEY_BILLABLE => true,
VacationTypeConfigRetriever::KEY_HAS_LIMIT => true, VacationTypeConfigRetriever::KEY_HAS_LIMIT => true,
], ],
VacationType::VACATION_ON_REQUEST->value => [ VacationType::OnRequest->value => [
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true, VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true, VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true,
VacationTypeConfigRetriever::KEY_BILLABLE => true, VacationTypeConfigRetriever::KEY_BILLABLE => true,
VacationTypeConfigRetriever::KEY_HAS_LIMIT => true, VacationTypeConfigRetriever::KEY_HAS_LIMIT => true,
], ],
VacationType::TIME_IN_LIEU->value => [ VacationType::TimeInLieu->value => [
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => false, VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => false,
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => false, VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => false,
VacationTypeConfigRetriever::KEY_BILLABLE => true, VacationTypeConfigRetriever::KEY_BILLABLE => true,
VacationTypeConfigRetriever::KEY_HAS_LIMIT => false, VacationTypeConfigRetriever::KEY_HAS_LIMIT => false,
], ],
VacationType::SICK_VACATION->value => [ VacationType::Sick->value => [
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => false, VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => false,
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true, VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true,
VacationTypeConfigRetriever::KEY_BILLABLE => true, VacationTypeConfigRetriever::KEY_BILLABLE => true,
VacationTypeConfigRetriever::KEY_HAS_LIMIT => false, VacationTypeConfigRetriever::KEY_HAS_LIMIT => false,
], ],
VacationType::UNPAID_VACATION->value => [ VacationType::Unpaid->value => [
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true, VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true, VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true,
VacationTypeConfigRetriever::KEY_BILLABLE => false, VacationTypeConfigRetriever::KEY_BILLABLE => false,
VacationTypeConfigRetriever::KEY_HAS_LIMIT => false, VacationTypeConfigRetriever::KEY_HAS_LIMIT => false,
], ],
VacationType::SPECIAL_VACATION->value => [ VacationType::Special->value => [
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true, VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true, VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true,
VacationTypeConfigRetriever::KEY_BILLABLE => false, VacationTypeConfigRetriever::KEY_BILLABLE => false,
VacationTypeConfigRetriever::KEY_HAS_LIMIT => false, VacationTypeConfigRetriever::KEY_HAS_LIMIT => false,
], ],
VacationType::CHILDCARE_VACATION->value => [ VacationType::Childcare->value => [
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true, VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true, VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true,
VacationTypeConfigRetriever::KEY_BILLABLE => false, VacationTypeConfigRetriever::KEY_BILLABLE => false,
VacationTypeConfigRetriever::KEY_HAS_LIMIT => false, VacationTypeConfigRetriever::KEY_HAS_LIMIT => false,
], ],
VacationType::TRAINING_VACATION->value => [ VacationType::Training->value => [
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true, VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true, VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true,
VacationTypeConfigRetriever::KEY_BILLABLE => true, VacationTypeConfigRetriever::KEY_BILLABLE => true,
VacationTypeConfigRetriever::KEY_HAS_LIMIT => false, VacationTypeConfigRetriever::KEY_HAS_LIMIT => false,
], ],
VacationType::VOLUNTEERING_VACATION->value => [ VacationType::Volunteering->value => [
VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true, VacationTypeConfigRetriever::KEY_TECHNICAL_APPROVAL => true,
VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true, VacationTypeConfigRetriever::KEY_ADMINISTRATIVE_APPROVAL => true,
VacationTypeConfigRetriever::KEY_BILLABLE => true, VacationTypeConfigRetriever::KEY_BILLABLE => true,

View File

@ -23,7 +23,7 @@ class UserFactory extends Factory
"email" => $this->faker->unique()->safeEmail(), "email" => $this->faker->unique()->safeEmail(),
"employment_form" => $this->faker->randomElement(EmploymentForm::cases()), "employment_form" => $this->faker->randomElement(EmploymentForm::cases()),
"position" => $this->faker->jobTitle(), "position" => $this->faker->jobTitle(),
"role" => Role::EMPLOYEE, "role" => Role::Employee,
"employment_date" => Carbon::createFromInterface($this->faker->dateTimeBetween("2020-10-27"))->toDateString(), "employment_date" => Carbon::createFromInterface($this->faker->dateTimeBetween("2020-10-27"))->toDateString(),
"remember_token" => Str::random(10), "remember_token" => Str::random(10),
]; ];

View File

@ -16,7 +16,7 @@ return new class() extends Migration {
$table->string("last_name"); $table->string("last_name");
$table->string("email")->unique(); $table->string("email")->unique();
$table->string("avatar")->nullable(); $table->string("avatar")->nullable();
$table->string("role")->default(Role::EMPLOYEE->value); $table->string("role")->default(Role::Employee->value);
$table->string("position"); $table->string("position");
$table->string("employment_form"); $table->string("employment_form");
$table->date("employment_date"); $table->date("employment_date");

View File

@ -0,0 +1,60 @@
const months = [
{
'name': 'Styczeń',
'value': 'january',
},
{
'name': 'Luty',
'value': 'february',
},
{
'name': 'Marzec',
'value': 'march',
},
{
'name': 'Kwiecień',
'value': 'april',
},
{
'name': 'Maj',
'value': 'may',
},
{
'name': 'Czerwiec',
'value': 'june',
},
{
'name': 'Lipiec',
'value': 'july',
},
{
'name': 'Sierpień',
'value': 'august',
},
{
'name': 'Wrzesień',
'value': 'september',
},
{
'name': 'Październik',
'value': 'october',
},
{
'name': 'Listopad',
'value': 'november',
},
{
'name': 'Grudzień',
'value': 'december',
},
]
export function useMonthInfo() {
const getMonths = () => months
const findMonth = value => months.find(month => month.value === value)
return {
getMonths,
findMonth,
}
}

View File

@ -31,7 +31,7 @@ const statuses = [
}, },
}, },
{ {
text: 'Czeka na akceptację od technicznego', text: 'Czeka na akceptację od przełożonego technicznego',
value: 'waiting_for_technical', value: 'waiting_for_technical',
outline: { outline: {
icon: OutlineClockIcon, icon: OutlineClockIcon,
@ -44,7 +44,7 @@ const statuses = [
}, },
}, },
{ {
text: 'Czeka na akceptację od administracyjnego', text: 'Czeka na akceptację od przełożonego administracyjnego',
value: 'waiting_for_administrative', value: 'waiting_for_administrative',
outline: { outline: {
icon: OutlineClockIcon, icon: OutlineClockIcon,

View File

@ -126,6 +126,7 @@
import {Menu, MenuButton, MenuItem, MenuItems} from '@headlessui/vue' import {Menu, MenuButton, MenuItem, MenuItems} from '@headlessui/vue'
import {CheckIcon, ChevronDownIcon} from '@heroicons/vue/solid' import {CheckIcon, ChevronDownIcon} from '@heroicons/vue/solid'
import {computed} from 'vue' import {computed} from 'vue'
import {useMonthInfo} from '@/Composables/monthInfo'
export default { export default {
name: 'VacationCalendar', name: 'VacationCalendar',
@ -152,58 +153,10 @@ export default {
}, },
}, },
setup(props) { setup(props) {
const months = [ const {getMonths, findMonth} = useMonthInfo()
{ const months = getMonths()
'name': 'Styczeń',
'value': 'january',
},
{
'name': 'Luty',
'value': 'february',
},
{
'name': 'Marzec',
'value': 'march',
},
{
'name': 'Kwiecień',
'value': 'april',
},
{
'name': 'Maj',
'value': 'may',
},
{
'name': 'Czerwiec',
'value': 'june',
},
{
'name': 'Lipiec',
'value': 'july',
},
{
'name': 'Sierpień',
'value': 'august',
},
{
'name': 'Wrzesień',
'value': 'september',
},
{
'name': 'Październik',
'value': 'october',
},
{
'name': 'Listopad',
'value': 'november',
},
{
'name': 'Grudzień',
'value': 'december',
},
]
const selectedMonth = computed(() => months.find(month => month.value === props.currentMonth)) const selectedMonth = computed(() => findMonth(props.currentMonth))
return { return {
months, months,

View File

@ -88,10 +88,10 @@ class UserTest extends FeatureTestCase
->post("/users", [ ->post("/users", [
"firstName" => "John", "firstName" => "John",
"lastName" => "Doe", "lastName" => "Doe",
"role" => Role::EMPLOYEE->value, "role" => Role::Employee->value,
"position" => "Test position", "position" => "Test position",
"email" => "john.doe@example.com", "email" => "john.doe@example.com",
"employmentForm" => EmploymentForm::B2B_CONTRACT->value, "employmentForm" => EmploymentForm::B2bContract->value,
"employmentDate" => Carbon::now()->toDateString(), "employmentDate" => Carbon::now()->toDateString(),
]) ])
->assertSessionHasNoErrors(); ->assertSessionHasNoErrors();
@ -100,9 +100,9 @@ class UserTest extends FeatureTestCase
"first_name" => "John", "first_name" => "John",
"last_name" => "Doe", "last_name" => "Doe",
"email" => "john.doe@example.com", "email" => "john.doe@example.com",
"role" => Role::EMPLOYEE->value, "role" => Role::Employee->value,
"position" => "Test position", "position" => "Test position",
"employment_form" => EmploymentForm::B2B_CONTRACT->value, "employment_form" => EmploymentForm::B2bContract->value,
"employment_date" => Carbon::now()->toDateString(), "employment_date" => Carbon::now()->toDateString(),
]); ]);
} }
@ -127,9 +127,9 @@ class UserTest extends FeatureTestCase
"firstName" => "John", "firstName" => "John",
"lastName" => "Doe", "lastName" => "Doe",
"email" => "john.doe@example.com", "email" => "john.doe@example.com",
"role" => Role::EMPLOYEE->value, "role" => Role::Employee->value,
"position" => "Test position", "position" => "Test position",
"employmentForm" => EmploymentForm::B2B_CONTRACT->value, "employmentForm" => EmploymentForm::B2bContract->value,
"employmentDate" => Carbon::now()->toDateString(), "employmentDate" => Carbon::now()->toDateString(),
]) ])
->assertSessionHasNoErrors(); ->assertSessionHasNoErrors();
@ -138,9 +138,9 @@ class UserTest extends FeatureTestCase
"first_name" => "John", "first_name" => "John",
"last_name" => "Doe", "last_name" => "Doe",
"email" => "john.doe@example.com", "email" => "john.doe@example.com",
"role" => Role::EMPLOYEE->value, "role" => Role::Employee->value,
"position" => "Test position", "position" => "Test position",
"employment_form" => EmploymentForm::B2B_CONTRACT->value, "employment_form" => EmploymentForm::B2bContract->value,
"employment_date" => Carbon::now()->toDateString(), "employment_date" => Carbon::now()->toDateString(),
]); ]);
} }

View File

@ -65,7 +65,7 @@ class VacationRequestTest extends FeatureTestCase
$this->actingAs($user) $this->actingAs($user)
->post("/vacation-requests", [ ->post("/vacation-requests", [
"type" => VacationType::VACATION->value, "type" => VacationType::Vacation->value,
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(), "from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
"to" => Carbon::create($currentYearPeriod->year, 2, 11)->toDateString(), "to" => Carbon::create($currentYearPeriod->year, 2, 11)->toDateString(),
"comment" => "Comment for the vacation request.", "comment" => "Comment for the vacation request.",
@ -76,8 +76,8 @@ class VacationRequestTest extends FeatureTestCase
"user_id" => $user->id, "user_id" => $user->id,
"year_period_id" => $currentYearPeriod->id, "year_period_id" => $currentYearPeriod->id,
"name" => "1/" . $currentYearPeriod->year, "name" => "1/" . $currentYearPeriod->year,
"type" => VacationType::VACATION->value, "type" => VacationType::Vacation->value,
"state" => VacationRequestState::WAITING_FOR_TECHNICAL, "state" => VacationRequestState::WaitingForTechnical,
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(), "from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
"to" => Carbon::create($currentYearPeriod->year, 2, 11)->toDateString(), "to" => Carbon::create($currentYearPeriod->year, 2, 11)->toDateString(),
"comment" => "Comment for the vacation request.", "comment" => "Comment for the vacation request.",
@ -91,8 +91,8 @@ class VacationRequestTest extends FeatureTestCase
$currentYearPeriod = YearPeriod::current(); $currentYearPeriod = YearPeriod::current();
$vacationRequest = VacationRequest::factory([ $vacationRequest = VacationRequest::factory([
"state" => VacationRequestState::WAITING_FOR_TECHNICAL, "state" => VacationRequestState::WaitingForTechnical,
"type" => VacationType::VACATION, "type" => VacationType::Vacation,
]) ])
->for($user) ->for($user)
->for($currentYearPeriod) ->for($currentYearPeriod)
@ -103,7 +103,7 @@ class VacationRequestTest extends FeatureTestCase
->assertSessionHasNoErrors(); ->assertSessionHasNoErrors();
$this->assertDatabaseHas("vacation_requests", [ $this->assertDatabaseHas("vacation_requests", [
"state" => VacationRequestState::WAITING_FOR_ADMINISTRATIVE, "state" => VacationRequestState::WaitingForAdministrative,
]); ]);
} }
@ -115,7 +115,7 @@ class VacationRequestTest extends FeatureTestCase
$currentYearPeriod = YearPeriod::current(); $currentYearPeriod = YearPeriod::current();
$vacationRequest = VacationRequest::factory([ $vacationRequest = VacationRequest::factory([
"state" => VacationRequestState::WAITING_FOR_ADMINISTRATIVE, "state" => VacationRequestState::WaitingForAdministrative,
]) ])
->for($user) ->for($user)
->for($currentYearPeriod) ->for($currentYearPeriod)
@ -126,7 +126,7 @@ class VacationRequestTest extends FeatureTestCase
->assertSessionHasNoErrors(); ->assertSessionHasNoErrors();
$this->assertDatabaseHas("vacation_requests", [ $this->assertDatabaseHas("vacation_requests", [
"state" => VacationRequestState::APPROVED, "state" => VacationRequestState::Approved,
]); ]);
} }
@ -144,8 +144,8 @@ class VacationRequestTest extends FeatureTestCase
->create(); ->create();
$vacationRequest = VacationRequest::factory([ $vacationRequest = VacationRequest::factory([
"state" => VacationRequestState::WAITING_FOR_TECHNICAL, "state" => VacationRequestState::WaitingForTechnical,
"type" => VacationType::VACATION, "type" => VacationType::Vacation,
]) ])
->for($user) ->for($user)
->for($currentYearPeriod) ->for($currentYearPeriod)
@ -156,7 +156,7 @@ class VacationRequestTest extends FeatureTestCase
->assertSessionHasNoErrors(); ->assertSessionHasNoErrors();
$this->assertDatabaseHas("vacation_requests", [ $this->assertDatabaseHas("vacation_requests", [
"state" => VacationRequestState::REJECTED, "state" => VacationRequestState::Rejected,
]); ]);
} }
@ -174,7 +174,7 @@ class VacationRequestTest extends FeatureTestCase
$this->actingAs($user) $this->actingAs($user)
->post("/vacation-requests", [ ->post("/vacation-requests", [
"type" => VacationType::VACATION->value, "type" => VacationType::Vacation->value,
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(), "from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
"to" => Carbon::create($currentYearPeriod->year, 2, 11)->toDateString(), "to" => Carbon::create($currentYearPeriod->year, 2, 11)->toDateString(),
"comment" => "Comment for the vacation request.", "comment" => "Comment for the vacation request.",
@ -198,7 +198,7 @@ class VacationRequestTest extends FeatureTestCase
$this->actingAs($user) $this->actingAs($user)
->post("/vacation-requests", [ ->post("/vacation-requests", [
"type" => VacationType::VACATION->value, "type" => VacationType::Vacation->value,
"from" => Carbon::create($currentYearPeriod->year, 2, 5)->toDateString(), "from" => Carbon::create($currentYearPeriod->year, 2, 5)->toDateString(),
"to" => Carbon::create($currentYearPeriod->year, 2, 6)->toDateString(), "to" => Carbon::create($currentYearPeriod->year, 2, 6)->toDateString(),
"comment" => "Vacation at weekend.", "comment" => "Vacation at weekend.",
@ -229,7 +229,7 @@ class VacationRequestTest extends FeatureTestCase
$this->actingAs($user) $this->actingAs($user)
->post("/vacation-requests", [ ->post("/vacation-requests", [
"type" => VacationType::VACATION->value, "type" => VacationType::Vacation->value,
"from" => Carbon::create($currentYearPeriod->year, 4, 18)->toDateString(), "from" => Carbon::create($currentYearPeriod->year, 4, 18)->toDateString(),
"to" => Carbon::create($currentYearPeriod->year, 4, 18)->toDateString(), "to" => Carbon::create($currentYearPeriod->year, 4, 18)->toDateString(),
"comment" => "Vacation at holiday.", "comment" => "Vacation at holiday.",
@ -252,8 +252,8 @@ class VacationRequestTest extends FeatureTestCase
->create(); ->create();
VacationRequest::factory([ VacationRequest::factory([
"type" => VacationType::VACATION->value, "type" => VacationType::Vacation->value,
"state" => VacationRequestState::WAITING_FOR_TECHNICAL, "state" => VacationRequestState::WaitingForTechnical,
"from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(), "from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(),
"to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(), "to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(),
"comment" => "Comment for the vacation request.", "comment" => "Comment for the vacation request.",
@ -264,7 +264,7 @@ class VacationRequestTest extends FeatureTestCase
$this->actingAs($user) $this->actingAs($user)
->post("/vacation-requests", [ ->post("/vacation-requests", [
"type" => VacationType::VACATION->value, "type" => VacationType::Vacation->value,
"from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(), "from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(),
"to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(), "to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(),
"comment" => "Another comment for the another vacation request.", "comment" => "Another comment for the another vacation request.",
@ -288,8 +288,8 @@ class VacationRequestTest extends FeatureTestCase
->create(); ->create();
VacationRequest::factory([ VacationRequest::factory([
"type" => VacationType::VACATION->value, "type" => VacationType::Vacation->value,
"state" => VacationRequestState::APPROVED, "state" => VacationRequestState::Approved,
"from" => Carbon::create($currentYearPeriod->year, 2, 2)->toDateString(), "from" => Carbon::create($currentYearPeriod->year, 2, 2)->toDateString(),
"to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(), "to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(),
"comment" => "Comment for the vacation request.", "comment" => "Comment for the vacation request.",
@ -300,7 +300,7 @@ class VacationRequestTest extends FeatureTestCase
$this->actingAs($user) $this->actingAs($user)
->post("/vacation-requests", [ ->post("/vacation-requests", [
"type" => VacationType::VACATION->value, "type" => VacationType::Vacation->value,
"from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(), "from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(),
"to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(), "to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(),
"comment" => "Another comment for the another vacation request.", "comment" => "Another comment for the another vacation request.",
@ -316,7 +316,7 @@ class VacationRequestTest extends FeatureTestCase
$currentYearPeriod = YearPeriod::current(); $currentYearPeriod = YearPeriod::current();
$this->actingAs($user) $this->actingAs($user)
->post("/vacation-requests", [ ->post("/vacation-requests", [
"type" => VacationType::VACATION->value, "type" => VacationType::Vacation->value,
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(), "from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
"to" => Carbon::create($currentYearPeriod->year, 2, 6)->toDateString(), "to" => Carbon::create($currentYearPeriod->year, 2, 6)->toDateString(),
"comment" => "Comment for the vacation request.", "comment" => "Comment for the vacation request.",
@ -333,7 +333,7 @@ class VacationRequestTest extends FeatureTestCase
$nextYearPeriod = $this->createYearPeriod(Carbon::now()->year + 1); $nextYearPeriod = $this->createYearPeriod(Carbon::now()->year + 1);
$this->actingAs($user) $this->actingAs($user)
->post("/vacation-requests", [ ->post("/vacation-requests", [
"type" => VacationType::VACATION->value, "type" => VacationType::Vacation->value,
"from" => Carbon::create($currentYearPeriod->year, 12, 27)->toDateString(), "from" => Carbon::create($currentYearPeriod->year, 12, 27)->toDateString(),
"to" => Carbon::create($nextYearPeriod->year, 1, 2)->toDateString(), "to" => Carbon::create($nextYearPeriod->year, 1, 2)->toDateString(),
"comment" => "Comment for the vacation request.", "comment" => "Comment for the vacation request.",

View File

@ -39,8 +39,8 @@ class VacationRequestStatesTest extends TestCase
/** @var VacationRequest $vacationRequest */ /** @var VacationRequest $vacationRequest */
$vacationRequest = VacationRequest::factory([ $vacationRequest = VacationRequest::factory([
"type" => VacationType::VACATION->value, "type" => VacationType::Vacation->value,
"state" => VacationRequestState::CREATED, "state" => VacationRequestState::Created,
"from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(), "from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(),
"to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(), "to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(),
"comment" => "Comment for the vacation request.", "comment" => "Comment for the vacation request.",
@ -51,7 +51,7 @@ class VacationRequestStatesTest extends TestCase
$this->stateManager->waitForTechnical($vacationRequest); $this->stateManager->waitForTechnical($vacationRequest);
$this->assertEquals(VacationRequestState::WAITING_FOR_TECHNICAL, $vacationRequest->state); $this->assertEquals(VacationRequestState::WaitingForTechnical, $vacationRequest->state);
} }
public function testAfterCreatingVacationRequestOfTypeSickVacationItTransitsToProperState(): void public function testAfterCreatingVacationRequestOfTypeSickVacationItTransitsToProperState(): void
@ -62,8 +62,8 @@ class VacationRequestStatesTest extends TestCase
/** @var VacationRequest $vacationRequest */ /** @var VacationRequest $vacationRequest */
$vacationRequest = VacationRequest::factory([ $vacationRequest = VacationRequest::factory([
"type" => VacationType::SICK_VACATION->value, "type" => VacationType::Sick->value,
"state" => VacationRequestState::CREATED, "state" => VacationRequestState::Created,
"from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(), "from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(),
"to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(), "to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(),
]) ])
@ -73,7 +73,7 @@ class VacationRequestStatesTest extends TestCase
$this->stateManager->approve($vacationRequest); $this->stateManager->approve($vacationRequest);
$this->assertEquals(VacationRequestState::APPROVED, $vacationRequest->state); $this->assertEquals(VacationRequestState::Approved, $vacationRequest->state);
} }
public function testAfterCreatingVacationRequestOfTypeTimeInLieuItTransitsToProperState(): void public function testAfterCreatingVacationRequestOfTypeTimeInLieuItTransitsToProperState(): void
@ -84,8 +84,8 @@ class VacationRequestStatesTest extends TestCase
/** @var VacationRequest $vacationRequest */ /** @var VacationRequest $vacationRequest */
$vacationRequest = VacationRequest::factory([ $vacationRequest = VacationRequest::factory([
"type" => VacationType::TIME_IN_LIEU->value, "type" => VacationType::TimeInLieu->value,
"state" => VacationRequestState::CREATED, "state" => VacationRequestState::Created,
"from" => Carbon::create($currentYearPeriod->year, 2, 2)->toDateString(), "from" => Carbon::create($currentYearPeriod->year, 2, 2)->toDateString(),
"to" => Carbon::create($currentYearPeriod->year, 2, 2)->toDateString(), "to" => Carbon::create($currentYearPeriod->year, 2, 2)->toDateString(),
]) ])
@ -95,6 +95,6 @@ class VacationRequestStatesTest extends TestCase
$this->stateManager->approve($vacationRequest); $this->stateManager->approve($vacationRequest);
$this->assertEquals(VacationRequestState::APPROVED, $vacationRequest->state); $this->assertEquals(VacationRequestState::Approved, $vacationRequest->state);
} }
} }