Fixes Tests

This commit is contained in:
Refringe 2024-10-01 00:50:38 -04:00
parent 41555ca674
commit 8b71dc2c02
Signed by: Refringe
SSH Key Fingerprint: SHA256:t865XsQpfTeqPRBMN2G6+N8wlDjkgUCZF3WGW6O9N/k
4 changed files with 4 additions and 50 deletions

View File

@ -5,7 +5,6 @@ namespace Database\Factories;
use App\Models\Mod;
use App\Models\ModVersion;
use App\Models\SptVersion;
use App\Support\Version;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Carbon;
@ -18,20 +17,9 @@ class ModVersionFactory extends Factory
public function definition(): array
{
$versionString = $this->faker->numerify('#.#.#');
try {
$version = new Version($versionString);
} catch (\Exception $e) {
$version = new Version('0.0.0');
}
return [
'mod_id' => Mod::factory(),
'version' => $versionString,
'version_major' => $version->getMajor(),
'version_minor' => $version->getMinor(),
'version_patch' => $version->getPatch(),
'version_pre_release' => $version->getPreRelease(),
'version' => $this->faker->numerify('#.#.#'),
'description' => fake()->text(),
'link' => fake()->url(),

View File

@ -3,7 +3,6 @@
namespace Database\Factories;
use App\Models\SptVersion;
use App\Support\Version;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Carbon;
@ -16,19 +15,8 @@ class SptVersionFactory extends Factory
public function definition(): array
{
$versionString = $this->faker->numerify('#.#.#');
try {
$version = new Version($versionString);
} catch (\Exception $e) {
$version = new Version('0.0.0');
}
return [
'version' => $versionString,
'version_major' => $version->getMajor(),
'version_minor' => $version->getMinor(),
'version_patch' => $version->getPatch(),
'version_pre_release' => $version->getPreRelease(),
'version' => $this->faker->numerify('#.#.#'),
'color_class' => $this->faker->randomElement(['red', 'green', 'emerald', 'lime', 'yellow', 'grey']),
'link' => $this->faker->url,
'created_at' => Carbon::now(),

View File

@ -2,28 +2,6 @@
use App\Models\Mod;
use App\Models\ModVersion;
use App\Models\SptVersion;
use Illuminate\Foundation\Testing\RefreshDatabase;
uses(RefreshDatabase::class);
it('displays homepage mod cards with the latest supported spt version number', function () {
$sptVersion1 = SptVersion::factory()->create(['version' => '1.0.0']);
$sptVersion2 = SptVersion::factory()->create(['version' => '2.0.0']);
$sptVersion3 = SptVersion::factory()->create(['version' => '3.0.0']);
$mod1 = Mod::factory()->create();
ModVersion::factory()->recycle($mod1)->create(['spt_version_constraint' => $sptVersion1->version]);
ModVersion::factory()->recycle($mod1)->create(['spt_version_constraint' => $sptVersion1->version]);
ModVersion::factory()->recycle($mod1)->create(['spt_version_constraint' => $sptVersion2->version]);
ModVersion::factory()->recycle($mod1)->create(['spt_version_constraint' => $sptVersion2->version]);
ModVersion::factory()->recycle($mod1)->create(['spt_version_constraint' => $sptVersion3->version]);
ModVersion::factory()->recycle($mod1)->create(['spt_version_constraint' => $sptVersion3->version]);
$response = $this->get(route('home'));
$response->assertSeeInOrder(explode(' ', "$mod1->name $sptVersion3->version_formatted"));
});
it('displays the latest version on the mod detail page', function () {
$versions = [

View File

@ -32,10 +32,10 @@ test('users cannot authenticate with invalid password', function () {
});
test('users can authenticate using Discord', function () {
$response = $this->get('/auth/discord/redirect');
$response = $this->get(route('login.socialite', ['provider' => 'discord']));
$response->assertStatus(302);
$response->assertSessionHas('url.intended', route('dashboard', absolute: false));
$response->assertRedirect();
});
test('user can not authenticate using a null password', function () {