152 - Give factories unique values for constrained columns

This commit is contained in:
myrmidex 2026-08-15 10:07:40 +02:00
parent de42bdca38
commit e58badf70e
4 changed files with 7 additions and 5 deletions

View file

@ -17,7 +17,7 @@ public function definition(): array
{
return [
'name' => $this->faker->words(3, true),
'url' => $this->faker->url(),
'url' => $this->faker->unique()->url(),
'type' => $this->faker->randomElement(['website', 'rss']),
'provider' => $this->faker->randomElement(['vrt', 'belga']),
'language_id' => null,

View file

@ -15,7 +15,9 @@ class LanguageFactory extends Factory
public function definition(): array
{
return [
'short_code' => $this->faker->unique()->languageCode(),
// Not a real language code: tests hardcode 'en', 'fr', 'nl' and
// others, and faker's pool would collide with them.
'short_code' => 'x-'.$this->faker->unique()->numerify('####'),
'name' => $this->faker->unique()->word(),
'native_name' => $this->faker->optional()->word(),
'is_active' => true,

View file

@ -19,7 +19,7 @@ public function definition(): array
return [
'platform' => PlatformEnum::LEMMY,
'instance_url' => 'https://lemmy.'.$this->faker->domainName(),
'username' => $this->faker->userName(),
'username' => $this->faker->unique()->userName(),
'password' => 'test-password',
'settings' => [],
'is_active' => true,

View file

@ -17,7 +17,7 @@ public function definition(): array
return [
'platform' => 'lemmy',
'name' => $this->faker->words(2, true),
'url' => $this->faker->url(),
'url' => $this->faker->unique()->url(),
'is_active' => true,
];
}
@ -34,7 +34,7 @@ public function lemmy(): static
return $this->state(fn (array $attributes) => [
'platform' => 'lemmy',
'name' => 'Lemmy '.$this->faker->word(),
'url' => 'https://lemmy.'.$this->faker->domainName(),
'url' => 'https://lemmy.'.$this->faker->unique()->domainName(),
]);
}
}