Skip to content

Commit

Permalink
feat (afup#1110): functional test
Browse files Browse the repository at this point in the history
Planete PHP
  • Loading branch information
stakovicz committed Nov 1, 2023
1 parent 95f5995 commit 93a5aa4
Show file tree
Hide file tree
Showing 7 changed files with 91 additions and 6 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
8 changes: 6 additions & 2 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 Down
17 changes: 17 additions & 0 deletions behat-planete.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
default:
suites:
planete_features:
paths:
- %paths.base%/tests/behat-planete
contexts:
- FeatureContext
- Behat\MinkExtension\Context\MinkContext
extensions:
Behat\MinkExtension:
base_url: 'https://planetetest:80'
files_path: '%paths.base%/tests/behat/files'
sessions:
default:
goutte:
guzzle_parameters:
verify: false
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
20 changes: 20 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 Down
11 changes: 11 additions & 0 deletions tests/behat-planete/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 tests/behat-planete/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>"

0 comments on commit 93a5aa4

Please sign in to comment.