Add seeds to data fixtures, to avoid random failures in tests

This commit is contained in:
2026-03-09 13:00:30 +00:00
committed by Boris Waaub
parent b7e8eec067
commit 0a8d650d95
16 changed files with 78 additions and 41 deletions

View File

@@ -55,6 +55,9 @@ final class RelationshipApiControllerTest extends WebTestCase
public static function personProvider(): array
{
// fix a seed to avoid random errors
mt_srand(1234588755);
self::bootKernel();
$em = self::getContainer()->get(EntityManagerInterface::class);
$personIdHavingRelation = $em->createQueryBuilder()
@@ -116,6 +119,9 @@ final class RelationshipApiControllerTest extends WebTestCase
public static function relationProvider(): array
{
// fix a seed to avoid random errors
mt_srand(1234588755);
self::bootKernel();
$em = self::getContainer()->get(EntityManagerInterface::class);
$personIdWithoutRelations = $em->createQueryBuilder()
@@ -144,6 +150,8 @@ final class RelationshipApiControllerTest extends WebTestCase
->findAll();
}
return self::$relations[\array_rand(self::$relations)];
$keys = array_keys(self::$relations);
return self::$relations[mt_rand(0, \count($keys) - 1)];
}
}