mirror of
https://github.com/sp-tarkov/forge.git
synced 2025-02-12 20:20:41 -05:00
add test
This commit is contained in:
parent
d4c6675155
commit
fe280faf36
34
tests/Feature/ModVersionTest.php
Normal file
34
tests/Feature/ModVersionTest.php
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use App\Models\ModVersion;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Support\Carbon;
|
||||||
|
|
||||||
|
it('includes only published mod versions', function () {
|
||||||
|
$publishedMod = ModVersion::factory()->create([
|
||||||
|
'published_at' => Carbon::now()->subDay(),
|
||||||
|
]);
|
||||||
|
$unpublishedMod = ModVersion::factory()->create([
|
||||||
|
'published_at' => Carbon::now()->addDay(),
|
||||||
|
]);
|
||||||
|
$noPublishedDateMod = ModVersion::factory()->create([
|
||||||
|
'published_at' => null,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$mods = ModVersion::all();
|
||||||
|
|
||||||
|
expect($mods)->toHaveCount(2);
|
||||||
|
expect($mods->contains($publishedMod))->toBeTrue();
|
||||||
|
expect($mods->contains($unpublishedMod))->toBeFalse();
|
||||||
|
expect($mods->contains($noPublishedDateMod))->toBeTrue();
|
||||||
|
});
|
||||||
|
|
||||||
|
it('handles null published_at as not published', function () {
|
||||||
|
$modWithNoPublishDate = ModVersion::factory()->create([
|
||||||
|
'published_at' => null,
|
||||||
|
]);
|
||||||
|
|
||||||
|
$mods = ModVersion::all();
|
||||||
|
|
||||||
|
expect($mods->contains($modWithNoPublishDate))->toBeTrue();
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user