Commit 93758070 authored by Ernesto Rodriguez Ortiz's avatar Ernesto Rodriguez Ortiz
Browse files

Add behat directory

parent 48daf402
......@@ -7,3 +7,6 @@ src/drupal
# Ignore profile directory
sflinux
# Ignore ssh keys
deploy/id_rsa*
Instructions
============
Behat: tests fonctionnels
-------------------------
Ces tests sont des tests génériques.
Cependant, ils nécessitent que le Drupal soit configuré de la sorte :
un rôle «administrator» et un rôle «editor»
installation en français, langue par défaut
Vieilles instructions qui ne seront plus valides quand le projet sera dockerisé
Copy behat/behat.yml.example to behat/behat.yml, and replace the placeholders with your values.
Run the tests:
% ./behat
= Instructions =
== Behat: functional tests ==
Copy behat/behat.yml.example to behat/behat.yml, and replace the placeholders with your values.
Run the tests:
% ./behat
Installation
=============
Documentation de Behat Drupal Extension 3.0: http://behat-drupal-extension.readthedocs.org/en/3.0/.
En particulier, se référer à la page suivante pour plus d'informations sur l'installation: http://behat-drupal-extension.readthedocs.org/en/3.0/localinstall.html.
* Installer Composer si nécessaire:
```bash
curl -s https://getcomposer.org/installer | php
```
* Installer Drupal Extension et toutes les dépendances nécessaires
```bash
php composer.phar install
```
* Copier le fichier exemple.behat.yml
```bash
cp exemple.behat.yml behat.yml
```
Éditer ce fichier pour mettre votre propre configuration (dans le profil *default*), entre autre:
```yml
base_url: 'http://votre.adresse.local'
root: '/votre/dossier/drupal'
drupal_root: '/votre/dossier/drupal'
```
* Exécuter les tests, où @nom est le nom d'un test, et ~@nom dans les tags sert à ignorer @nom
```bash
bin/behat --tags "~@wip&&~@disabled"
```
\ No newline at end of file
{
"require": {
"drupal/drupal-extension": "~3.0"
},
"config": {
"bin-dir": "bin/"
}
}
default:
suites:
default:
contexts:
- FeatureContext
- Drupal\DrupalExtension\Context\DrupalContext
- Drupal\DrupalExtension\Context\MinkContext
- Drupal\DrupalExtension\Context\MessageContext
- Drupal\DrupalExtension\Context\DrushContext
extensions:
Behat\MinkExtension:
goutte: ~
selenium2: ~
base_url: %URL
Drupal\DrupalExtension:
blackbox: ~
api_driver: 'drupal'
drush:
root: %DRUPAL_ROOT
drupal:
drupal_root: %DRUPAL_ROOT
selectors:
message_selector: '.messages'
error_message_selector: '.messages.error'
warning_message_selector: '.messages.warning'
success_message_selector: '.messages.status'
region_map:
"Header": "header.siteHeader"
"Content": "main.main"
"Footer": "footer.siteFooter"
text:
username_field: "Nom d'utilisateur"
password_field: "Mot de passe"
log_in: "Se connecter"
log_out: "Se déconnecter"
<?php
use Drupal\DrupalExtension\Context\RawDrupalContext;
use Behat\Behat\Context\SnippetAcceptingContext;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;
/**
* Defines application features from the specific context.
*/
class FeatureContext extends RawDrupalContext implements SnippetAcceptingContext {
/**
* Initializes context.
*
* Every scenario gets its own context instance.
* You can also pass arbitrary arguments to the
* context constructor through behat.yml.
*/
public function __construct() {
}
}
@api @generic
Feature: Generic site features and global health
Scenario: The homepage must load properly
Given I am on the homepage
Then I should get a "200" HTTP response
Scenario: Accessing to admin menu toolbar
Given I am logged in as a user with the "administrator" role
When I am on the homepage
Then I should see an "div#admin-menu-wrapper" element
Scenario: The cache can be cleared
Given the cache has been cleared
When I am on the homepage
Then I should get a "200" HTTP response
Scenario: An administrator can administer the modules
Given I am logged in as a user with the "administrator" role
When I am on "/admin/modules"
Then I should get a "200" HTTP response
Scenario: An anonymous user can not access to admin pages
Given I am an anonymous user
When I am on "/admin"
Then I should get a "403" HTTP response
Scenario: An administrator can create users
Given users:
| name | mail | status |
| Joe User | joe@example.com | 1 |
And I am logged in as a user with the "administrator" role
When I visit "admin/people"
Then I should see the link "Joe User"
Scenario: An administrator can create users with roles
Given users:
| name | mail | roles |
| Joe User | joe@example.com | administrator |
And I am logged in as a user with the "administrator" role
When I visit "admin/people"
Then I should see the text "administrator" in the "Joe User" row
Scenario: Run cron
Given I am logged in as a user with the "administrator" role
When I run cron
And am on "admin/reports/status"
Then I should see the link "lancer le cron manuellement"
Scenario: Login as a user created during this scenario
Given users:
| name | status | roles |
| Test user | 1 | editor |
When I am logged in as "Test user"
Then I should see the link "Se déconnecter"
Scenario: Error messages
Given I am on "/user"
When I press "Se connecter"
Then I should see the error message "Le champ Mot de passe est requis."
And I should not see the error message "Désolé, nom d'utilisateur ou mot de passe non reconnu."
And I should see the following error messages:
| error messages |
| Le champ Nom d'utilisateur est requis. |
| Le champ Mot de passe est requis. |
And I should not see the following error messages:
| error messages |
| Désolé, nom d'utilisateur ou mot de passe non reconnu. |
Scenario: Access denied to register url.
Given I am on "/user/register"
Then I should see "Accès refusé"
And I should see "Vous n'êtes pas autorisé(e) à accéder à cette page."
Scenario: drush command with text matching: drush output correct status
Given I run drush "st"
Then drush output should contain "Drupal version"
Then drush output should contain "Site URI"
Then drush output should contain "Database driver"
Then drush output should contain "Successful"
Then drush output should not contain "NonExistantWord"
Scenario: drush command with arguments: re-enable system
Given I run drush "en" "system -y"
Then drush output should contain "system is already enabled."
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment