Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Make good use of the turnip syntax in Behat 3
Feature: registration
Scenario: I cannot register with an already registered email
When I register with "tyrion@lannister.fr" as email
Then I should see "Cet email est déjà utilisé"
Scenario: the email should be valid
When I register with "thisisnot@avalidemail" as email
Then I should see "Cet email n'est pas valide"
Scenario: I cannot register with an already registered nickname
When I register with "Cersei" as nickname
Then I should see "Ce pseudonyme est déjà pris"
Scenario: I cannot register with a short password
When I register with "chien" as password
Then I should see "Pour plus de sécurité le mot de passe doit contenir au moins 6 caractères"
Scenario: all fields are required at registration
When I register with an empty form
Then I should see "L'email est obligatoire"
And I should see "Renseigne un mot de passe pour sécuriser ton compte"
And I should see "Choisis toi un pseudonyme !"
<?php
namespace Context;
class RegistrationContext extends BaseContext
{
/**
* @When I go to the registration page
*/
public function iGoToTheRegistrationPage()
{
$this->visit('/inscription');
}
/**
* @When I register with :email as email
* @When I register with :nickname as nickname
* @When I register with :password as password
*/
public function iRegisterWith($email = 'foo@bar.com', $nickname = 'FooBar', $password = 'foobar1337')
{
$this->iGoToTheRegistrationPage();
$this->fillField('register_email', $email);
$this->fillField('register_person_nickname', $nickname);
$this->fillField('register_plainPassword_first', $password);
$this->fillField('register_plainPassword_second', $password);
$this->pressButton('register_registerButton');
}
/**
* @When I register with an empty form
*/
public function iRegisterWithAnEmptyForm()
{
$this->iRegisterWith('', '', '');
}
}
@sansonthomas

This comment has been minimized.

Copy link

commented Sep 3, 2014

Great. Thank you!

juste line 7 => Scenario: the email should be valid
should be :
Scenario: the email should not be valid

It's no big deal

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.