Skip to content

Commit

Permalink
feat (afup#1110): functional test
Browse files Browse the repository at this point in the history
Billeterie :
- Retour CB Paybox
- Achat billet virement
- Achat billet tarif membre
  • Loading branch information
stakovicz committed Nov 6, 2023
1 parent ea2fc17 commit 16647b2
Show file tree
Hide file tree
Showing 10 changed files with 124 additions and 12 deletions.
2 changes: 1 addition & 1 deletion app/Resources/translations/messages.en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ Language: Language
'Recevoir le dossier': 'Get it'
'Page précédente': 'Previous page'
'Page suivante': 'Next page'
Billetterie: Ticketting
Billetterie: Ticketing
'Vous êtes connecté avec un compte AFUP d''entreprise. Pour acheter des places au tarif AFUP, celles-ci doivent être enregistrées pour les membres de votre adhésion.': 'You are connected with an enterprise membership account. You can only buy tickets for the accounts of your memberships.'
'Vous êtes connecté avec un compte AFUP personnel. Vous pouvez acheter une place au tarif membre pour vous seul.': 'You are connected with a personnal account. You can buy one member ticket for yourself.'
'Attention votre cotisation ne sera plus valable le jour de l''évènement. Vous pouvez commander des billets au tarif AFUP mais vous devrez renouveler votre cotisation pour pouvoir accéder à l''évènement.': 'Please take care of your membership. It won''t be valid at the date of the event. You can order members tickets but you will have to pay your membership fee before the event.'
Expand Down
3 changes: 2 additions & 1 deletion db/seeds/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ public function run()
'fr' => 'François le français',
'en' => 'Henri l\'anglais',
'sponsor_management_fr' => '**Sponsors**, venez, vous serez très visible !',
'sponsor_management_en' => '**Sponsors**, come, you will be very visible!'
'sponsor_management_en' => '**Sponsors**, come, you will be very visible!',
'mail_inscription_content' => 'Contenu email',
]),
'date_fin_appel_projet' => $now + $oneMonthInSeconds,
'date_fin_appel_conferencier' => $event - $oneMonthInSeconds * 2,
Expand Down
2 changes: 1 addition & 1 deletion db/seeds/EventTarif.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function run()
[
'id_tarif' => 3,
'id_event' => Event::ID_FORUM,
'price' => 150,
'price' => 15,
'date_start' => '2010-01-01 10:00:00',
'date_end' => '2099-12-31 23:59:59',
],
Expand Down
29 changes: 29 additions & 0 deletions features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;
use Behat\Mink\Exception\ExpectationException;
use Behat\MinkExtension\Context\MinkContext;
use Symfony\Component\Filesystem\Filesystem;
use Symfony\Component\Process\Process;
Expand Down Expand Up @@ -107,6 +108,34 @@ public function iAmLoggedInWithTheUserAndThePassword($user, $password)
$this->minkContext->assertPageContainsText("Espace membre");
}

/**
* @Then I submit the form with name :formName
*/
public function submitFormWithName($formName)
{
$form = $this->minkContext->getSession()->getPage()->find('xpath', "//form[@name='$formName']");

if (null === $form) {
throw new ExpectationException(sprintf('The form named "%s" not found', $formName), null);
}

$form->submit();
}

