yearPeriodRetriever = $this->app->make(YearPeriodRetriever::class); } public function testUserCanSelectNextYearPeriod(): void { $nextYearPeriod = $this->createYearPeriod(Carbon::now()->year + 1); $user = User::factory()->create(); $this->actingAs($user) ->post("/year-periods/{$nextYearPeriod->id}/select") ->assertRedirect(); $this->assertSame($nextYearPeriod->id, $this->yearPeriodRetriever->selected()->id); } public function testUserCannotSelectNextYearPeriodIfDoesntExist(): void { $user = User::factory()->create(); $this->actingAs($user) ->post("/year-periods/25/select") ->assertNotFound(); } public function testIfUserDoesntSelectAnyYearPeriodCurrentActsAsSelected(): void { $currentYearPeriod = $this->yearPeriodRetriever->current(); $this->assertSame($currentYearPeriod->id, $this->yearPeriodRetriever->selected()->id); } }