diff --git a/sources/AppBundle/Event/Form/TicketType.php b/sources/AppBundle/Event/Form/TicketType.php index 905f5962a..f4c4e0883 100644 --- a/sources/AppBundle/Event/Form/TicketType.php +++ b/sources/AppBundle/Event/Form/TicketType.php @@ -26,6 +26,7 @@ use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvents; use Symfony\Component\OptionsResolver\OptionsResolver; +use Symfony\Component\Validator\Constraints\Email; class TicketType extends AbstractType { @@ -70,6 +71,9 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ]) ->add('email', EmailType::class, [ 'label' => 'Email', + 'constraints' => [ + new Email(), + ], ]) ->add('phoneNumber', TextType::class, [ 'label' => 'Téléphone', diff --git a/sources/AppBundle/Event/Model/Ticket.php b/sources/AppBundle/Event/Model/Ticket.php index 67d06092c..804f39285 100644 --- a/sources/AppBundle/Event/Model/Ticket.php +++ b/sources/AppBundle/Event/Model/Ticket.php @@ -8,6 +8,7 @@ use AppBundle\Event\Validator\Constraints as Assert; use CCMBenchmark\Ting\Entity\NotifyProperty; use CCMBenchmark\Ting\Entity\NotifyPropertyInterface; +use Symfony\Component\Validator\Constraints\Email; #[Assert\LoggedInMember(groups: ['personal'])] #[Assert\PublicTicket(groups: ['not_logged_in'])] @@ -134,6 +135,7 @@ class Ticket implements NotifyPropertyInterface /** * @var string */ + #[Email] private $email; /** diff --git a/tests/behat/features/EventPages/Ticketing.feature b/tests/behat/features/EventPages/Ticketing.feature index fe28a58c0..e9e74dc8e 100644 --- a/tests/behat/features/EventPages/Ticketing.feature +++ b/tests/behat/features/EventPages/Ticketing.feature @@ -95,3 +95,23 @@ Feature: Event pages - Ticketing When I press "Confirmer & Payer" Then I should see "Paiement de vos billets" And I should see "Vous serez redirigé vers notre partenaire paybox afin de procéder au paiement d'un montant de 15€" + + @reloadDbWithTestData + Scenario: Refus des emails sans TLD lors de l'achat de billets + Given I am on "/event/forum/tickets" + Then I should see "Billetterie: forum" + And I select "0" from "purchase[paymentType]" + When I fill in "purchase[tickets][0][firstname]" with "Prénom personne 1" + And I fill in "purchase[tickets][0][lastname]" with "Nom personne 1" + # Email de billet sans extension de domaine (pas de TLD) + And I fill in "purchase[tickets][0][email]" with "personne1@hostname" + And I fill in "purchase[firstname]" with "Prénom facturation" + And I fill in "purchase[lastname]" with "Nom facturation" + And I fill in "purchase[address]" with "42 rue de Strasbourg" + And I fill in "purchase[zipcode]" with "75003" + And I fill in "purchase[city]" with "PARIS" + And I fill in "purchase[email]" with "facturationEntreprise@yahoo.fr" + And I check "purchase[cgv]" + When I press "Confirmer & Payer" + Then I should see "Cette valeur n'est pas une adresse email valide." + And I should not see "Paiement de vos billets"