This commit is contained in:
Adrian Hopek
2022-01-21 15:17:59 +01:00
parent a62a428781
commit 5a51f24342
23 changed files with 2492 additions and 183 deletions

View File

@@ -7,12 +7,14 @@ namespace Tests\Unit;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Carbon;
use Tests\TestCase;
use Tests\Traits\InteractsWithYearPeriods;
use Toby\Jobs\CheckYearPeriod;
use Toby\Models\YearPeriod;
class CheckYearPeriodTest extends TestCase
{
use RefreshDatabase;
use InteractsWithYearPeriods;
public function testYearPeriodsAreCreatedWhenDontExist(): void
{
@@ -54,9 +56,7 @@ class CheckYearPeriodTest extends TestCase
$now = Carbon::now();
Carbon::setTestNow($now);
YearPeriod::factory([
"year" => $now->year,
]);
$this->createCurrentYearPeriod();
$this->assertDatabaseMissing("year_periods", [
"year" => $now->year + 1,
@@ -74,12 +74,8 @@ class CheckYearPeriodTest extends TestCase
$now = Carbon::now();
Carbon::setTestNow($now);
YearPeriod::factory([
"year" => $now->year,
])->create();
YearPeriod::factory([
"year" => $now->year + 1,
])->create();
$this->createCurrentYearPeriod();
$this->createYearPeriod($now->year + 1);
$this->assertDatabaseCount("year_periods", 2);