Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add additional Behat features for checkout #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
@house_number_checkout
Feature: Addressing an order
In order to address an order
As a Customer
I want to be able to fill addressing details

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 I am a logged in customer

@ui
Scenario: Address an order without different billing address
Given I have product "PHP T-Shirt" in the cart
And I am at the checkout addressing step
When I specify the shipping address extended as "Ankh Morpork", "Frost Alley", "12", "a", "90210", "United States" for "Jon Snow"
And I complete the addressing step
Then I should be on the checkout shipping step

@ui
Scenario: Address an order without different billing address with optional addition
Given I have product "PHP T-Shirt" in the cart
And I am at the checkout addressing step
When I specify the shipping address extended as "Ankh Morpork", "Frost Alley", "12", "", "90210", "United States" for "Jon Snow"
And I complete the addressing step
Then I should be on the checkout shipping step

@ui
Scenario: Address an order with different billing address
Given I have product "PHP T-Shirt" in the cart
And I am at the checkout addressing step
When I specify the shipping address extended as "Ankh Morpork", "Frost Alley", "14", "a", "90210", "United States" for "Jon Snow"
And I specify the billing address extended as "Ankh Morpork", "Frost Alley", "28", "b", "90210", "United States" for "Eddard Stark"
And I complete the addressing step
Then I should be on the checkout shipping step

@ui
Scenario: Address an order with different billing address with optional addition
Given I have product "PHP T-Shirt" in the cart
And I am at the checkout addressing step
When I specify the shipping address extended as "Ankh Morpork", "Frost Alley", "14", "", "90210", "United States" for "Jon Snow"
And I specify the billing address extended as "Ankh Morpork", "Frost Alley", "28", "", "90210", "United States" for "Eddard Stark"
And I complete the addressing step
Then I should be on the checkout shipping step
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
@house_number_checkout
Feature: Addressing an order
In order to address an order
As a Guest
I want to be able to fill extended addressing details

Background:
Given the store operates on a single channel in "United States"
And the store ships everywhere for free
And the store has a product "PHP T-Shirt" priced at "$19.99"

@ui
Scenario: Address an order without different billing address
Given I have product "PHP T-Shirt" in the cart
And I am at the checkout addressing step
When I specify the email as "[email protected]"
And I specify the shipping address extended as "Ankh Morpork", "Frost Alley", "12", "a", "90210", "United States" for "Jon Snow"
And I complete the addressing step
Then I should be on the checkout shipping step

@ui
Scenario: Address an order without different billing address with optional addition
Given I have product "PHP T-Shirt" in the cart
And I am at the checkout addressing step
When I specify the email as "[email protected]"
And I specify the shipping address extended as "Ankh Morpork", "Frost Alley", "12", "", "90210", "United States" for "Jon Snow"
And I complete the addressing step
Then I should be on the checkout shipping step

@ui
Scenario: Address an order with different billing address with optional addition
Given I have product "PHP T-Shirt" in the cart
And I am at the checkout addressing step
When I specify the email as "[email protected]"
And I specify the shipping address extended as "Ankh Morpork", "Frost Alley", "12", "", "90210", "United States" for "Jon Snow"
And I specify the billing address extended as "Ankh Morpork", "Frost Alley", "14", "", "90210", "United States" for "Eddard Stark"
And I complete the addressing step
Then I should be on the checkout shipping step
22 changes: 22 additions & 0 deletions tests/Behat/Context/Transform/AddressContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,28 @@ public function createNewAddressWith($city, $street, $postcode, $countryName, $c
]);
}

/**
* @Transform /^address extended (?:as |is |to )"([^"]+)", ([^"]+)", ([^"]+)", "([^"]+)", "([^"]+)", "([^"]+)" for "([^"]+)"$/
*/
public function createNewExtendedAddressWith($city, $street, $number, $addition, $postcode, $countryName, $customerName)
{
[$firstName, $lastName] = explode(' ', $customerName);

return $this->exampleAddressFactory->create([
'country_code' => $this->countryNameConverter->convertToCode($countryName),
'first_name' => $firstName,
'last_name' => $lastName,
'company' => null,
'customer' => null,
'phone_number' => null,
'city' => $city,
'street' => $street,
'postcode' => $postcode,
'number' => $number,
'addition' => $addition,
]);
}

/**
* @Transform /^clear old (shipping|billing) address$/
* @Transform /^do not specify any (shipping|billing) address$/
Expand Down
30 changes: 30 additions & 0 deletions tests/Behat/Context/Ui/Shop/Checkout/CheckoutAddressingContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,36 @@ public function __construct(
$this->selectShippingPage = $selectShippingPage;
}

/**
* @When /^I specify the shipping (address extended as "[^"]+", "[^"]+", "[^"]+", "[^"]+", "[^"]+", "[^"]+" for "[^"]+")$/
*/
public function iSpecifyTheShippingAddressAs(AddressInterface $address)
{
$key = sprintf(
'shipping_address_%s_%s',
strtolower((string) $address->getFirstName()),
strtolower((string) $address->getLastName())
);
$this->sharedStorage->set($key, $address);

$this->addressPage->specifyShippingAddress($address);
}

/**
* @When /^I specify the billing (address extended as "[^"]+", "[^"]+", "[^"]+", "[^"]+", "[^"]+", "[^"]+" for "[^"]+")$/
*/
public function iSpecifyTheBillingAddressAs(AddressInterface $address)
{
$key = sprintf(
'billing_address_%s_%s',
strtolower((string) $address->getFirstName()),
strtolower((string) $address->getLastName())
);
$this->sharedStorage->set($key, $address);

$this->addressPage->specifyBillingAddress($address);
}

/**
* @Then /^I should be notified that the street number in (shipping|billing) details is required$/
*/
Expand Down