* #38 - wip * #38 - wip * #38 - fix * #38 - fix * #38 - fix * #38 - fix * Update resources/lang/pl.json Co-authored-by: Krzysztof Rewak <krzysztof.rewak@blumilk.pl> * #38 - cr fix Co-authored-by: EwelinaLasowy <ewelina.lasowy@blumilk.pl> Co-authored-by: Krzysztof Rewak <krzysztof.rewak@blumilk.pl>
This commit is contained in:
@@ -13,6 +13,7 @@ use Toby\Domain\Enums\VacationRequestState;
|
||||
use Toby\Domain\Enums\VacationType;
|
||||
use Toby\Domain\Events\VacationRequestAcceptedByAdministrative;
|
||||
use Toby\Domain\Events\VacationRequestAcceptedByTechnical;
|
||||
use Toby\Domain\Events\VacationRequestApproved;
|
||||
use Toby\Domain\Events\VacationRequestRejected;
|
||||
use Toby\Domain\PolishHolidaysRetriever;
|
||||
use Toby\Eloquent\Models\User;
|
||||
@@ -69,6 +70,7 @@ class VacationRequestTest extends FeatureTestCase
|
||||
|
||||
$this->actingAs($user)
|
||||
->post("/vacation-requests", [
|
||||
"user" => $user->id,
|
||||
"type" => VacationType::Vacation->value,
|
||||
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
||||
"to" => Carbon::create($currentYearPeriod->year, 2, 11)->toDateString(),
|
||||
@@ -88,6 +90,83 @@ class VacationRequestTest extends FeatureTestCase
|
||||
]);
|
||||
}
|
||||
|
||||
public function testUserCanCreateVacationRequestOnEmployeeBehalf(): void
|
||||
{
|
||||
$creator = User::factory()->createQuietly();
|
||||
$user = User::factory()->createQuietly();
|
||||
|
||||
$currentYearPeriod = YearPeriod::current();
|
||||
|
||||
VacationLimit::factory([
|
||||
"days" => 20,
|
||||
])
|
||||
->for($user)
|
||||
->for($currentYearPeriod)
|
||||
->create();
|
||||
|
||||
$this->actingAs($creator)
|
||||
->post("/vacation-requests", [
|
||||
"user" => $user->id,
|
||||
"type" => VacationType::Vacation->value,
|
||||
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
||||
"to" => Carbon::create($currentYearPeriod->year, 2, 11)->toDateString(),
|
||||
"comment" => "Comment for the vacation request.",
|
||||
])
|
||||
->assertSessionHasNoErrors();
|
||||
|
||||
$this->assertDatabaseHas("vacation_requests", [
|
||||
"user_id" => $user->id,
|
||||
"creator_id" => $creator->id,
|
||||
"year_period_id" => $currentYearPeriod->id,
|
||||
"name" => "1/" . $currentYearPeriod->year,
|
||||
"type" => VacationType::Vacation->value,
|
||||
"state" => VacationRequestState::WaitingForTechnical,
|
||||
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
||||
"to" => Carbon::create($currentYearPeriod->year, 2, 11)->toDateString(),
|
||||
"comment" => "Comment for the vacation request.",
|
||||
]);
|
||||
}
|
||||
|
||||
public function testUserCanCreateVacationRequestOnEmployeeBehalfAndSkipAcceptanceFlow(): void
|
||||
{
|
||||
Event::fake(VacationRequestApproved::class);
|
||||
|
||||
$creator = User::factory()->createQuietly();
|
||||
$user = User::factory()->createQuietly();
|
||||
|
||||
$currentYearPeriod = YearPeriod::current();
|
||||
|
||||
VacationLimit::factory([
|
||||
"days" => 20,
|
||||
])
|
||||
->for($user)
|
||||
->for($currentYearPeriod)
|
||||
->create();
|
||||
|
||||
$this->actingAs($creator)
|
||||
->post("/vacation-requests", [
|
||||
"user" => $user->id,
|
||||
"type" => VacationType::Vacation->value,
|
||||
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
||||
"to" => Carbon::create($currentYearPeriod->year, 2, 11)->toDateString(),
|
||||
"comment" => "Comment for the vacation request.",
|
||||
"flowSkipped" => true,
|
||||
])
|
||||
->assertSessionHasNoErrors();
|
||||
|
||||
$this->assertDatabaseHas("vacation_requests", [
|
||||
"user_id" => $user->id,
|
||||
"creator_id" => $creator->id,
|
||||
"year_period_id" => $currentYearPeriod->id,
|
||||
"name" => "1/" . $currentYearPeriod->year,
|
||||
"type" => VacationType::Vacation->value,
|
||||
"state" => VacationRequestState::Approved,
|
||||
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
||||
"to" => Carbon::create($currentYearPeriod->year, 2, 11)->toDateString(),
|
||||
"comment" => "Comment for the vacation request.",
|
||||
]);
|
||||
}
|
||||
|
||||
public function testTechnicalApproverCanApproveVacationRequest(): void
|
||||
{
|
||||
Event::fake(VacationRequestAcceptedByTechnical::class);
|
||||
@@ -178,6 +257,7 @@ class VacationRequestTest extends FeatureTestCase
|
||||
|
||||
$this->actingAs($user)
|
||||
->post("/vacation-requests", [
|
||||
"user" => $user->id,
|
||||
"type" => VacationType::Vacation->value,
|
||||
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
||||
"to" => Carbon::create($currentYearPeriod->year, 2, 11)->toDateString(),
|
||||
@@ -202,6 +282,7 @@ class VacationRequestTest extends FeatureTestCase
|
||||
|
||||
$this->actingAs($user)
|
||||
->post("/vacation-requests", [
|
||||
"user" => $user->id,
|
||||
"type" => VacationType::Vacation->value,
|
||||
"from" => Carbon::create($currentYearPeriod->year, 2, 5)->toDateString(),
|
||||
"to" => Carbon::create($currentYearPeriod->year, 2, 6)->toDateString(),
|
||||
@@ -233,6 +314,7 @@ class VacationRequestTest extends FeatureTestCase
|
||||
|
||||
$this->actingAs($user)
|
||||
->post("/vacation-requests", [
|
||||
"user" => $user->id,
|
||||
"type" => VacationType::Vacation->value,
|
||||
"from" => Carbon::create($currentYearPeriod->year, 4, 18)->toDateString(),
|
||||
"to" => Carbon::create($currentYearPeriod->year, 4, 18)->toDateString(),
|
||||
@@ -268,6 +350,7 @@ class VacationRequestTest extends FeatureTestCase
|
||||
|
||||
$this->actingAs($user)
|
||||
->post("/vacation-requests", [
|
||||
"user" => $user->id,
|
||||
"type" => VacationType::Vacation->value,
|
||||
"from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(),
|
||||
"to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(),
|
||||
@@ -304,6 +387,7 @@ class VacationRequestTest extends FeatureTestCase
|
||||
|
||||
$this->actingAs($user)
|
||||
->post("/vacation-requests", [
|
||||
"user" => $user->id,
|
||||
"type" => VacationType::Vacation->value,
|
||||
"from" => Carbon::create($currentYearPeriod->year, 2, 1)->toDateString(),
|
||||
"to" => Carbon::create($currentYearPeriod->year, 2, 4)->toDateString(),
|
||||
@@ -320,6 +404,7 @@ class VacationRequestTest extends FeatureTestCase
|
||||
$currentYearPeriod = YearPeriod::current();
|
||||
$this->actingAs($user)
|
||||
->post("/vacation-requests", [
|
||||
"user" => $user->id,
|
||||
"type" => VacationType::Vacation->value,
|
||||
"from" => Carbon::create($currentYearPeriod->year, 2, 7)->toDateString(),
|
||||
"to" => Carbon::create($currentYearPeriod->year, 2, 6)->toDateString(),
|
||||
@@ -337,6 +422,7 @@ class VacationRequestTest extends FeatureTestCase
|
||||
$nextYearPeriod = $this->createYearPeriod(Carbon::now()->year + 1);
|
||||
$this->actingAs($user)
|
||||
->post("/vacation-requests", [
|
||||
"user" => $user->id,
|
||||
"type" => VacationType::Vacation->value,
|
||||
"from" => Carbon::create($currentYearPeriod->year, 12, 27)->toDateString(),
|
||||
"to" => Carbon::create($nextYearPeriod->year, 1, 2)->toDateString(),
|
||||
|
Reference in New Issue
Block a user