* #23 - wip * #23 - wip * #23 - wip * #23 - wip * #23 - fix * #23 - ecs fix * #23 - fix * #23 - fix * #23 - cr fix
This commit is contained in:
53
tests/Feature/SelectYearPeriodTest.php
Normal file
53
tests/Feature/SelectYearPeriodTest.php
Normal file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Illuminate\Support\Carbon;
|
||||
use Tests\FeatureTestCase;
|
||||
use Toby\Helpers\YearPeriodRetriever;
|
||||
use Toby\Models\User;
|
||||
|
||||
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();
|
||||
|
||||
$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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user