forked from Sylius/Sylius
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request Sylius#9656 from GSadee/registration-after-checkout
[Shop] Registration after checkout
- Loading branch information
Showing
27 changed files
with
719 additions
and
301 deletions.
There are no files selected for viewing
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
31 changes: 31 additions & 0 deletions
31
features/checkout/having_registration_account_form_prefilled_after_checkout.feature
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
@checkout | ||
Feature: Having registration form prefilled after checkout | ||
In order to make future purchases with ease | ||
As an Visitor | ||
I want to have account registration form prefilled after placing an order | ||
|
||
Background: | ||
Given the store operates on a single channel in "United States" | ||
And the store has a product "PHP T-Shirt" priced at "$19.99" | ||
And the store ships everywhere for free | ||
And the store allows paying offline | ||
|
||
@ui | ||
Scenario: Having prefilled registration form after checkout | ||
Given I have product "PHP T-Shirt" in the cart | ||
And I complete addressing step with email "[email protected]" and "United States" based shipping address | ||
And I proceed with "Free" shipping method and "Offline" payment | ||
And I confirm my order | ||
Then I should see the thank you page | ||
And I should be able to proceed to the registration | ||
And the registration form should be prefilled with "[email protected]" email | ||
|
||
@ui | ||
Scenario: Not being able to create an account if customer is logged in | ||
Given I am a logged in customer | ||
And I have product "PHP T-Shirt" in the cart | ||
And I complete addressing step with "United States" based shipping address | ||
And I proceed with "Free" shipping method and "Offline" payment | ||
And I confirm my order | ||
Then I should see the thank you page | ||
And I should not be able to proceed to the registration |
24 changes: 24 additions & 0 deletions
24
features/checkout/registering_account_after_checkout.feature
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
@checkout | ||
Feature: Registering a new account after checkout | ||
In order to make future purchases with ease | ||
As an Visitor | ||
I want to be able to create an account in the store after placing an order | ||
|
||
Background: | ||
Given the store operates on a single channel in "United States" | ||
And the store has a product "PHP T-Shirt" priced at "$19.99" | ||
And the store ships everywhere for free | ||
And the store allows paying offline | ||
|
||
@ui | ||
Scenario: Registering a new account after checkout | ||
Given I have product "PHP T-Shirt" in the cart | ||
And I have completed addressing step with email "[email protected]" and "United States" based shipping address | ||
And I have proceeded order with "Free" shipping method and "Offline" payment | ||
And I have confirmed order | ||
When I proceed to the registration | ||
And I specify a password as "sylius" | ||
And I confirm this password | ||
And I register this account | ||
And I verify my account using link sent to "[email protected]" | ||
Then I should be able to log in as "[email protected]" with "sylius" password |
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
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
132 changes: 132 additions & 0 deletions
132
src/Sylius/Behat/Context/Ui/Shop/Checkout/RegistrationAfterCheckoutContext.php
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,132 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Paweł Jędrzejewski | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sylius\Behat\Context\Ui\Shop\Checkout; | ||
|
||
use Behat\Behat\Context\Context; | ||
use Sylius\Behat\Element\Shop\Account\RegisterElementInterface; | ||
use Sylius\Behat\Page\Shop\Account\DashboardPageInterface; | ||
use Sylius\Behat\Page\Shop\Account\LoginPageInterface; | ||
use Sylius\Behat\Page\Shop\Account\VerificationPageInterface; | ||
use Sylius\Behat\Page\Shop\HomePageInterface; | ||
use Sylius\Behat\Page\Shop\Order\ThankYouPageInterface; | ||
use Sylius\Behat\Service\NotificationCheckerInterface; | ||
use Sylius\Behat\Service\SharedStorageInterface; | ||
use Sylius\Component\Core\Model\CustomerInterface; | ||
use Webmozart\Assert\Assert; | ||
|
||
final class RegistrationAfterCheckoutContext implements Context | ||
{ | ||
/** @var SharedStorageInterface */ | ||
private $sharedStorage; | ||
|
||
/** @var LoginPageInterface */ | ||
private $loginPage; | ||
|
||
/** @var ThankYouPageInterface */ | ||
private $thankYouPage; | ||
|
||
/** @var DashboardPageInterface */ | ||
private $dashboardPage; | ||
|
||
/** @var HomePageInterface */ | ||
private $homePage; | ||
|
||
/** @var VerificationPageInterface */ | ||
private $verificationPage; | ||
|
||
/** @var RegisterElementInterface */ | ||
private $registerElement; | ||
|
||
/** @var NotificationCheckerInterface */ | ||
private $notificationChecker; | ||
|
||
public function __construct( | ||
SharedStorageInterface $sharedStorage, | ||
LoginPageInterface $loginPage, | ||
ThankYouPageInterface $thankYouPage, | ||
DashboardPageInterface $dashboardPage, | ||
HomePageInterface $homePage, | ||
VerificationPageInterface $verificationPage, | ||
RegisterElementInterface $registerElement, | ||
NotificationCheckerInterface $notificationChecker | ||
) { | ||
$this->sharedStorage = $sharedStorage; | ||
$this->loginPage = $loginPage; | ||
$this->thankYouPage = $thankYouPage; | ||
$this->dashboardPage = $dashboardPage; | ||
$this->homePage = $homePage; | ||
$this->verificationPage = $verificationPage; | ||
$this->registerElement = $registerElement; | ||
$this->notificationChecker = $notificationChecker; | ||
} | ||
|
||
/** | ||
* @When I specify a password as :password | ||
*/ | ||
public function iSpecifyThePasswordAs(string $password): void | ||
{ | ||
$this->registerElement->specifyPassword($password); | ||
$this->sharedStorage->set('password', $password); | ||
} | ||
|
||
/** | ||
* @When /^I confirm (this password)$/ | ||
*/ | ||
public function iConfirmThisPassword(string $password): void | ||
{ | ||
$this->registerElement->verifyPassword($password); | ||
} | ||
|
||
/** | ||
* @When I register this account | ||
*/ | ||
public function iRegisterThisAccount(): void | ||
{ | ||
$this->registerElement->register(); | ||
} | ||
|
||
/** | ||
* @When I verify my account using link sent to :customer | ||
*/ | ||
public function iVerifyMyAccountUsingLink(CustomerInterface $customer): void | ||
{ | ||
$user = $customer->getUser(); | ||
Assert::notNull($user, 'No account for given customer'); | ||
|
||
$this->verificationPage->verifyAccount($user->getEmailVerificationToken()); | ||
} | ||
|
||
/** | ||
* @Then the registration form should be prefilled with :email email | ||
*/ | ||
public function theRegistrationFormShouldBePrefilledWithEmail(string $email): void | ||
{ | ||
$this->thankYouPage->createAccount(); | ||
|
||
Assert::same($this->registerElement->getEmail(), $email); | ||
} | ||
|
||
/** | ||
* @Then I should be able to log in as :email with :password password | ||
*/ | ||
public function iShouldBeAbleToLogInAsWithPassword(string $email, string $password): void | ||
{ | ||
$this->loginPage->open(); | ||
$this->loginPage->specifyUsername($email); | ||
$this->loginPage->specifyPassword($password); | ||
$this->loginPage->logIn(); | ||
|
||
Assert::true($this->homePage->hasLogoutButton()); | ||
} | ||
} |
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
Oops, something went wrong.