Skip to content

Commit

Permalink
[Behat] Introduce register element
Browse files Browse the repository at this point in the history
  • Loading branch information
GSadee committed Aug 24, 2018
1 parent 616bef8 commit dc9de6c
Show file tree
Hide file tree
Showing 14 changed files with 306 additions and 319 deletions.
1 change: 1 addition & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"behat/mink-selenium2-driver": "^1.3",
"friends-of-behat/context-service-extension": "^1.2",
"friends-of-behat/cross-container-extension": "^1.1",
"friends-of-behat/page-object-extension": "^0.1.0",
"friends-of-behat/service-container-extension": "^1.0",
"friends-of-behat/symfony-extension": "^1.2.1",
"friends-of-behat/variadic-extension": "^1.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
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\RegisterPageInterface;
use Sylius\Behat\Page\Shop\Account\VerificationPageInterface;
use Sylius\Behat\Page\Shop\HomePageInterface;
use Sylius\Behat\Page\Shop\Order\ThankYouPageInterface;
Expand All @@ -33,9 +33,6 @@ final class RegistrationAfterCheckoutContext implements Context
/** @var LoginPageInterface */
private $loginPage;

/** @var RegisterPageInterface */
private $registerPage;

/** @var ThankYouPageInterface */
private $thankYouPage;

Expand All @@ -48,26 +45,29 @@ final class RegistrationAfterCheckoutContext implements Context
/** @var VerificationPageInterface */
private $verificationPage;

/** @var RegisterElementInterface */
private $registerElement;

/** @var NotificationCheckerInterface */
private $notificationChecker;

public function __construct(
SharedStorageInterface $sharedStorage,
LoginPageInterface $loginPage,
RegisterPageInterface $registerPage,
ThankYouPageInterface $thankYouPage,
DashboardPageInterface $dashboardPage,
HomePageInterface $homePage,
VerificationPageInterface $verificationPage,
RegisterElementInterface $registerElement,
NotificationCheckerInterface $notificationChecker
) {
$this->sharedStorage = $sharedStorage;
$this->loginPage = $loginPage;
$this->registerPage = $registerPage;
$this->thankYouPage = $thankYouPage;
$this->dashboardPage = $dashboardPage;
$this->homePage = $homePage;
$this->verificationPage = $verificationPage;
$this->registerElement = $registerElement;
$this->notificationChecker = $notificationChecker;
}

