This commit is contained in:
Adrian Hopek
2022-01-24 10:19:26 +01:00
parent b4c6cfe612
commit 75889a16e6
12 changed files with 223 additions and 24 deletions

View File

@@ -7,16 +7,19 @@ namespace Tests\Unit;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Support\Facades\Storage;
use Tests\TestCase;
use Tests\Traits\InteractsWithYearPeriods;
use Toby\Models\User;
class AvatarTest extends TestCase
{
use DatabaseMigrations;
use InteractsWithYearPeriods;
protected function setUp(): void
{
parent::setUp();
$this->createCurrentYearPeriod();
Storage::fake();
}

View File

@@ -0,0 +1,50 @@
<?php
declare(strict_types=1);
namespace Tests\Unit;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Tests\TestCase;
use Tests\Traits\InteractsWithYearPeriods;
use Toby\Models\User;
use Toby\Models\YearPeriod;
class VacationLimitTest extends TestCase
{
use DatabaseMigrations;
use InteractsWithYearPeriods;
protected function setUp(): void
{
parent::setUp();
$this->createCurrentYearPeriod();
}
public function testWhenUserIsCreatedThenVacationLimitIsCreatedForCurrentYearPeriod(): void
{
$this->assertDatabaseCount("vacation_limits", 0);
$currentYearPeriod = YearPeriod::current();
$user = User::factory()->create();
$this->assertDatabaseCount("vacation_limits", 1);
$this->assertDatabaseHas("vacation_limits", [
"user_id" => $user->id,
"year_period_id" => $currentYearPeriod->id,
]);
}
public function testWhenYearPeriodIsCreatedThenVacationLimitsForThisYearPeriodAreCreated(): void
{
$this->assertDatabaseCount("vacation_limits", 0);
User::factory(10)->createQuietly();
YearPeriod::factory()->create();
$this->assertDatabaseCount("vacation_limits", 10);
}
}