mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 07:03:49 +00:00
add test for Member edition + fix path
This commit is contained in:
@@ -8,6 +8,7 @@ use Chill\MainBundle\Test\PrepareClientTrait;
|
||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Chill\PersonBundle\Entity\Household\Household;
|
||||
use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
||||
use Chill\PersonBundle\Entity\Household\Position;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
@@ -17,7 +18,7 @@ class HouseholdMemberControllerTest extends WebTestCase
|
||||
use PrepareClientTrait;
|
||||
|
||||
/**
|
||||
* @dataProvider provideValidData
|
||||
* @dataProvider provideValidDataMove
|
||||
*/
|
||||
public function testMoveMember($personId, $householdId, $positionId, \DateTimeInterface $date)
|
||||
{
|
||||
@@ -66,7 +67,31 @@ class HouseholdMemberControllerTest extends WebTestCase
|
||||
);
|
||||
}
|
||||
|
||||
public function provideValidData(): \Iterator
|
||||
/**
|
||||
* @dataProvider provideValidDataEditMember
|
||||
*/
|
||||
public function testEditMember($memberId)
|
||||
{
|
||||
$client = $this->getClientAuthenticated();
|
||||
|
||||
$crawler = $client->request(
|
||||
Request::METHOD_GET,
|
||||
"/fr/person/household/member/{$memberId}/edit"
|
||||
);
|
||||
|
||||
$this->assertResponseIsSuccessful();
|
||||
|
||||
$form = $crawler->selectButton('Enregistrer')
|
||||
->form();
|
||||
$form['household_member[endDate]'] = (new \DateTime('tomorrow'))
|
||||
->format('d-m-Y');
|
||||
|
||||
$crawler = $client->submit($form);
|
||||
|
||||
$this->assertEquals(302, $client->getResponse()->getStatusCode());
|
||||
}
|
||||
|
||||
public function provideValidDataMove(): \Iterator
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
@@ -95,4 +120,22 @@ class HouseholdMemberControllerTest extends WebTestCase
|
||||
new \DateTimeImmutable('today')
|
||||
];
|
||||
}
|
||||
|
||||
public function provideValidDataEditMember(): \Iterator
|
||||
{
|
||||
self::bootKernel();
|
||||
$em = self::$container->get(EntityManagerInterface::class);
|
||||
|
||||
$membershipIds = $em->createQuery("SELECT m.id FROM ".HouseholdMember::class." m ".
|
||||
"JOIN m.person p ".
|
||||
"JOIN p.center c ".
|
||||
"WHERE c.name = :center AND m.endDate IS NULL")
|
||||
->setParameter('center', 'Center A')
|
||||
->getScalarResult()
|
||||
;
|
||||
|
||||
\shuffle($membershipIds);
|
||||
|
||||
yield [ \array_pop($membershipIds)['id'] ];
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user