Last active
August 29, 2015 14:06
-
-
Save tentacode/5cb8c27ca7e63666cc4d to your computer and use it in GitHub Desktop.
Make good use of the turnip syntax in Behat 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 !" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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('', '', ''); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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