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);
}
}