/**
* @Then simulate the Paybox callback
*/
public function simulateThePayboxCallback()
{
$url = $this->minkContext->getSession()->getCurrentUrl();
$url = str_replace('paybox-redirect', 'paybox-callback', $url);

$curl = curl_init($url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_exec($curl);
}

/**
* @Then The :field field should only contain the follow values :expectedValuesJson
*/
Expand Down
9 changes: 9 additions & 0 deletions htdocs/css/buttons.css
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,12 @@ input[type="submit"].button--call-to-action {
font-weight: bold;
color: #fff;
}

button[type="submit"].button--call-to-action.paiement {
background-color: #ed0678 !important;
border-color: #ed0678 !important;
font-weight: bold !important;
color: #fff !important;
height: auto !important;
}

2 changes: 1 addition & 1 deletion sources/AppBundle/Payment/Paybox.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public function generate(\DateTimeInterface $now)
foreach ($sanitizedInputs as $inputKey => $inputValue) {
$htmlForm .= ' <input type="hidden" name="' . $inputKey . '" value="' . $inputValue . '">' . PHP_EOL;
}
$htmlForm .= ' <INPUT TYPE=SUBMIT class="button button--call-to-action" VALUE="R&eacute;gler par carte">' . PHP_EOL;
$htmlForm .= ' <button type="submit" class="button button--call-to-action paiement">Régler par carte</button>' . PHP_EOL;
$htmlForm .= '</form>';

return $htmlForm;
Expand Down
9 changes: 6 additions & 3 deletions tests/behat/features/Admin/Events/TokensSponsors.feature
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ Feature: Administration - Évènements - Tokens Sponsors
Then I follow "Envoyer le mail de rappel"
And I should see "1 mails de relance ont été envoyés"
And I should only receive the following emails:
| to | subject |
| <testToken1@mail.com> | Toutes les informations concernant votre sponsoring du forum |
| <testToken1@mail.com> | Sponsor: enregistrez-vous pour le forum |
| to | subject |
| <testToken1@mail.com> | Toutes les informations concernant votre sponsoring du forum |
| <personneinvitee@masociete.com> | [forum] Merci ! |
| <personneinvitee@masociete.com> | [forum] Merci ! |
| <testToken1@mail.com> | Sponsor: enregistrez-vous pour le forum |

72 changes: 71 additions & 1 deletion tests/behat/features/EventPages/Ticketing.feature
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
Feature: Event pages - Ticketing

@reloadDbWithTestData
Scenario: On voit bien toute la page, même le footer
@clearEmails
Scenario: Achat de billet CB
Given I am on "/event/forum/tickets"
Then I should see "Billetterie: forum"
And I should see "Si vous rencontrez le moindre problème, n'hésitez pas à nous contacter à l'adresse bonjour [@] afup.org."
# Choix du règlement par CB
And I select "0" from "purchase[paymentType]"
Then The "purchase[tickets][0][civility]" field should only contain the follow values '["M.", "Mme"]'
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"
Expand All @@ -16,8 +19,75 @@ Feature: Event pages - Ticketing
And I fill in "purchase[city]" with "PARIS"
And I fill in "purchase[email]" with "facturationEntreprise@yahoo.fr"
And I check "purchase[cgv]"
# Formule Deuxième journée
And I select "2" from "purchase[tickets][0][ticketEventType]"
And I press "Confirmer & Payer"
Then I should see "Paiement de vos billets"
And I should see "Nous avons bien reçu votre inscription et nous vous en remercions !"
And I should see "Vous serez redirigé vers notre partenaire paybox afin de procéder au paiement d'un montant de 250€"
# Bascule vers Paybox
When I press "Régler par carte"
# Pour suivre la redirection POST de Paybox
And I submit the form with name "PAYBOX"
When I fill in "NUMERO_CARTE" with "1111222233334444"
And I select "12" from "MOIS_VALIDITE"
And I select "25" from "AN_VALIDITE"
And I fill in "CVVX" with "123"
And I press "Valider"
Then I should see "PAIEMENT ACCEPTÉ"
When I follow "Retour"
Then I should see "Le paiement de votre commande s'est bien passé, merci."
# Simuler l'appel de callback Paybox
And simulate the Paybox callback
And I should only receive the following emails:
| to | subject |
| <facturationEntreprise@yahoo.fr>,<tresorier@afup.org> | Facture évènement AFUP |
| <personne1@yahoo.fr> | [forum] Merci ! |

@reloadDbWithTestData
Scenario: Achat de billet virement
Given I am on "/event/forum/tickets"
Then I should see "Billetterie: forum"
And I should see "Si vous rencontrez le moindre problème, n'hésitez pas à nous contacter à l'adresse bonjour [@] afup.org."
# Choix du règlement par virement
And I select "2" from "purchase[paymentType]"
Then The "purchase[tickets][0][civility]" field should only contain the follow values '["M.", "Mme"]'
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"
And I fill in "purchase[tickets][0][email]" with "personne1@yahoo.fr"
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]"
# Formule Deuxième journée
And I select "2" from "purchase[tickets][0][ticketEventType]"
When I press "Confirmer & Payer"
Then I should see "Paiement de vos billets"
And I should see "Nous avons bien reçu votre inscription et nous vous en remercions !"
And I should see "Pour les paiements par virement, merci d'envoyer le virement d'un montant de 250€ aux coordonnées suivantes :"
And I should see "Pensez à indiquer dans le libellé du virement la référence suivante:"

@reloadDbWithTestData
Scenario: Achat de billet tarif membre
Given I am logged-in with the user "paul" and the password "paul"
And I am on "/event/forum/tickets"
Then I should see "Billetterie: forum"
# Formule Tarif membre
And I select "0" from "purchase[tickets][0][ticketEventType]"
Then The "purchase[tickets][0][civility]" field should only contain the follow values '["M.", "Mme"]'
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"
And I fill in "purchase[tickets][0][email]" with "paul.personne@mycorp.fr"
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 "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€"
4 changes: 2 additions & 2 deletions tests/behat/features/EventPages/TicketingEn.feature
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Feature: Event pages - Ticketing - en anglais

@reloadDbWithTestData
Scenario: On voit bien toute la page, même le footer
Scenario: Achat de billet en anglais
Given I am on "/event/forum/tickets?_locale=en"
Then I should see "Ticketting: forum"
Then I should see "Ticketing: forum"
Then The "purchase[tickets][0][civility]" field should only contain the follow values '["M.", "Mrs."]'
4 changes: 2 additions & 2 deletions tests/units/AppBundle/Payment/Paybox.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ protected function generateDateProvider()
<input type="hidden" name="PBX_TYPEPAIEMENT" value="CARTE">
<input type="hidden" name="PBX_TYPECARTE" value="CB">
<input type="hidden" name="PBX_HMAC" value="39EE89FB543A226318139335D24074868FA5912418045813F225572BD1FE069AC88C6B70D0BA1B84B2A974F0D22572D2FFFA3D309E2F2192CEF12E44931CA88C">
<INPUT TYPE=SUBMIT class="button button--call-to-action" VALUE="R&eacute;gler par carte">
<button type="submit" class="button button--call-to-action paiement">Régler par carte</button>
</form>
EOF;

Expand All @@ -65,7 +65,7 @@ protected function generateDateProvider()
<input type="hidden" name="PBX_TYPECARTE" value="CB">
<input type="hidden" name="PBX_REPONDRE_A" value="http://reponseA">
<input type="hidden" name="PBX_HMAC" value="8E5F8C3C052D64606288F3C55C502153CA1D424F7C25CAD4057100897F95E481F155DBD349495FD4C327F5389BA6C98C3DB43A3CF5394378F4276EB53A1C0245">
<INPUT TYPE=SUBMIT class="button button--call-to-action" VALUE="R&eacute;gler par carte">
<button type="submit" class="button button--call-to-action paiement">Régler par carte</button>
</form>
EOF;

Expand Down

0 comments on commit 16647b2

Please sign in to comment.