This commit is contained in:
2025-06-20 17:31:13 +02:00
parent 9158e33854
commit a38116cca4
65 changed files with 2298 additions and 2298 deletions

View File

@@ -40,6 +40,19 @@ final class RelationshipApiControllerTest extends WebTestCase
self::ensureKernelShutdown();
}
/**
* @dataProvider personProvider
*/
public function testGetRelationshipByPerson(int $personId)
{
self::ensureKernelShutdown();
$client = $this->getClientAuthenticated();
$client->request(Request::METHOD_GET, sprintf('/api/1.0/relations/relationship/by-person/%d.json', $personId));
$response = $client->getResponse();
$this->assertEquals(200, $response->getStatusCode(), 'Test to see that API response returns a status code 200');
}
public static function personProvider(): array
{
self::bootKernel();
@@ -75,42 +88,6 @@ final class RelationshipApiControllerTest extends WebTestCase
];
}
public static function relationProvider(): array
{
self::bootKernel();
$em = self::getContainer()->get(EntityManagerInterface::class);
$personIdWithoutRelations = $em->createQueryBuilder()
->select('p.id')
->from(Person::class, 'p')
->join('p.centerCurrent', 'center_current')
->join('center_current.center', 'c')
->where('c.name LIKE :name')
->andWhere('NOT EXISTS (SELECT 1 FROM '.Relationship::class.' r WHERE r.fromPerson = p OR r.toPerson = p)')
->setParameter('name', 'Center A')
->getQuery()
->setMaxResults(2)
->getResult();
self::ensureKernelShutdown();
return [
[$personIdWithoutRelations[0]['id'], $personIdWithoutRelations[1]['id'], self::getRandomRelation($em)->getId(), true],
];
}
/**
* @dataProvider personProvider
*/
public function testGetRelationshipByPerson(int $personId)
{
self::ensureKernelShutdown();
$client = $this->getClientAuthenticated();
$client->request(Request::METHOD_GET, sprintf('/api/1.0/relations/relationship/by-person/%d.json', $personId));
$response = $client->getResponse();
$this->assertEquals(200, $response->getStatusCode(), 'Test to see that API response returns a status code 200');
}
/**
* @dataProvider relationProvider
*/
@@ -137,6 +114,29 @@ final class RelationshipApiControllerTest extends WebTestCase
$this->assertEquals(200, $response->getStatusCode());
}
public static function relationProvider(): array
{
self::bootKernel();
$em = self::getContainer()->get(EntityManagerInterface::class);
$personIdWithoutRelations = $em->createQueryBuilder()
->select('p.id')
->from(Person::class, 'p')
->join('p.centerCurrent', 'center_current')
->join('center_current.center', 'c')
->where('c.name LIKE :name')
->andWhere('NOT EXISTS (SELECT 1 FROM '.Relationship::class.' r WHERE r.fromPerson = p OR r.toPerson = p)')
->setParameter('name', 'Center A')
->getQuery()
->setMaxResults(2)
->getResult();
self::ensureKernelShutdown();
return [
[$personIdWithoutRelations[0]['id'], $personIdWithoutRelations[1]['id'], self::getRandomRelation($em)->getId(), true],
];
}
private static function getRandomRelation(EntityManagerInterface $em): Relation
{
if (null === self::$relations) {