Expand All @@ -76,7 +76,7 @@ public function __construct(
*/
public function iSpecifyThePasswordAs(string $password): void
{
$this->registerPage->specifyPassword($password);
$this->registerElement->specifyPassword($password);
$this->sharedStorage->set('password', $password);
}

Expand All @@ -85,15 +85,15 @@ public function iSpecifyThePasswordAs(string $password): void
*/
public function iConfirmThisPassword(string $password): void
{
$this->registerPage->verifyPassword($password);
$this->registerElement->verifyPassword($password);
}

/**
* @When I register this account
*/
public function iRegisterThisAccount(): void
{
$this->registerPage->register();
$this->registerElement->register();
}

/**
Expand All @@ -114,7 +114,7 @@ public function theRegistrationFormShouldBePrefilledWithEmail(string $email): vo
{
$this->thankYouPage->createAccount();

Assert::same($this->registerPage->getEmail(), $email);
Assert::same($this->registerElement->getEmail(), $email);
}

/**
Expand Down
65 changes: 21 additions & 44 deletions src/Sylius/Behat/Context/Ui/Shop/CheckoutContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Sylius\Behat\Context\Ui\Shop\Checkout\CheckoutAddressingContext;
use Sylius\Behat\Context\Ui\Shop\Checkout\CheckoutPaymentContext;
use Sylius\Behat\Context\Ui\Shop\Checkout\CheckoutShippingContext;
use Sylius\Behat\Element\Shop\Account\RegisterElementInterface;
use Sylius\Behat\Page\Shop\Account\RegisterPageInterface;
use Sylius\Behat\Page\Shop\Checkout\AddressPageInterface;
use Sylius\Behat\Page\Shop\Checkout\CompletePageInterface;
Expand All @@ -29,68 +30,43 @@

final class CheckoutContext implements Context
{
/**
* @var AddressPageInterface
*/
/** @var AddressPageInterface */
private $addressPage;

/**
* @var SelectPaymentPageInterface
*/
/** @var SelectPaymentPageInterface */
private $selectPaymentPage;

/**
* @var SelectShippingPageInterface
*/
/** @var SelectShippingPageInterface */
private $selectShippingPage;

/**
* @var CompletePageInterface
*/
/** @var CompletePageInterface */
private $completePage;

/**
* @var RegisterPageInterface
*/
/** @var RegisterPageInterface */
private $registerPage;

/**
* @var CurrentPageResolverInterface
*/
/** @var RegisterElementInterface */
private $registerElement;

/** @var CurrentPageResolverInterface */
private $currentPageResolver;

/**
* @var CheckoutAddressingContext
*/
/** @var CheckoutAddressingContext */
private $addressingContext;

/**
* @var CheckoutShippingContext
*/
/** @var CheckoutShippingContext */
private $shippingContext;

/**
* @var CheckoutPaymentContext
*/
/** @var CheckoutPaymentContext */
private $paymentContext;

/**
* @param AddressPageInterface $addressPage
* @param SelectPaymentPageInterface $selectPaymentPage
* @param SelectShippingPageInterface $selectShippingPage
* @param CompletePageInterface $completePage
* @param RegisterPageInterface $registerPage
* @param CurrentPageResolverInterface $currentPageResolver
* @param CheckoutAddressingContext $addressingContext
* @param CheckoutShippingContext $shippingContext
* @param CheckoutPaymentContext $paymentContext
*/
public function __construct(
AddressPageInterface $addressPage,
SelectPaymentPageInterface $selectPaymentPage,
SelectShippingPageInterface $selectShippingPage,
CompletePageInterface $completePage,
RegisterPageInterface $registerPage,
RegisterElementInterface $registerElement,
CurrentPageResolverInterface $currentPageResolver,
CheckoutAddressingContext $addressingContext,
CheckoutShippingContext $shippingContext,
Expand All @@ -101,6 +77,7 @@ public function __construct(
$this->selectShippingPage = $selectShippingPage;
$this->completePage = $completePage;
$this->registerPage = $registerPage;
$this->registerElement = $registerElement;
$this->currentPageResolver = $currentPageResolver;
$this->addressingContext = $addressingContext;
$this->shippingContext = $shippingContext;
Expand Down Expand Up @@ -242,11 +219,11 @@ public function theSubtotalOfItemShouldBe($item, $price)
public function iRegisterWithPreviouslyUsedEmailAndPassword(string $email, string $password): void
{
$this->registerPage->open();
$this->registerPage->specifyEmail($email);
$this->registerPage->specifyPassword($password);
$this->registerPage->verifyPassword($password);
$this->registerPage->specifyFirstName('Carrot');
$this->registerPage->specifyLastName('Ironfoundersson');
$this->registerPage->register();
$this->registerElement->specifyEmail($email);
$this->registerElement->specifyPassword($password);
$this->registerElement->verifyPassword($password);
$this->registerElement->specifyFirstName('Carrot');
$this->registerElement->specifyLastName('Ironfoundersson');
$this->registerElement->register();
}
}
47 changes: 18 additions & 29 deletions src/Sylius/Behat/Context/Ui/Shop/LoginContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace Sylius\Behat\Context\Ui\Shop;

use Behat\Behat\Context\Context;
use Sylius\Behat\Element\Shop\Account\RegisterElementInterface;
use Sylius\Behat\NotificationType;
use Sylius\Behat\Page\Shop\Account\LoginPageInterface;
use Sylius\Behat\Page\Shop\Account\RegisterPageInterface;
Expand All @@ -24,49 +25,37 @@

final class LoginContext implements Context
{
/**
* @var HomePageInterface
*/
/** @var HomePageInterface */
private $homePage;

/**
* @var LoginPageInterface
*/
/** @var LoginPageInterface */
private $loginPage;

/**
* @var RegisterPageInterface
*/
/** @var RegisterPageInterface */
private $registerPage;

/**
* @var ResetPasswordPageInterface
*/
/** @var ResetPasswordPageInterface */
private $resetPasswordPage;

/**
* @var NotificationCheckerInterface
*/
/** @var RegisterElementInterface */
private $registerElement;

/** @var NotificationCheckerInterface */
private $notificationChecker;

/**
* @param HomePageInterface $homePage
* @param LoginPageInterface $loginPage
* @param RegisterPageInterface $registerPage
* @param ResetPasswordPageInterface $resetPasswordPage
* @param NotificationCheckerInterface $notificationChecker
*/
public function __construct(
HomePageInterface $homePage,
LoginPageInterface $loginPage,
RegisterPageInterface $registerPage,
ResetPasswordPageInterface $resetPasswordPage,
RegisterElementInterface $registerElement,
NotificationCheckerInterface $notificationChecker
) {
$this->homePage = $homePage;
$this->loginPage = $loginPage;
$this->registerPage = $registerPage;
$this->resetPasswordPage = $resetPasswordPage;
$this->registerElement = $registerElement;
$this->notificationChecker = $notificationChecker;
}

Expand Down Expand Up @@ -144,15 +133,15 @@ public function iSignInWithEmailAndPassword(string $email, string $password): vo
/**
* @When I register with email :email and password :password
*/
public function iRegisterWithEmailAndPassword($email, $password)
public function iRegisterWithEmailAndPassword(string $email, string $password): void
{
$this->registerPage->open();
$this->registerPage->specifyEmail($email);
$this->registerPage->specifyPassword($password);
$this->registerPage->verifyPassword($password);
$this->registerPage->specifyFirstName('Carrot');
$this->registerPage->specifyLastName('Ironfoundersson');
$this->registerPage->register();
$this->registerElement->specifyEmail($email);
$this->registerElement->specifyPassword($password);
$this->registerElement->verifyPassword($password);
$this->registerElement->specifyFirstName('Carrot');
$this->registerElement->specifyLastName('Ironfoundersson');
$this->registerElement->register();
}

/**
Expand Down
Loading

0 comments on commit dc9de6c

Please sign in to comment.