-
-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Rémi
authored and
Rémi
committed
Feb 27, 2025
1 parent
4931505
commit ea10960
Showing
2 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -84,6 +84,7 @@ public function load(ObjectManager $manager): void | |
// Create adherent users list | ||
$adherent1 = $this->adherentFactory->createFromArray([ | ||
'uuid' => self::ADHERENT_1_UUID, | ||
'public_id' => '123-456', | ||
'password' => self::DEFAULT_PASSWORD, | ||
'email' => '[email protected]', | ||
'gender' => 'female', | ||
|
77 changes: 77 additions & 0 deletions
77
tests/Controller/Renaissance/NationalEvent/EventInscriptionControllerTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<?php | ||
|
||
namespace Tests\App\Controller\Renaissance\NationalEvent; | ||
|
||
use App\Entity\NationalEvent\EventInscription; | ||
use App\Repository\NationalEvent\EventInscriptionRepository; | ||
use PHPUnit\Framework\Attributes\DataProvider; | ||
use PHPUnit\Framework\Attributes\Group; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Tests\App\AbstractWebTestCase; | ||
use Tests\App\Controller\ControllerTestTrait; | ||
|
||
#[Group('functional')] | ||
class EventInscriptionControllerTest extends AbstractWebTestCase | ||
{ | ||
use ControllerTestTrait; | ||
|
||
private ?EventInscriptionRepository $eventInscriptionRepository = null; | ||
|
||
#[DataProvider('provideReferrerCodes')] | ||
public function testEventInscriptionWithReferral(string $referrerCode, ?string $referrerEmail): void | ||
{ | ||
$crawler = $this->client->request(Request::METHOD_GET, "/grand-rassemblement/event-national-1/$referrerCode"); | ||
$this->assertStatusCode(Response::HTTP_OK, $this->client); | ||
|
||
$buttonCrawlerNode = $crawler->selectButton('Je réserve ma place'); | ||
|
||
$form = $buttonCrawlerNode->form(); | ||
|
||
$form['event_inscription[acceptCgu]']->tick(); | ||
$form['event_inscription[acceptMedia]']->tick(); | ||
|
||
$this->client->submit($form, [ | ||
'event_inscription' => [ | ||
'email' => '[email protected]', | ||
'civility' => 'male', | ||
'firstName' => 'John', | ||
'lastName' => 'Doe', | ||
'birthPlace' => 'Paris', | ||
'birthdate' => ['year' => '2000', 'month' => '10', 'day' => '2'], | ||
'postalCode' => '75001', | ||
], | ||
]); | ||
$this->assertClientIsRedirectedTo('/grand-rassemblement/event-national-1/confirmation', $this->client); | ||
|
||
$this->client->followRedirect(); | ||
$this->assertStatusCode(Response::HTTP_OK, $this->client); | ||
|
||
$eventInscription = $this->eventInscriptionRepository->findOneBy(['addressEmail' => '[email protected]']); | ||
$this->assertInstanceOf(EventInscription::class, $eventInscription); | ||
$this->assertEquals($referrerCode, $eventInscription->referrerCode); | ||
$this->assertEquals($referrerEmail, $eventInscription->referrer?->getEmailAddress()); | ||
} | ||
|
||
public static function provideReferrerCodes(): iterable | ||
{ | ||
yield ['123-456', '[email protected]']; | ||
yield ['invalid', null]; | ||
} | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->eventInscriptionRepository = $this->getRepository(EventInscription::class); | ||
|
||
$this->client->setServerParameter('HTTP_HOST', static::getContainer()->getParameter('user_vox_host')); | ||
} | ||
|
||
protected function tearDown(): void | ||
{ | ||
parent::tearDown(); | ||
|
||
$this->eventInscriptionRepository = null; | ||
} | ||
} |