Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat 1110 functional tests #1334

Merged
merged 4 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 3 additions & 3 deletions app/Resources/views/event/speaker/page.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@
{{ form_errors(speakers_contact_form.phone_number) }}
</span>
<span>
{{ form_widget(speakers_contact_form.submit) }}
{{ form_widget(speakers_contact_form.submit, {attr: {title: "Enregistrer le contact"}}) }}
</span>
</div>

Expand Down Expand Up @@ -150,7 +150,7 @@
</div>

<div class="submit-container">
{{ form_widget(speakers_diner_form.submit) }}
{{ form_widget(speakers_diner_form.submit, {attr: {title: "Enregistrer mes préférences pour le restaurant"}}) }}
</div>

{{ form_end(speakers_diner_form) }}
Expand Down Expand Up @@ -196,7 +196,7 @@
</div>

<div class="submit-container">
{{ form_widget(hotel_reservation_form.submit) }}
{{ form_widget(hotel_reservation_form.submit, {attr: {title: "Enregistrer les nuitées"}}) }}
</div>

{{ form_end(hotel_reservation_form) }}
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
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;
}

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:
stakovicz marked this conversation as resolved.
Show resolved Hide resolved
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: 9 additions & 0 deletions sources/AppBundle/Security/TestGithubAuthenticator.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,15 @@ private function getTestUsersDetails()
'avatar_url' => 'http://test2.com',
];

$testUsers['agallou'] = [
'id' => 320372,
'name' => 'agallou',
'login' => 'agallou',
'company' => 'AFUP',
'html_url' => 'http://test2.com',
'avatar_url' => 'http://test2.com',
];

return $testUsers;
}

Expand Down
Loading
Loading