mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
add tests for household
This commit is contained in:
parent
ff5b0bc258
commit
0158c6f2ed
@ -0,0 +1,97 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Tests\Controller;
|
||||||
|
|
||||||
|
use Chill\PersonBundle\Entity\Household\Household;
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
|
use Chill\MainBundle\Test\PrepareClientTrait;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||||
|
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
|
||||||
|
|
||||||
|
class HouseholdControllerTest extends WebTestCase
|
||||||
|
{
|
||||||
|
use PrepareClientTrait;
|
||||||
|
|
||||||
|
private ?KernelBrowser $client = null;
|
||||||
|
|
||||||
|
protected function setUp()
|
||||||
|
{
|
||||||
|
$this->client = $this->getClientAuthenticated();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider generateValidHouseholdIds
|
||||||
|
*/
|
||||||
|
public function testSummary($householdId)
|
||||||
|
{
|
||||||
|
$this->client->request(
|
||||||
|
Request::METHOD_GET,
|
||||||
|
"/fr/person/household/{$householdId}/summary"
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertResponseIsSuccessful();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider generateValidHouseholdIds
|
||||||
|
*/
|
||||||
|
public function testMembers($householdId)
|
||||||
|
{
|
||||||
|
$this->client->request(
|
||||||
|
Request::METHOD_GET,
|
||||||
|
"/fr/person/household/{$householdId}/members"
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertResponseIsSuccessful();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider generateValidHouseholdIds
|
||||||
|
*/
|
||||||
|
public function testAddresses($householdId)
|
||||||
|
{
|
||||||
|
$this->client->request(
|
||||||
|
Request::METHOD_GET,
|
||||||
|
"/fr/person/household/{$householdId}/addresses"
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertResponseIsSuccessful();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dataProvider generateValidHouseholdIds
|
||||||
|
*/
|
||||||
|
public function testAddressMove($householdId)
|
||||||
|
{
|
||||||
|
$this->client->request(
|
||||||
|
Request::METHOD_GET,
|
||||||
|
"/fr/person/household/{$householdId}/address/move"
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->assertResponseIsSuccessful();
|
||||||
|
|
||||||
|
// ici, il faudrait tester la requête POST
|
||||||
|
}
|
||||||
|
|
||||||
|
public function generateValidHouseholdIds()
|
||||||
|
{
|
||||||
|
self::bootKernel();
|
||||||
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
|
|
||||||
|
$ids = $em->createQuery("SELECT DISTINCT h.id FROM ".Household::class." h ".
|
||||||
|
"JOIN h.members m ".
|
||||||
|
"JOIN m.person p ".
|
||||||
|
"JOIN p.center c ".
|
||||||
|
"WHERE c.name = :center"
|
||||||
|
)
|
||||||
|
->setParameter('center', "Center A")
|
||||||
|
->setMaxResults(100)
|
||||||
|
->getScalarResult()
|
||||||
|
;
|
||||||
|
|
||||||
|
\shuffle($ids);
|
||||||
|
|
||||||
|
yield [ \array_pop($ids)['id'] ];
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user