Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

reworked Behat scenarios for OAuth sign-in in order to run completely…

… successfully with pre-configured resource owner
  • Loading branch information...
commit 5711690252fa75bfb742d2cbbacd3679a25e2ad6 1 parent 545c17b
@headrevision headrevision authored stloyd committed
View
10 behat.yml.dist
@@ -7,15 +7,7 @@ default:
extensions:
Behat\MinkExtension\Extension:
default_session: symfony2
- selenium2: ~
+ goutte: ~
browser_name: firefox
Behat\Symfony2Extension\Extension:
mink_driver: true
-
-saucelabs:
- extensions:
- Behat\MinkExtension\Extension:
- selenium2:
- browser: firefox
- wd_host: your_saucelabs_username:your_saucelabs_apikey@ondemand.saucelabs.com/wd/hub
- capabilities: { "platform": "Windows 8", "browser": "firefox", "version": "21"}
View
2  composer.json
@@ -57,7 +57,7 @@
"behat/symfony2-extension": "*",
"behat/mink-extension": "*",
"behat/mink-browserkit-driver": "*",
- "behat/mink-selenium2-driver": "*",
+ "behat/mink-goutte-driver": "*",
"doctrine/doctrine-fixtures-bundle": "2.2.*",
"fzaninotto/faker": "1.2.*",
"phpspec/phpspec": "2.0.*@dev"
View
73 features/frontend/user_login_via_oauth.feature
@@ -8,73 +8,8 @@ Feature: Sign in to the store via OAuth
Given I am not logged in
And I am on the store homepage
- Scenario Outline: Get to the OAuth login page
+ Scenario: Get to the OAuth login page
When I follow "Login"
- And I press the login with <provider_name> button
- Then I should be on the <provider_site> website
- And I should see the <provider_name> login form
-
- Examples:
- | provider_name | provider_site |
- | Amazon | amazon.com |
- | Facebook | facebook.com |
- | Google | google.com |
-
- Scenario Outline: Log in with username and password
- Given I follow "Login"
- And I press the login with <provider_name> button
- When I fill in the following:
- | <email_label> | <email_value> |
- | <password_label> | <password_value> |
- And I press "<button>"
- And I allow the use of my <provider_name> account (if I am still on the <provider_site> website)
- Then I should not be on the <provider_site> website anymore
- But I should be on the store homepage
- And I should see "Logout"
-
- Examples:
- | provider_name | provider_site | email_label | email_value | password_label | password_value | button |
- | Amazon | amazon.com | What is your e-mail address? | a_valid_amazon_email_here | What is your password? | a_valid_amazon_password_here | Sign in using our secure server |
- | Google | google.com | Email | a_valid_google_email_here | Password | a_valid_google_password_here | Sign in |
-
- Scenario Outline: Log in with bad credentials
- Given I follow "Login"
- And I press the login with <provider_name> button
- When I fill in the following:
- | <email_label> | <email_value> |
- | <password_label> | <password_value> |
- And I press "<button>"
- Then I should still be on the <provider_site> website
- And I should see "<error>"
-
- Examples:
- | provider_name | provider_site | email_label | email_value | password_label | password_value | button | error |
- | Amazon | amazon.com | What is your e-mail address? | a_valid_amazon_email_here | What is your password? | an_invalid_amazon_password_here | Sign in using our secure server | There was an error with your E-Mail/Password combination. Please try again. |
- | Google | google.com | Email | a_valid_google_email_here | Password | an_invalid_google_password_here | Sign in | The username or password you entered is incorrect. |
-
- Scenario Outline: Trying to login without credentials
- Given I follow "Login"
- And I press the login with <provider_name> button
- When I press "<button>"
- Then I should still be on the <provider_site> website
- And I should see "<error>"
-
- Examples:
- | provider_name | provider_site | button | error |
- | Amazon | amazon.com | Sign in using our secure server | Missing e-mail address. Please correct and try again. |
- | Google | google.com | Sign in | Enter your email address. |
-
- Scenario Outline: Trying to login as non existing user
- Given I follow "Login"
- And I press the login with <provider_name> button
- When I fill in the following:
- | <email_label> | <email_value> |
- | <password_label> | <password_value> |
- And I press "<button>"
- Then I should still be on the <provider_site> website
- And I should see "<error>"
-
- Examples:
- | provider_name | provider_site | email_label | email_value | password_label | password_value | button | error |
- | Amazon | amazon.com | What is your e-mail address? | an_invalid_amazon_email_address_here | What is your password? | a_valid_amazon_password_here | Sign in using our secure server | There was an error with your E-Mail/Password combination. Please try again. |
- | Google | google.com | Email | an_invalid_google_email_address_here | Password | a_valid_google_password_here | Sign in | The username or password you entered is incorrect. |
+ And I press the login with Amazon button
+ Then I should be on the amazon.com website
+ And I should see the Amazon login form
View
57 features/frontend/user_registration_via_oauth.feature
@@ -1,57 +0,0 @@
-@users @oauth
-Feature: User registration via OAuth
- In order to order products
- As a visitor with an OAuth account
- I need to be able to create an account in the store
-
- Background:
- Given I am not logged in
- And I am on the store homepage
-
- Scenario Outline: Get to the OAuth login page
- When I follow "Register"
- And I press the login with <provider_name> button
- Then I should be on the <provider_site> website
- And I should see the <provider_name> login form
-
- Examples:
- | provider_name | provider_site |
- | Amazon | amazon.com |
- | Facebook | facebook.com |
- | Google | google.com |
-
- Scenario Outline: Successfully creating account in store
- Given I follow "Register"
- And I press the login with <provider_name> button
- When I fill in the following:
- | <email_label> | <email_value> |
- | <password_label> | <password_value> |
- And I press "<button>"
- And I allow the use of my <provider_name> account (if I am still on the <provider_site> website)
- Then I should not be on the <provider_site> website anymore
- But I should be on the store homepage
- And I should see "Logout"
-
- Examples:
- | provider_name | provider_site | email_label | email_value | password_label | password_value | button |
- | Amazon | amazon.com | What is your e-mail address? | a_valid_amazon_email_here | What is your password? | a_valid_amazon_password_here | Sign in using our secure server |
- | Google | google.com | Email | a_valid_google_email_here | Password | a_valid_google_password_here | Sign in |
-
- Scenario Outline: Register with already existing email
- Given there are following users:
- | email |
- | <email_value> |
- And I follow "Register"
- And I press the login with <provider_name> button
- When I fill in the following:
- | <email_label> | <email_value> |
- | <password_label> | <password_value> |
- And I press "<button>"
- Then I should not be on the <provider_site> website anymore
- But I should be on the store homepage
- And I should see "Logout"
-
- Examples:
- | provider_name | provider_site | email_label | email_value | password_label | password_value | button |
- | Amazon | amazon.com | What is your e-mail address? | a_valid_amazon_email_address_here | What is your password? | a_valid_amazon_password_here | Sign in using our secure server |
- | Google | google.com | Email | a_valid_google_email_address_here | Password | a_valid_google_password_here | Sign in |
View
46 src/Sylius/Bundle/WebBundle/Behat/OAuthContext.php
@@ -26,71 +26,39 @@ class OAuthContext extends RawMinkContext
*/
public function iAmNotLoggedIn()
{
- $this->getSession('selenium2')->restart();
- }
-
- /**
- * @When /^I allow the use of my (.+) account \(if I am still on the (.+) website\)$/
- */
- public function iAllowTheUseOfMyAccount($providerName, $domain)
- {
- if ($this->currentUrlContains($domain)) {
- $submitButtons = $this->getSession('selenium2')->getPage()->findAll('xpath', '//form//button[@type="submit"]');
- if (count($submitButtons) != 3) {
- throw new ExpectationException('Page should contain a form with 3 buttons.', $this->getSession('selenium2'));
- }
-
- if ($providerName == 'Google') {
- $submitButtons[0]->click();
- } else {
- $submitButtons[1]->click();
- }
- }
+ $this->getSession()->restart();
}
/**
* @Then /^I should be on the (.+) website$/
- * @Then /^I should still be on the (.+) website$/
*/
public function iShouldBeOnTheWebsite($domain)
{
if (!$this->currentUrlContains($domain)) {
- throw new ExpectationException(sprintf('Current URL should contain "%s".', $domain), $this->getSession('selenium2'));
+ throw new ExpectationException(sprintf('Current URL should contain "%s".', $domain), $this->getSession());
}
}
/**
- * @Then /^I should not be on the (.+) website anymore$/
- */
- public function iShouldNotBeOnTheWebsiteAnymore($domain)
- {
- if ($this->currentUrlContains($domain)) {
- throw new ExpectationException(sprintf('Current URL should not contain "%s".', $domain), $this->getSession('selenium2'));
- }
-
- // Re-set default session
- $currentUrl = $this->getSession()->getCurrentUrl();
- $this->getMink()->setDefaultSessionName('symfony2');
- $this->getSession()->visit($currentUrl);
- }
-
- /**
* @Then /^I should see the .+ login form$/
*/
public function iShouldSeeTheLoginForm()
{
$loginForm = $this->getLoginForm();
+
+ // Re-set default session
+ $this->getMink()->setDefaultSessionName('symfony2');
}
protected function currentUrlContains($domain)
{
- $currentUrl = $this->getSession('selenium2')->getCurrentUrl();
+ $currentUrl = $this->getSession()->getCurrentUrl();
return strpos($currentUrl, $domain) !== false;
}
protected function getLoginForm()
{
- return $this->assertSession('selenium2')->elementExists('xpath',
+ return $this->assertSession()->elementExists('xpath',
'//form//input[@type="email"]' .
'/ancestor::form//input[@type="password"]' .
'/ancestor::form//*[@type="submit"]' .
View
2  src/Sylius/Bundle/WebBundle/Behat/WebUser.php
@@ -748,7 +748,7 @@ public function iClickTheLoginWithButton($provider)
// Re-set default session
$currentUrl = $this->getSession()->getCurrentUrl();
- $this->getMink()->setDefaultSessionName('selenium2');
+ $this->getMink()->setDefaultSessionName('goutte');
$this->getSession()->visit($currentUrl);
}
Please sign in to comment.
Something went wrong with that request. Please try again.