mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 23:23:51 +00:00
add address suggestion by household
This commit is contained in:
@@ -4,6 +4,7 @@ namespace Chill\PersonBundle\Tests\Controller;
|
||||
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\MainBundle\Test\PrepareClientTrait;
|
||||
use Chill\PersonBundle\Entity\Household\Household;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
@@ -29,6 +30,21 @@ class HouseholdApiControllerTest extends WebTestCase
|
||||
$this->assertResponseIsSuccessful();
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider generateHouseholdId
|
||||
*/
|
||||
public function testSuggestAddressByHousehold(int $householdId)
|
||||
{
|
||||
$client = $this->getClientAuthenticated();
|
||||
|
||||
$client->request(
|
||||
Request::METHOD_GET,
|
||||
"/api/1.0/person/address/suggest/by-household/{$householdId}.json"
|
||||
);
|
||||
|
||||
$this->assertResponseIsSuccessful();
|
||||
}
|
||||
|
||||
public function generatePersonId()
|
||||
{
|
||||
self::bootKernel();
|
||||
@@ -51,5 +67,33 @@ class HouseholdApiControllerTest extends WebTestCase
|
||||
->first()->getPerson();
|
||||
|
||||
yield [ $person->getId() ];
|
||||
}
|
||||
}
|
||||
|
||||
public function generateHouseholdId()
|
||||
{
|
||||
self::bootKernel();
|
||||
|
||||
$qb = self::$container->get(EntityManagerInterface::class)
|
||||
->createQueryBuilder();
|
||||
|
||||
$householdIds = $qb
|
||||
->select('DISTINCT household.id')
|
||||
->from(Household::class, 'household')
|
||||
->join('household.members', 'members')
|
||||
->join('members.person', 'person')
|
||||
->join('person.center', 'center')
|
||||
->where($qb->expr()->eq('center.name', ':center_name'))
|
||||
->andWhere($qb->expr()->gt('SIZE(person.accompanyingPeriodParticipations)', 0))
|
||||
->setParameter('center_name', 'Center A')
|
||||
->setMaxResults(100)
|
||||
->getQuery()
|
||||
->getResult()
|
||||
;
|
||||
|
||||
\shuffle($householdIds);
|
||||
|
||||
yield [ \array_pop($householdIds)['id'] ];
|
||||
yield [ \array_pop($householdIds)['id'] ];
|
||||
yield [ \array_pop($householdIds)['id'] ];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user