This commit is contained in:
Adrian Hopek
2022-03-29 15:13:10 +02:00
parent 93f0151b14
commit 3c43f6814d
28 changed files with 176 additions and 144 deletions

View File

@@ -7,6 +7,8 @@ namespace Tests\Unit;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Tests\TestCase;
use Tests\Traits\InteractsWithYearPeriods;
use Toby\Domain\Actions\CreateUserAction;
use Toby\Domain\Actions\CreateYearPeriodAction;
use Toby\Eloquent\Models\User;
use Toby\Eloquent\Models\YearPeriod;
@@ -27,7 +29,11 @@ class VacationLimitTest extends TestCase
$this->assertDatabaseCount("vacation_limits", 0);
$currentYearPeriod = YearPeriod::current();
$user = User::factory()->create();
$createUserAction = $this->app->make(CreateUserAction::class);
$dumpData = User::factory()->raw();
$user = $createUserAction->execute($dumpData);
$this->assertDatabaseCount("vacation_limits", 1);
@@ -40,10 +46,12 @@ class VacationLimitTest extends TestCase
public function testWhenYearPeriodIsCreatedThenVacationLimitsForThisYearPeriodAreCreated(): void
{
$this->assertDatabaseCount("vacation_limits", 0);
$createYearPeriodAction = $this->app->make(CreateYearPeriodAction::class);
$lastYear = YearPeriod::query()->max("year") + 1;
User::factory(10)->createQuietly();
User::factory(10)->create();
YearPeriod::factory()->create();
$createYearPeriodAction->execute($lastYear);
$this->assertDatabaseCount("vacation_limits", 10);
}

View File

@@ -39,16 +39,16 @@ class VacationRequestNotificationTest extends TestCase
$user = User::factory([
"role" => Role::Employee,
])->createQuietly();
])->create();
$technicalApprover = User::factory([
"role" => Role::TechnicalApprover,
])->createQuietly();
])->create();
$administrativeApprover = User::factory([
"role" => Role::AdministrativeApprover,
])->createQuietly();
])->create();
$admin = User::factory([
"role" => Role::Administrator,
])->createQuietly();
])->create();
$currentYearPeriod = YearPeriod::current();
@@ -78,13 +78,13 @@ class VacationRequestNotificationTest extends TestCase
$technicalApprover = User::factory([
"role" => Role::TechnicalApprover,
])->createQuietly();
])->create();
$administrativeApprover = User::factory([
"role" => Role::AdministrativeApprover,
])->createQuietly();
])->create();
$admin = User::factory([
"role" => Role::Administrator,
])->createQuietly();
])->create();
$currentYearPeriod = YearPeriod::current();

View File

@@ -40,7 +40,7 @@ class VacationRequestStatesTest extends TestCase
public function testAfterCreatingVacationRequestOfTypeVacationItTransitsToProperState(): void
{
$user = User::factory()->createQuietly();
$user = User::factory()->create();
$currentYearPeriod = YearPeriod::current();
@@ -63,7 +63,7 @@ class VacationRequestStatesTest extends TestCase
public function testAfterCreatingVacationRequestOfTypeSickVacationItTransitsToProperState(): void
{
$user = User::factory()->createQuietly();
$user = User::factory()->create();
$currentYearPeriod = YearPeriod::current();
@@ -85,7 +85,7 @@ class VacationRequestStatesTest extends TestCase
public function testAfterCreatingVacationRequestOfTypeTimeInLieuItTransitsToProperState(): void
{
$user = User::factory()->createQuietly();
$user = User::factory()->create();
$currentYearPeriod = YearPeriod::current();

View File

@@ -60,7 +60,14 @@ class YearPeriodRetrieverTest extends TestCase
public function testLinks(): void
{
$expected = [
"current" => $this->current->year,
"current" => [
"year" => $this->currentYearPeriod->year,
"link" => route("year-periods.select", $this->currentYearPeriod),
],
"selected" => [
"year" => $this->currentYearPeriod->year,
"link" => route("year-periods.select", $this->currentYearPeriod),
],
"navigation" => [
[
"year" => $this->previousYearPeriod->year,