This commit is contained in:
Adrian Hopek
2022-01-24 11:21:00 +01:00
parent 03af084c04
commit 36b98e1e67
13 changed files with 54 additions and 39 deletions

View File

@@ -14,17 +14,25 @@ class SelectYearPeriodTest extends FeatureTestCase
{
use DatabaseMigrations;
protected YearPeriodRetriever $yearPeriodRetriever;
protected function setUp(): void
{
parent::setUp();
$this->yearPeriodRetriever = $this->app->make(YearPeriodRetriever::class);
}
public function testUserCanSelectNextYearPeriod(): void
{
$nextYearPeriod = $this->createYearPeriod(Carbon::now()->year + 1);
$user = User::factory()->create();
$yearPeriodRetriever = new YearPeriodRetriever();
$this->actingAs($user)
->post("/year-periods/{$nextYearPeriod->id}/select")
->assertRedirect();
$this->assertSame($nextYearPeriod->id, $yearPeriodRetriever->selected()->id);
$this->assertSame($nextYearPeriod->id, $this->yearPeriodRetriever->selected()->id);
}
public function testUserCannotSelectNextYearPeriodIfDoesntExist(): void
@@ -38,9 +46,8 @@ class SelectYearPeriodTest extends FeatureTestCase
public function testIfUserDoesntSelectAnyYearPeriodCurrentActsAsSelected(): void
{
$yearPeriodRetriever = new YearPeriodRetriever();
$currentYearPeriod = $yearPeriodRetriever->current();
$currentYearPeriod = $this->yearPeriodRetriever->current();
$this->assertSame($currentYearPeriod->id, $yearPeriodRetriever->selected()->id);
$this->assertSame($currentYearPeriod->id, $this->yearPeriodRetriever->selected()->id);
}
}

View File

@@ -41,17 +41,14 @@ class VacationLimitTest extends FeatureTestCase
$data = [
[
"id" => $limit1->id,
"hasVacation" => true,
"days" => 25,
],
[
"id" => $limit2->id,
"hasVacation" => false,
"days" => null,
],
[
"id" => $limit3->id,
"hasVacation" => true,
"days" => 20,
],
];
@@ -64,19 +61,16 @@ class VacationLimitTest extends FeatureTestCase
$this->assertDatabaseHas("vacation_limits", [
"id" => $limit1->id,
"has_vacation" => true,
"days" => 25,
]);
$this->assertDatabaseHas("vacation_limits", [
"id" => $limit2->id,
"has_vacation" => false,
"days" => null,
]);
$this->assertDatabaseHas("vacation_limits", [
"id" => $limit3->id,
"has_vacation" => true,
"days" => 20,
]);
}

View File

@@ -31,7 +31,7 @@ class YearPeriodRetrieverTest extends TestCase
$this->current = Carbon::now();
Carbon::setTestNow($this->current);
$this->yearPeriodRetriever = new YearPeriodRetriever();
$this->yearPeriodRetriever = $this->app->make(YearPeriodRetriever::class);
$this->previousYearPeriod = $this->createYearPeriod($this->current->year - 1);
$this->currentYearPeriod = $this->createCurrentYearPeriod();
@@ -43,7 +43,7 @@ class YearPeriodRetrieverTest extends TestCase
$this->assertSame($this->currentYearPeriod->id, $this->yearPeriodRetriever->current()->id);
}
public function testRetrievesCurrentYearPeriodWhenNoSelected(): void
public function testRetrievesCurrentYearPeriodWhenNoneIsSelected(): void
{
$this->clearSelectedYearPeriod();