
* - directory refactor * - readme.md update * Update readme.md Co-authored-by: Adrian Hopek <adrian.hopek@blumilk.pl> * Update readme.md Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com> * Update readme.md Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com> * Update readme.md Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com> * Update readme.md Co-authored-by: Adrian Hopek <adrian.hopek@blumilk.pl> Co-authored-by: Ewelina Lasowy <56546832+EwelinaLasowy@users.noreply.github.com>
51 lines
1.2 KiB
PHP
51 lines
1.2 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\Unit;
|
|
|
|
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
|
use Tests\TestCase;
|
|
use Tests\Traits\InteractsWithYearPeriods;
|
|
use Toby\Eloquent\Models\User;
|
|
use Toby\Eloquent\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);
|
|
}
|
|
}
|