Skip to content

Commit

Permalink
feat (#1110): functional test
Browse files Browse the repository at this point in the history
Espace membre:
- Présence AG
- Saisie infos fiche entreprise publique

feat (#1110): functional test
Planete PHP

feat (#1110): functional test
AG

feat (#1110): functional test
Achat de billet CB + virement + tarif membre
  • Loading branch information
stakovicz committed Nov 5, 2023
1 parent 3d6e03f commit 2979f98
Show file tree
Hide file tree
Showing 25 changed files with 294 additions and 29 deletions.
7 changes: 4 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,11 @@ test:


test-functional: data config htdocs/uploads
CURRENT_UID=$(CURRENT_UID) docker-compose stop dbtest apachephptest mailcatcher
CURRENT_UID=$(CURRENT_UID) docker-compose up -d dbtest apachephptest mailcatcher
CURRENT_UID=$(CURRENT_UID) docker-compose stop dbtest apachephptest planetetest mailcatcher
CURRENT_UID=$(CURRENT_UID) docker-compose up -d dbtest apachephptest planetetest mailcatcher
CURRENT_UID=$(CURRENT_UID) docker-compose run --no-deps --rm cliphp ./bin/behat
CURRENT_UID=$(CURRENT_UID) docker-compose stop dbtest apachephptest mailcatcher
CURRENT_UID=$(CURRENT_UID) docker-compose run --no-deps --rm cliphp ./bin/behat -c behat-planete.yml
CURRENT_UID=$(CURRENT_UID) docker-compose stop dbtest apachephptest planetetest mailcatcher

data:
mkdir data
Expand Down
10 changes: 7 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,16 @@ Lancement des tests unitaires :
```
- Une alternative est d'utiliser la commande `make test` qui effectuer la même action.

Lancement des tests unitaires :
Lancement des tests fonctionnels :
- Se connecter dans le conteneur php `docker/bin/bash`
- Lancer les tests :
- Lancer les tests pour le site web :
```
./bin/behat
```
- Lancer les tests pour le site Planete PHP :
```
./bin/behat -c behat-planete.yml
```
- Une alternative est d'utiliser la commande `make test-functional`, attention cette commande arrête les containeurs de tests à la fin de l'exécution de la suite de test. Si par la suite vous souhaitez lancer un test, il faut bien penser à les allumer de nouveau.

Dans chacun des cas, il est possible de spécifier un test dans la ligne de commande. Exemple: `./bin/behat tests/behat/features/Admin/AdminFeuilles.feature`
Expand All @@ -84,7 +88,7 @@ Il est possible de tester les paiements Paybox en environnement de développemen
Pour cela, les identifiant, site et rang [de test](https://www.paybox.com/espace-integrateur-documentation/comptes-de-tests/) sont déjà configurés dans le fichier parameters.yml par défaut.

Ensuite pour le paiement il faut utiliser ces informations [de carte](https://www.paybox.com/espace-integrateur-documentation/cartes-de-tests/) (celle _"Carte participant au programme 3-D Secure (enrôlée)"_) :
* Numéro de carte : `1111 2222 3333 4444`
* Numéro de carte : `1111222233334444`
* Validité : `12/25`
* CVV : `123`

Expand Down
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 app/Resources/views/site/member/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
</a>
<span class="member-index-item--title">Mes coordonnées</span> : {{ user.label }}
<div class="member-index-item--link">
<a class="button-inverted button__medium" href="{{ href }}">Modifier</a>
<a class="button-inverted button__medium" href="{{ href }}"
title="Modifier les coordonnées">Modifier</a>
</div>
<div class="member-index-item--description">
Modifiez votre adresse de facturation et votre adresse email, changez votre mot de passe
Expand Down
16 changes: 16 additions & 0 deletions behat-planete.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
default:
suites:
features:
paths:
- %paths.base%/planete/tests
contexts:
- FeatureContext
- Behat\MinkExtension\Context\MinkContext
extensions:
Behat\MinkExtension:
base_url: 'https://planetetest:80'
sessions:
default:
goutte:
guzzle_parameters:
verify: false
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
24 changes: 23 additions & 1 deletion db/seeds/FeedArticle.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function run()

$data = [
[
'afup_planete_flux_id' => 2,
'afup_planete_flux_id' => 1,
'clef' => '0482a33e-7370-11ee-b962-0242ac120002',
'titre' => 'Un titre',
'url' => 'https://afup.org/url.html',
Expand All @@ -31,6 +31,28 @@ public function run()
'contenu' => 'Le contenu du super article',
'etat' => 1
],
[
'afup_planete_flux_id' => 1,
'clef' => '460d0a22-78bd-11ee-b962-0242ac120002',
'titre' => 'Un 2e titre',
'url' => 'https://afup.org/url-2.html',
'maj' => time(),
'auteur' => 'Toujours un super auteur',
'resume' => 'Un article qui déchire',
'contenu' => 'Le contenu de l\'article qui déchire',
'etat' => 1
],
[
'afup_planete_flux_id' => 1,
'clef' => '4d5cf2e2-78bd-11ee-b962-0242ac120002',
'titre' => 'Un titre désactivé',
'url' => 'https://afup.org/url-out.html',
'maj' => time(),
'auteur' => 'Un super désactivé',
'resume' => 'Un super désactivé',
'contenu' => 'Le contenu du super désactivé',
'etat' => 0
],
];

$table = $this->table('afup_planete_billet');
Expand Down
15 changes: 13 additions & 2 deletions db/seeds/GeneralMeetings.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ class GeneralMeetings extends AbstractSeed
{
public function run()
{
$timestamp = strtotime(date("Y-m-d") . "+2 months");

// Assemblées générales
$data = [
[
'date' => 1635544800,
'description' => 'Assemblée octobre 2021'
],
[
'date' => $timestamp,
'description' => 'Assemblée dans 2 mois'
],
];

$table = $this->table('afup_assemblee_generale');
Expand All @@ -28,6 +34,11 @@ public function run()
'date' => 1635544800,
'presence' => 1
],
[
'id_personne_physique' => '1',
'date' => $timestamp,
'presence' => 1
],
];

$table = $this->table('afup_presences_assemblee_generale');
Expand All @@ -41,12 +52,12 @@ public function run()
// Assemblées générales Questions
$data = [
[
'date' => 1635544800,
'date' => $timestamp,
'label' => 'Une 1ère question. Alors d\'accord ?',
'created_at' => '2021-09-01 10:42:42'
],
[
'date' => 1635544800,
'date' => $timestamp,
'label' => 'Une autre question pertinente. On vote ?',
'created_at' => '2021-09-12 10:42:42'
],
Expand Down
21 changes: 21 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,26 @@ services:
- db
- mailcatcher

planetetest:
build:
context: ./docker/dockerfiles/planete
args:
uid: ${CURRENT_UID:-1001}
gid: "1001"
ENABLE_XDEBUG: ${ENABLE_XDEBUG:-false}
environment:
SYMFONY_ENV: "test"
volumes:
- ./:/var/www/html
healthcheck:
test: ["CMD", "curl", "-f", "https://planetetest:80"]
interval: 30s
timeout: 10s
retries: 5
depends_on:
dbtest:
condition: service_healthy

cliphp:
build:
context: ./docker/dockerfiles/apachephp
Expand All @@ -104,6 +124,7 @@ services:
- apachephp
- mailcatcher
- apachephptest
- planetetest
- dbtest
command: "false"

Expand Down
30 changes: 30 additions & 0 deletions features/bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,14 @@
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;
use AppBundle\Event\Model\Event;

use function GuzzleHttp\Psr7\parse_query;

class FeatureContext implements Context
{
const MAILCATCHER_URL = 'http://mailcatcher:1080';
Expand Down Expand Up @@ -107,6 +110,33 @@ 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;
}

11 changes: 8 additions & 3 deletions htdocs/pages/planete/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
}

$isDevEnv = isset($_ENV['SYMFONY_ENV']) && $_ENV['SYMFONY_ENV'] == 'dev';
$isTestEnv = isset($_ENV['SYMFONY_ENV']) && $_ENV['SYMFONY_ENV'] == 'test';

if ($_SERVER['HTTP_HOST'] === 'afup.dev' || $isDevEnv) {
if (!$isDevEnv
if ($_SERVER['HTTP_HOST'] === 'afup.dev' || $isDevEnv || $isTestEnv) {
if (!($isDevEnv || $isTestEnv)
&&
(
isset($_SERVER['HTTP_CLIENT_IP'])
Expand All @@ -33,7 +34,11 @@
$loader = require __DIR__.'/../../../vendor/autoload.php';
Debug::enable();

$kernel = new PlaneteAppKernel('dev', true);
if ($isDevEnv) {
$kernel = new PlaneteAppKernel('dev', true);
} else {
$kernel = new PlaneteAppKernel('test', true);
}
} else {
/** @var ClassLoader $loader */
$loader = require __DIR__.'/../../../vendor/autoload.php';
Expand Down
8 changes: 6 additions & 2 deletions planete/app/config/config_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,9 @@ web_profiler:
toolbar: false
intercept_redirects: false

swiftmailer:
disable_delivery: true
parameters:
database_host: dbtest
database_port: 3306
database_name: web
database_user: afup
database_password: afup
11 changes: 11 additions & 0 deletions planete/tests/features/Home.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Feature: Planete PHP - Home

@reloadDbWithTestData
Scenario: On voit bien toute la page
Given I am on the homepage
Then I should see "planete-php.fr"
Then I should see "Un titre"
Then I should see "Un 2e titre"
Then I should see "Envoyez un email avec l'URL du site et du flux à planetephpfr AT afup POINT org"
When I follow "Articles précédents"
Then I should see "Articles précédents Articles suivants"
10 changes: 10 additions & 0 deletions planete/tests/features/Rss.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Feature: Planete PHP - RSS

@reloadDbWithTestData
Scenario: On accède bien au flux RSS
Given I am on the homepage
When I follow "RSS Feed"
Then the response should contain "<title>planete php fr</title>"
Then the response should contain "<title>Un titre</title>"
Then the response should contain "<title>Un 2e titre</title>"
Then the response should contain "</rss>"
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: 8 additions & 1 deletion tests/behat/features/Admin/Events/GestionEvenements.feature
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,14 @@ Feature: Administration - Évènements - Gestions Évènements
And I should see "03/03/2027"
And I should see "06/03/2027"

Scenario: Si on tente d'en envoyer un mail de test sans contenu, on a un message d'erreur
@reloadDbWithTestData
@clearEmails
Scenario: Si on tente d'en envoyer un mail de test sans contenu, on a un message d'erreur
Given I am logged in as admin and on the Administration
When I go to "/pages/administration/index.php?page=forum_gestion&action=modifier&id=1"
And I fill in "mail_inscription_content" with ""
And I press "Soumettre"
When I go to "/pages/administration/index.php?page=forum_gestion&action=modifier&id=1"
Then I should see "Modifier un évènement"
When I follow "Envoyer un test du mail d'inscription sur [email protected]"
Then I should see "Contenu du mail d'inscription non trouvé pour le forum forum"
Expand All @@ -128,6 +133,8 @@ Feature: Administration - Évènements - Gestions Évènements
And I press "Soumettre"
Then I should see "Le forum a été modifié"

@reloadDbWithTestData
@clearEmails
Scenario: Si on tente d'en envoyer un mail de test avec contenu, le mail est bien envoyé
Given I am logged in as admin and on the Administration
When I go to "/pages/administration/index.php?page=forum_gestion&action=modifier&id=1"
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 |

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ Feature: Administration - Partie Assemblée Générale Questions
And I follow "Assemblée générale - votes"
When I follow "Ajouter"
Then the ".content h2" element should contain "Assemblée générale - questions"
Then I should see "Assemblée générale du 30/10/2021"
And I fill in "general_meeting_question_form[label]" with "Une super question"
And I press "Ajouter cette question"
Then I should see "La question a été ajoutée"
Expand Down
Loading

0 comments on commit 2979f98

Please sign in to comment.