mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 13:24:25 +00:00
add test for Member edition + fix path
This commit is contained in:
parent
2384281532
commit
4dc82bc207
@ -62,7 +62,7 @@ class HouseholdMemberController extends ApiController
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @Route(
|
* @Route(
|
||||||
* "/api/1.0/person/household/member/{id}/edit",
|
* "/{_locale}/person/household/member/{id}/edit",
|
||||||
* name="chill_person_household_member_edit"
|
* name="chill_person_household_member_edit"
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
|
@ -8,6 +8,7 @@ use Chill\MainBundle\Test\PrepareClientTrait;
|
|||||||
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
||||||
use Chill\PersonBundle\Entity\Person;
|
use Chill\PersonBundle\Entity\Person;
|
||||||
use Chill\PersonBundle\Entity\Household\Household;
|
use Chill\PersonBundle\Entity\Household\Household;
|
||||||
|
use Chill\PersonBundle\Entity\Household\HouseholdMember;
|
||||||
use Chill\PersonBundle\Entity\Household\Position;
|
use Chill\PersonBundle\Entity\Household\Position;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
|
||||||
@ -17,7 +18,7 @@ class HouseholdMemberControllerTest extends WebTestCase
|
|||||||
use PrepareClientTrait;
|
use PrepareClientTrait;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider provideValidData
|
* @dataProvider provideValidDataMove
|
||||||
*/
|
*/
|
||||||
public function testMoveMember($personId, $householdId, $positionId, \DateTimeInterface $date)
|
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();
|
self::bootKernel();
|
||||||
$em = self::$container->get(EntityManagerInterface::class);
|
$em = self::$container->get(EntityManagerInterface::class);
|
||||||
@ -95,4 +120,22 @@ class HouseholdMemberControllerTest extends WebTestCase
|
|||||||
new \DateTimeImmutable('today')
|
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'] ];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user