mirror of
https://github.com/Sylius/Sylius.git
synced 2026-07-14 17:10:53 +00:00
Add implementation of scenarios
This commit is contained in:
parent
2092624510
commit
9b25a870b6
21 changed files with 428 additions and 49 deletions
|
|
@ -155,6 +155,7 @@ final class CustomerContext implements Context
|
|||
|
||||
/**
|
||||
* @Given /^(his) shipping (address is "(?:[^"]+)", "(?:[^"]+)", "(?:[^"]+)", "(?:[^"]+)" for "(?:[^"]+)")$/
|
||||
* @Given /^(his) shipping (address is "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)")$/
|
||||
*/
|
||||
public function heHasShippingAddress(CustomerInterface $customer, AddressInterface $address)
|
||||
{
|
||||
|
|
@ -165,6 +166,7 @@ final class CustomerContext implements Context
|
|||
|
||||
/**
|
||||
* @Given /^(his) billing (address is "(?:[^"]+)", "(?:[^"]+)", "(?:[^"]+)", "(?:[^"]+)" for "(?:[^"]+)")$/
|
||||
* @Given /^(his) billing (address is "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)")$/
|
||||
*/
|
||||
public function heHasBillingAddress(CustomerInterface $customer, AddressInterface $address)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ final class GeographicalContext implements Context
|
|||
|
||||
/**
|
||||
* @Given /^(this country) has the "([^"]+)" province with "([^"]+)" code$/
|
||||
* @Given /^(country "[^"]+") has the "([^"]+)" province with "([^"]+)" code$/
|
||||
* @Given /^(?:|the )(country "[^"]+") has the "([^"]+)" province with "([^"]+)" code$/
|
||||
*/
|
||||
public function theCountryHasProvinceWithCode(CountryInterface $country, $name, $code)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -183,8 +183,8 @@ final class OrderContext implements Context
|
|||
}
|
||||
|
||||
/**
|
||||
* @Given /^the customer ("[^"]+" addressed it to "[^"]+", "[^"]+" "[^"]+" in the "[^"]+")$/
|
||||
* @Given /^I (addressed it to "[^"]+", "[^"]+", "[^"]+" "[^"]+" in the "[^"]+")$/
|
||||
* @Given /^the customer ("[^"]+" addressed it to "[^"]+", "[^"]+" "[^"]+" in the "[^"]+"(?:|, "[^"]+"))$/
|
||||
* @Given /^I (addressed it to "[^"]+", "[^"]+", "[^"]+" "[^"]+" in the "[^"]+"(?:|, "[^"]+"))$/
|
||||
*/
|
||||
public function theCustomerAddressedItTo(AddressInterface $address)
|
||||
{
|
||||
|
|
@ -197,6 +197,7 @@ final class OrderContext implements Context
|
|||
|
||||
/**
|
||||
* @Given /^for the billing address (of "[^"]+" in the "[^"]+", "[^"]+" "[^"]+", "[^"]+")$/
|
||||
* @Given /^for the billing address (of "[^"]+" in the "[^"]+", "[^"]+" "([^"]+)", "[^"]+", "[^"]+")$/
|
||||
*/
|
||||
public function forTheBillingAddressOf(AddressInterface $address)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -59,12 +59,12 @@ final class AddressingContext implements Context
|
|||
* @Transform /^address is "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)" for "([^"]+)"$/
|
||||
* @Transform /^address to "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)" for "([^"]+)"$/
|
||||
*/
|
||||
public function createNewAddressWith($cityName, $street, $postcode, $countryName, $customerName)
|
||||
public function createNewAddressWith($cityName, $street, $postcode, $countryName, $customerName, $provinceName = null)
|
||||
{
|
||||
$countryCode = $this->countryNameConverter->convertToCode($countryName);
|
||||
$customerName = explode(' ', $customerName);
|
||||
|
||||
return $this->createAddress($countryCode, $customerName[0], $customerName[1], $cityName, $street, $postcode);
|
||||
return $this->createAddress($countryCode, $customerName[0], $customerName[1], $cityName, $street, $postcode, $provinceName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -76,27 +76,18 @@ final class AddressingContext implements Context
|
|||
}
|
||||
|
||||
/**
|
||||
* @Transform /^"([^"]+)" addressed it to "([^"]+)", "([^"]+)" "([^"]+)" in the "([^"]+)"$/
|
||||
* @Transform /^of "([^"]+)" in the "([^"]+)", "([^"]+)" "([^"]+)", "([^"]+)"$/
|
||||
* @Transform /^addressed it to "([^"]+)", "([^"]+)", "([^"]+)" "([^"]+)" in the "([^"]+)"$/
|
||||
* @Transform /^address for "([^"]+)" from "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)"$/
|
||||
* @Transform /^"([^"]+)" addressed it to "([^"]+)", "([^"]+)" "([^"]+)" in the "([^"]+)"(?:|, "([^"]+)")$/
|
||||
* @Transform /^of "([^"]+)" in the "([^"]+)", "([^"]+)" "([^"]+)", "([^"]+)"(?:|, "([^"]+)")$/
|
||||
* @Transform /^addressed it to "([^"]+)", "([^"]+)", "([^"]+)" "([^"]+)" in the "([^"]+)"(?:|, "([^"]+)")$/
|
||||
* @Transform /^address is "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)"$/
|
||||
*/
|
||||
public function createNewAddressWithName($name, $street, $postcode, $city, $countryName)
|
||||
public function createNewAddressWithName($name, $street, $postcode, $city, $countryName, $provinceName = null)
|
||||
{
|
||||
$countryCode = $this->countryNameConverter->convertToCode($countryName);
|
||||
$names = explode(" ", $name);
|
||||
|
||||
return $this->createAddress($countryCode, $names[0], $names[1], $city, $street, $postcode);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Transform /^"([^"]+)" addressed it to "([^"]+)", "([^"]+)" "([^"]+)" in the "([^"]+)"$/
|
||||
*/
|
||||
public function createNewAddressWithUser($name, $street, $postcode, $city, $countryName)
|
||||
{
|
||||
$countryCode = $this->countryNameConverter->convertToCode($countryName);
|
||||
$names = explode(" ", $name);
|
||||
|
||||
return $this->createAddress($countryCode, $names[0], $names[1], $city, $street, $postcode);
|
||||
return $this->createAddress($countryCode, $names[0], $names[1], $city, $street, $postcode, $provinceName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -105,6 +96,8 @@ final class AddressingContext implements Context
|
|||
* @param string $lastName
|
||||
* @param string $city
|
||||
* @param string $street
|
||||
* @param string $postCode
|
||||
* @param string $provinceName
|
||||
*
|
||||
* @return AddressInterface
|
||||
*/
|
||||
|
|
@ -114,7 +107,8 @@ final class AddressingContext implements Context
|
|||
$lastName = 'Doe',
|
||||
$city = 'Ankh Morpork',
|
||||
$street = 'Frost Alley',
|
||||
$postCode = '90210'
|
||||
$postCode = '90210',
|
||||
$provinceName = null
|
||||
) {
|
||||
/** @var AddressInterface $address */
|
||||
$address = $this->addressFactory->createNew();
|
||||
|
|
@ -124,6 +118,7 @@ final class AddressingContext implements Context
|
|||
$address->setCity($city);
|
||||
$address->setStreet($street);
|
||||
$address->setPostcode($postCode);
|
||||
$address->setProvinceName($provinceName);
|
||||
|
||||
return $address;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ use Sylius\Behat\Page\Admin\Customer\CreatePageInterface;
|
|||
use Sylius\Behat\Page\Admin\Customer\ShowPageInterface;
|
||||
use Sylius\Behat\Page\Admin\Customer\UpdatePageInterface;
|
||||
use Sylius\Behat\Service\SharedStorageInterface;
|
||||
use Sylius\Component\Core\Model\Customer;
|
||||
use Sylius\Component\Customer\Model\CustomerInterface;
|
||||
use Webmozart\Assert\Assert;
|
||||
|
||||
|
|
@ -528,4 +529,26 @@ final class ManagingCustomersContext implements Context
|
|||
'This customer should subscribe to the newsletter.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then the province in the shipping address should be :provinceName
|
||||
*/
|
||||
public function theProvinceInTheShippingAddressShouldBe($provinceName)
|
||||
{
|
||||
Assert::true(
|
||||
$this->showPage->hasShippingProvinceName($provinceName),
|
||||
sprintf('Cannot find shipping address with province %s', $provinceName)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then the province in the billing address should be :provinceName
|
||||
*/
|
||||
public function theProvinceInTheShippingBillingShouldBe($provinceName)
|
||||
{
|
||||
Assert::true(
|
||||
$this->showPage->hasBillingProvinceName($provinceName),
|
||||
sprintf('Cannot find shipping address with province %s', $provinceName)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -743,4 +743,26 @@ final class ManagingOrdersContext implements Context
|
|||
{
|
||||
return str_replace(' ', '_', $elementName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I should see :provinceName as province in the shipping address
|
||||
*/
|
||||
public function iShouldSeeAsProvinceInTheShippingAddress($provinceName)
|
||||
{
|
||||
Assert::true(
|
||||
$this->showPage->hasShippingProvinceName($provinceName),
|
||||
sprintf('Cannot find shipping address with province %s', $provinceName)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I should see :provinceName ad province in the billing address
|
||||
*/
|
||||
public function iShouldSeeAdProvinceInTheBillingAddress($provinceName)
|
||||
{
|
||||
Assert::true(
|
||||
$this->showPage->hasBillingProvinceName($provinceName),
|
||||
sprintf('Cannot find shipping address with province %s', $provinceName)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -214,6 +214,7 @@ final class CheckoutContext implements Context
|
|||
|
||||
/**
|
||||
* @When /^I specify the shipping (address as "[^"]+", "[^"]+", "[^"]+", "[^"]+" for "[^"]+")$/
|
||||
* @When /^I specify the shipping (address for "[^"]+" from "[^"]+", "[^"]+", "[^"]+", "[^"]+", "[^"]+")$/
|
||||
* @When /^I (do not specify any shipping address) information$/
|
||||
* @When /^I change the shipping (address to "[^"]+", "[^"]+", "[^"]+", "[^"]+" for "[^"]+")$/
|
||||
*/
|
||||
|
|
@ -234,7 +235,7 @@ final class CheckoutContext implements Context
|
|||
*/
|
||||
public function iSpecifyShippingCountryProvinceAs($province)
|
||||
{
|
||||
$this->addressPage->specifyShippingAddressProvince($province);
|
||||
$this->addressPage->selectShippingAddressProvince($province);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -242,11 +243,12 @@ final class CheckoutContext implements Context
|
|||
*/
|
||||
public function iSpecifyBillingCountryProvinceAs($province)
|
||||
{
|
||||
$this->addressPage->specifyBillingAddressProvince($province);
|
||||
$this->addressPage->selectBillingAddressProvince($province);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When /^I specify the billing (address as "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)" for "([^"]+)")$/
|
||||
* @When /^I specify the billing (address for "([^"]+)" from "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)")$/
|
||||
* @When /^I (do not specify any billing address) information$/
|
||||
*/
|
||||
public function iSpecifyTheBillingAddressAs(AddressInterface $address)
|
||||
|
|
@ -746,11 +748,11 @@ final class CheckoutContext implements Context
|
|||
}
|
||||
|
||||
/**
|
||||
* @When I select :paymentMethodName payment method
|
||||
* @When I select :name payment method
|
||||
*/
|
||||
public function iSelectPaymentMethod($paymentMethodName)
|
||||
public function iSelectPaymentMethod($name)
|
||||
{
|
||||
$this->selectPaymentPage->selectPaymentMethod($paymentMethodName);
|
||||
$this->selectPaymentPage->selectPaymentMethod($name);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1105,6 +1107,66 @@ final class CheckoutContext implements Context
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I specify the province name manually as :provinceName for shipping address
|
||||
*/
|
||||
public function iSpecifyTheProvinceNameManuallyAsForShippingAddress($provinceName)
|
||||
{
|
||||
$this->addressPage->specifyShippingAddressProvince($provinceName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I specify the province name manually as :provinceName for billing address
|
||||
*/
|
||||
public function iSpecifyTheProvinceNameManuallyAsForBillingAddress($provinceName)
|
||||
{
|
||||
$this->addressPage->specifyBillingAddressProvince($provinceName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I should not be able to specify province name manually for shipping address
|
||||
*/
|
||||
public function iShouldNotBeAbleToSpecifyProvinceNameManuallyForShippingAddress()
|
||||
{
|
||||
Assert::false(
|
||||
$this->addressPage->hasShippingAddressInput(),
|
||||
'I should not be able to specify manually the province for shipping address, but I can.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I should not be able to specify province name manually for billing address
|
||||
*/
|
||||
public function iShouldNotBeAbleToSpecifyProvinceNameManuallyForBillingAddress()
|
||||
{
|
||||
Assert::false(
|
||||
$this->addressPage->hasBillingAddressInput(),
|
||||
'I should not be able to specify manually the province for billing address, but I can.'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I should see :provinceName in the shipping address
|
||||
*/
|
||||
public function iShouldSeeInTheShippingAddress($provinceName)
|
||||
{
|
||||
Assert::true(
|
||||
$this->completePage->hasShippingProvinceName($provinceName),
|
||||
sprintf('Cannot find shipping address with province %s', $provinceName)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I should see :provinceName in the billing address
|
||||
*/
|
||||
public function iShouldSeeInTheBillingAddress($provinceName)
|
||||
{
|
||||
Assert::true(
|
||||
$this->completePage->hasBillingProvinceName($provinceName),
|
||||
sprintf('Cannot find billing address with province %s', $provinceName)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return AddressInterface
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -406,19 +406,6 @@ final class AccountContext implements Context
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PageInterface $page
|
||||
* @param string $element
|
||||
* @param string $expectedMessage
|
||||
*/
|
||||
private function assertFieldValidationMessage(PageInterface $page, $element, $expectedMessage)
|
||||
{
|
||||
Assert::true(
|
||||
$page->checkValidationMessageFor($element, $expectedMessage),
|
||||
sprintf('There should be a message: "%s".', $expectedMessage)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @When I subscribe to the newsletter
|
||||
*/
|
||||
|
|
@ -437,4 +424,39 @@ final class AccountContext implements Context
|
|||
'I should be subscribed to the newsletter, but I am not'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I should see :provinceName as province in the shipping address
|
||||
*/
|
||||
public function iShouldSeeAsProvinceInTheShippingAddress($provinceName)
|
||||
{
|
||||
Assert::true(
|
||||
$this->orderShowPage->hasShippingProvinceName($provinceName),
|
||||
sprintf('Cannot find shipping address with province %s', $provinceName)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @Then I should see :provinceName as province in the billing address
|
||||
*/
|
||||
public function iShouldSeeAsProvinceInTheBillingAddress($provinceName)
|
||||
{
|
||||
Assert::true(
|
||||
$this->orderShowPage->hasBillingProvinceName($provinceName),
|
||||
sprintf('Cannot find shipping address with province %s', $provinceName)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param PageInterface $page
|
||||
* @param string $element
|
||||
* @param string $expectedMessage
|
||||
*/
|
||||
private function assertFieldValidationMessage(PageInterface $page, $element, $expectedMessage)
|
||||
{
|
||||
Assert::true(
|
||||
$page->checkValidationMessageFor($element, $expectedMessage),
|
||||
sprintf('There should be a message: "%s".', $expectedMessage)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -99,6 +99,26 @@ class ShowPage extends SymfonyPage implements ShowPageInterface
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasShippingProvinceName($provinceName)
|
||||
{
|
||||
$shippingAddressText = $this->getElement('shipping_address')->getText();
|
||||
|
||||
return false !== stripos($shippingAddressText, $provinceName);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasBillingProvinceName($provinceName)
|
||||
{
|
||||
$billingAddressText = $this->getElement('billing_address')->getText();
|
||||
|
||||
return false !== stripos($billingAddressText, $provinceName);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -68,4 +68,18 @@ interface ShowPageInterface extends PageInterface
|
|||
* @return bool
|
||||
*/
|
||||
public function isSubscribedToNewsletter();
|
||||
|
||||
/**
|
||||
* @param string $provinceName
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasShippingProvinceName($provinceName);
|
||||
|
||||
/**
|
||||
* @param string $provinceName
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasBillingProvinceName($provinceName);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -345,6 +345,26 @@ class ShowPage extends SymfonyPage implements ShowPageInterface
|
|||
return $orderNotesElement->getText() === $note;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasShippingProvinceName($provinceName)
|
||||
{
|
||||
$shippingAddressText = $this->getElement('shipping_address')->getText();
|
||||
|
||||
return false !== stripos($shippingAddressText, $provinceName);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasBillingProvinceName($provinceName)
|
||||
{
|
||||
$billingAddressText = $this->getElement('billing_address')->getText();
|
||||
|
||||
return false !== stripos($billingAddressText, $provinceName);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -227,4 +227,18 @@ interface ShowPageInterface extends SymfonyPageInterface
|
|||
* @return bool
|
||||
*/
|
||||
public function hasNote($note);
|
||||
|
||||
/**
|
||||
* @param string $provinceName
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasShippingProvinceName($provinceName);
|
||||
|
||||
/**
|
||||
* @param string $provinceName
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasBillingProvinceName($provinceName);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -146,6 +146,26 @@ class ShowPage extends SymfonyPage implements ShowPageInterface
|
|||
return $this->getElement('product_price')->getText();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasShippingProvinceName($provinceName)
|
||||
{
|
||||
$shippingAddressText = $this->getElement('shipping_address')->getText();
|
||||
|
||||
return false !== stripos($shippingAddressText, $provinceName);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasBillingProvinceName($provinceName)
|
||||
{
|
||||
$billingAddressText = $this->getElement('billing_address')->getText();
|
||||
|
||||
return false !== stripos($billingAddressText, $provinceName);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -76,4 +76,18 @@ interface ShowPageInterface extends SymfonyPageInterface
|
|||
* @return string
|
||||
*/
|
||||
public function getItemPrice();
|
||||
|
||||
/**
|
||||
* @param string $provinceName
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasShippingProvinceName($provinceName);
|
||||
|
||||
/**
|
||||
* @param string $provinceName
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasBillingProvinceName($provinceName);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -104,12 +104,17 @@ class AddressPage extends SymfonyPage implements AddressPageInterface
|
|||
$this->getElement('shipping_country')->selectOption($shippingAddress->getCountryCode() ?: 'Select');
|
||||
$this->getElement('shipping_city')->setValue($shippingAddress->getCity());
|
||||
$this->getElement('shipping_postcode')->setValue($shippingAddress->getPostcode());
|
||||
|
||||
if ($shippingAddress->getProvinceName()) {
|
||||
$this->waitForShippingProvinceInput();
|
||||
$this->getElement('shipping_province')->setValue($shippingAddress->getProvinceName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function specifyShippingAddressProvince($province)
|
||||
public function selectShippingAddressProvince($province)
|
||||
{
|
||||
$this->waitForShippingProvinceSelector();
|
||||
$this->getElement('shipping_country_province')->selectOption($province);
|
||||
|
|
@ -126,12 +131,17 @@ class AddressPage extends SymfonyPage implements AddressPageInterface
|
|||
$this->getElement('billing_country')->selectOption($billingAddress->getCountryCode() ?: 'Select');
|
||||
$this->getElement('billing_city')->setValue($billingAddress->getCity());
|
||||
$this->getElement('billing_postcode')->setValue($billingAddress->getPostcode());
|
||||
|
||||
if ($billingAddress->getProvinceName()) {
|
||||
$this->waitForBillingProvinceInput();
|
||||
$this->getElement('billing_province')->setValue($billingAddress->getProvinceName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function specifyBillingAddressProvince($province)
|
||||
public function selectBillingAddressProvince($province)
|
||||
{
|
||||
$this->waitForBillingProvinceSelector();
|
||||
$this->getElement('billing_country_province')->selectOption($province);
|
||||
|
|
@ -202,19 +212,54 @@ class AddressPage extends SymfonyPage implements AddressPageInterface
|
|||
$this->getDocument()->clickLink('Back to store');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function specifyBillingAddressProvince($provinceName)
|
||||
{
|
||||
$this->waitForBillingProvinceInput();
|
||||
$this->getElement('billing_province')->setValue($provinceName);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function specifyShippingAddressProvince($provinceName)
|
||||
{
|
||||
$this->waitForShippingProvinceInput();
|
||||
$this->getElement('shipping_province')->setValue($provinceName);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasShippingAddressInput()
|
||||
{
|
||||
return $this->waitForShippingProvinceInput();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasBillingAddressInput()
|
||||
{
|
||||
return $this->waitForBillingProvinceInput();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getDefinedElements()
|
||||
{
|
||||
return array_merge(parent::getDefinedElements(), [
|
||||
'billing_first_name' => '#sylius_checkout_address_billingAddress_firstName',
|
||||
'billing_last_name' => '#sylius_checkout_address_billingAddress_lastName',
|
||||
'billing_street' => '#sylius_checkout_address_billingAddress_street',
|
||||
'billing_city' => '#sylius_checkout_address_billingAddress_city',
|
||||
'billing_country' => '#sylius_checkout_address_billingAddress_countryCode',
|
||||
'billing_country_province' => '[name="sylius_checkout_address[billingAddress][provinceCode]"]',
|
||||
'billing_first_name' => '#sylius_checkout_address_billingAddress_firstName',
|
||||
'billing_last_name' => '#sylius_checkout_address_billingAddress_lastName',
|
||||
'billing_postcode' => '#sylius_checkout_address_billingAddress_postcode',
|
||||
'billing_street' => '#sylius_checkout_address_billingAddress_street',
|
||||
'billing_province' => '[name="sylius_checkout_address[billingAddress][provinceName]"]',
|
||||
'checkout_subtotal' => '#checkout-subtotal',
|
||||
'customer_email' => '#sylius_checkout_address_customer_email',
|
||||
'different_billing_address' => '#sylius_checkout_address_differentBillingAddress',
|
||||
|
|
@ -228,6 +273,7 @@ class AddressPage extends SymfonyPage implements AddressPageInterface
|
|||
'shipping_first_name' => '#sylius_checkout_address_shippingAddress_firstName',
|
||||
'shipping_last_name' => '#sylius_checkout_address_shippingAddress_lastName',
|
||||
'shipping_postcode' => '#sylius_checkout_address_shippingAddress_postcode',
|
||||
'shipping_province' => '[name="sylius_checkout_address[shippingAddress][provinceName]"]',
|
||||
'shipping_street' => '#sylius_checkout_address_shippingAddress_street',
|
||||
]);
|
||||
}
|
||||
|
|
@ -259,6 +305,9 @@ class AddressPage extends SymfonyPage implements AddressPageInterface
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
private function waitForLoginAction()
|
||||
{
|
||||
$this->getDocument()->waitFor(5, function () {
|
||||
|
|
@ -266,6 +315,9 @@ class AddressPage extends SymfonyPage implements AddressPageInterface
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
private function waitForShippingProvinceSelector()
|
||||
{
|
||||
return $this->getDocument()->waitFor(5, function () {
|
||||
|
|
@ -273,10 +325,33 @@ class AddressPage extends SymfonyPage implements AddressPageInterface
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
private function waitForBillingProvinceSelector()
|
||||
{
|
||||
return $this->getDocument()->waitFor(5, function () {
|
||||
return $this->hasElement('billing_country_province');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
private function waitForShippingProvinceInput()
|
||||
{
|
||||
return $this->getDocument()->waitFor(5, function () {
|
||||
return $this->hasElement('shipping_province');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
private function waitForBillingProvinceInput()
|
||||
{
|
||||
return $this->getDocument()->waitFor(10, function () {
|
||||
return $this->hasElement('billing_province');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ interface AddressPageInterface extends SymfonyPageInterface
|
|||
/**
|
||||
* @param string $province
|
||||
*/
|
||||
public function specifyBillingAddressProvince($province);
|
||||
public function selectBillingAddressProvince($province);
|
||||
|
||||
/**
|
||||
* @param AddressInterface $shippingAddress
|
||||
|
|
@ -55,7 +55,7 @@ interface AddressPageInterface extends SymfonyPageInterface
|
|||
/**
|
||||
* @param string $province
|
||||
*/
|
||||
public function specifyShippingAddressProvince($province);
|
||||
public function selectShippingAddressProvince($province);
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
|
|
@ -84,4 +84,24 @@ interface AddressPageInterface extends SymfonyPageInterface
|
|||
public function nextStep();
|
||||
|
||||
public function backToStore();
|
||||
|
||||
/**
|
||||
* @param string $provinceName
|
||||
*/
|
||||
public function specifyBillingAddressProvince($provinceName);
|
||||
|
||||
/**
|
||||
* @param string $provinceName
|
||||
*/
|
||||
public function specifyShippingAddressProvince($provinceName);
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasShippingAddressInput();
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasBillingAddressInput();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -239,6 +239,26 @@ class CompletePage extends SymfonyPage implements CompletePageInterface
|
|||
$this->getElement('payment_step_label')->click();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasShippingProvinceName($provinceName)
|
||||
{
|
||||
$shippingAddressText = $this->getElement('shipping_address')->getText();
|
||||
|
||||
return false !== stripos($shippingAddressText, $provinceName);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function hasBillingProvinceName($provinceName)
|
||||
{
|
||||
$billingAddressText = $this->getElement('billing_address')->getText();
|
||||
|
||||
return false !== stripos($billingAddressText, $provinceName);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -142,4 +142,18 @@ interface CompletePageInterface extends SymfonyPageInterface
|
|||
public function changePaymentMethod();
|
||||
|
||||
public function confirmOrder();
|
||||
|
||||
/**
|
||||
* @param string $provinceName
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasShippingProvinceName($provinceName);
|
||||
|
||||
/**
|
||||
* @param string $provinceName
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function hasBillingProvinceName($provinceName);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
namespace Sylius\Behat\Page\Shop\Checkout;
|
||||
|
||||
use Behat\Mink\Driver\Selenium2Driver;
|
||||
use Behat\Mink\Exception\ElementNotFoundException;
|
||||
use Sylius\Behat\Page\SymfonyPage;
|
||||
|
||||
|
|
@ -32,8 +33,16 @@ class SelectPaymentPage extends SymfonyPage implements SelectPaymentPageInterfac
|
|||
*/
|
||||
public function selectPaymentMethod($paymentMethod)
|
||||
{
|
||||
if ($this->getDriver() instanceof Selenium2Driver) {
|
||||
$paymentMethodOption = $this->getElement('payment_method_select');
|
||||
$paymentMethodOption->getParent()->click();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$paymentMethodElement = $this->getElement('payment_method');
|
||||
$paymentMethodElement->selectOption($paymentMethodElement->getAttribute('value'));
|
||||
$paymentMethodValue = $this->getElement('payment_method_option', ['%payment_method%' => $paymentMethod])->getAttribute('value');
|
||||
$paymentMethodElement->selectOption($paymentMethodValue);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -94,6 +103,7 @@ class SelectPaymentPage extends SymfonyPage implements SelectPaymentPageInterfac
|
|||
'order_cannot_be_paid_message' => '#sylius-order-cannot-be-paid',
|
||||
'payment_method' => '[name="sylius_checkout_select_payment[payments][0][method]"]',
|
||||
'payment_method_option' => '.item:contains("%payment_method%") input',
|
||||
'payment_method_select' => '#sylius_checkout_select_payment_payments_0_method_0',
|
||||
'shipping_step_label' => '.steps a:contains("Shipping")',
|
||||
]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
|
||||
namespace Sylius\Behat\Page\Shop\Checkout;
|
||||
|
||||
use Behat\Mink\Driver\Selenium2Driver;
|
||||
use Behat\Mink\Exception\ElementNotFoundException;
|
||||
use Sylius\Behat\Page\SymfonyPage;
|
||||
|
||||
|
|
@ -32,6 +33,13 @@ class SelectShippingPage extends SymfonyPage implements SelectShippingPageInterf
|
|||
*/
|
||||
public function selectShippingMethod($shippingMethod)
|
||||
{
|
||||
if ($this->getDriver() instanceof Selenium2Driver) {
|
||||
$shippingMethodOption = $this->getElement('shipping_method_select');
|
||||
$shippingMethodOption->getParent()->click();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$shippingMethodElement = $this->getElement('shipping_method');
|
||||
$shippingMethodValue = $this->getElement('shipping_method_option', ['%shipping_method%' => $shippingMethod])->getAttribute('value');
|
||||
|
||||
|
|
@ -116,6 +124,8 @@ class SelectShippingPage extends SymfonyPage implements SelectShippingPageInterf
|
|||
'shipping_method' => '[name="sylius_checkout_select_shipping[shipments][0][method]"]',
|
||||
'shipping_method_fee' => '.item:contains("%shipping_method%") .fee',
|
||||
'shipping_method_option' => '.item:contains("%shipping_method%") input',
|
||||
'shipping_method_select' => '#sylius_checkout_select_shipping_shipments_0_method_0',
|
||||
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@
|
|||
"countryCode": {},
|
||||
"street": {},
|
||||
"city": {},
|
||||
"postcode": {}
|
||||
"postcode": {},
|
||||
"provinceName": {}
|
||||
}
|
||||
},
|
||||
"billingAddress": {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue