Skip to content

Commit

Permalink
adding company and phoneNumber to checkout/address
Browse files Browse the repository at this point in the history
  • Loading branch information
hashnz committed May 2, 2019
1 parent 6e25aa8 commit 762ecd7
Show file tree
Hide file tree
Showing 10 changed files with 65 additions and 11 deletions.
4 changes: 4 additions & 0 deletions spec/Factory/AddressBook/AddressViewFactorySpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ function it_creates_address_view(AddressInterface $address): void
$address->getCity()->willReturn('London');
$address->getPostcode()->willReturn('NMW');
$address->getProvinceName()->willReturn('Greater London');
$address->getCompany()->willReturn('Detective Inc');
$address->getPhoneNumber()->willReturn('999');

$addressView = new AddressView();
$addressView->firstName = 'Sherlock';
Expand All @@ -39,6 +41,8 @@ function it_creates_address_view(AddressInterface $address): void
$addressView->city = 'London';
$addressView->postcode = 'NMW';
$addressView->provinceName = 'Greater London';
$addressView->company = 'Detective Inc';
$addressView->phoneNumber = '999';

$this->create($address)->shouldBeLike($addressView);
}
Expand Down
16 changes: 16 additions & 0 deletions spec/Handler/Cart/AddressOrderHandlerSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ function it_handles_order_shipment_addressing(
$shippingAddress->setCountryCode('GB')->shouldBeCalled();
$shippingAddress->setPostcode('NWB')->shouldBeCalled();
$shippingAddress->setProvinceName('Greater London')->shouldBeCalled();
$shippingAddress->setCompany('Detective Inc')->shouldBeCalled();
$shippingAddress->setPhoneNumber('999')->shouldBeCalled();

$billingAddress->setFirstName('John')->shouldBeCalled();
$billingAddress->setLastName('Watson')->shouldBeCalled();
Expand All @@ -52,6 +54,8 @@ function it_handles_order_shipment_addressing(
$billingAddress->setCountryCode('GB')->shouldBeCalled();
$billingAddress->setPostcode('NWB')->shouldBeCalled();
$billingAddress->setProvinceName('Greater London')->shouldBeCalled();
$billingAddress->setCompany('Detective Corp')->shouldBeCalled();
$billingAddress->setPhoneNumber('111')->shouldBeCalled();

$order->setShippingAddress($shippingAddress)->shouldBeCalled();
$order->setBillingAddress($billingAddress)->shouldBeCalled();
Expand All @@ -70,6 +74,8 @@ function it_handles_order_shipment_addressing(
'countryCode' => 'GB',
'postcode' => 'NWB',
'provinceName' => 'Greater London',
'company' => 'Detective Inc',
'phoneNumber' => '999',
]),
Address::createFromArray([
'firstName' => 'John',
Expand All @@ -79,6 +85,8 @@ function it_handles_order_shipment_addressing(
'countryCode' => 'GB',
'postcode' => 'NWB',
'provinceName' => 'Greater London',
'company' => 'Detective Corp',
'phoneNumber' => '111',
])
));
}
Expand All @@ -105,6 +113,8 @@ function it_does_not_create_new_addresses_for_already_addressed_order(
$shippingAddress->setCountryCode('GB')->shouldBeCalled();
$shippingAddress->setPostcode('NWB')->shouldBeCalled();
$shippingAddress->setProvinceName('Greater London')->shouldBeCalled();
$shippingAddress->setCompany('Detective Inc')->shouldBeCalled();
$shippingAddress->setPhoneNumber('999')->shouldBeCalled();

$billingAddress->setFirstName('John')->shouldBeCalled();
$billingAddress->setLastName('Watson')->shouldBeCalled();
Expand All @@ -113,6 +123,8 @@ function it_does_not_create_new_addresses_for_already_addressed_order(
$billingAddress->setCountryCode('GB')->shouldBeCalled();
$billingAddress->setPostcode('NWB')->shouldBeCalled();
$billingAddress->setProvinceName('Greater London')->shouldBeCalled();
$billingAddress->setCompany('Detective Corp')->shouldBeCalled();
$billingAddress->setPhoneNumber('111')->shouldBeCalled();

$order->setShippingAddress($shippingAddress)->shouldBeCalled();
$order->setBillingAddress($billingAddress)->shouldBeCalled();
Expand All @@ -131,6 +143,8 @@ function it_does_not_create_new_addresses_for_already_addressed_order(
'countryCode' => 'GB',
'postcode' => 'NWB',
'provinceName' => 'Greater London',
'company' => 'Detective Inc',
'phoneNumber' => '999',
]),
Address::createFromArray([
'firstName' => 'John',
Expand All @@ -140,6 +154,8 @@ function it_does_not_create_new_addresses_for_already_addressed_order(
'countryCode' => 'GB',
'postcode' => 'NWB',
'provinceName' => 'Greater London',
'company' => 'Detective Corp',
'phoneNumber' => '111',
])
));
}
Expand Down
2 changes: 2 additions & 0 deletions src/Factory/AddressBook/AddressViewFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ public function create(AddressInterface $address): AddressView
$addressView->city = $address->getCity();
$addressView->postcode = $address->getPostcode();
$addressView->provinceName = $address->getProvinceName();
$addressView->company = $address->getCompany();
$addressView->phoneNumber = $address->getPhoneNumber();

return $addressView;
}
Expand Down
4 changes: 4 additions & 0 deletions src/Handler/Cart/AddressOrderHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public function __invoke(AddressOrder $addressOrder): void
$shippingAddress->setCountryCode($addressOrder->shippingAddress()->countryCode());
$shippingAddress->setPostcode($addressOrder->shippingAddress()->postcode());
$shippingAddress->setProvinceName($addressOrder->shippingAddress()->provinceName());
$shippingAddress->setCompany($addressOrder->shippingAddress()->company());
$shippingAddress->setPhoneNumber($addressOrder->shippingAddress()->phoneNumber());

/** @var AddressInterface $billingAddress */
$billingAddress = $order->getBillingAddress() ?? $this->addressFactory->createNew();
Expand All @@ -66,6 +68,8 @@ public function __invoke(AddressOrder $addressOrder): void
$billingAddress->setCountryCode($addressOrder->billingAddress()->countryCode());
$billingAddress->setPostcode($addressOrder->billingAddress()->postcode());
$billingAddress->setProvinceName($addressOrder->billingAddress()->provinceName());
$billingAddress->setCompany($addressOrder->billingAddress()->company());
$billingAddress->setPhoneNumber($addressOrder->billingAddress()->phoneNumber());

$order->setShippingAddress($shippingAddress);
$order->setBillingAddress($billingAddress);
Expand Down
6 changes: 6 additions & 0 deletions src/View/AddressBook/AddressView.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,10 @@ class AddressView

/** @var string */
public $provinceName;

/** @var string */
public $company;

/** @var string */
public $phoneNumber;
}
12 changes: 9 additions & 3 deletions tests/Controller/Checkout/CheckoutSummarizeApiTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ public function it_shows_an_order_with_same_shipping_and_billing_address_with_pr
"street": "Baker Street 221b",
"city": "London",
"postcode": "NW1",
"provinceName": "Greater London"
"provinceName": "Greater London",
"company": "Detective Inc",
"phoneNumber": "999"
}
}
EOT;
Expand Down Expand Up @@ -78,7 +80,9 @@ public function it_shows_an_order_with_different_shipping_and_billing_address_wi
"street": "Baker Street 221b",
"city": "London",
"postcode": "NW1",
"provinceName": "Greater London"
"provinceName": "Greater London",
"company": "Detective Inc",
"phoneNumber": "999"
},
"billingAddress": {
"firstName": "John",
Expand All @@ -87,7 +91,9 @@ public function it_shows_an_order_with_different_shipping_and_billing_address_wi
"street": "Baker Street 21b",
"city": "London",
"postcode": "NW1",
"provinceName": "Greater London"
"provinceName": "Greater London",
"company": "Detective Corp",
"phoneNumber": "111"
}
}
EOT;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@
"street": "Baker Street 221b",
"city": "London",
"postcode": "NW1",
"provinceName": "Greater London"
"provinceName": "Greater London",
"company": "Detective Inc",
"phoneNumber": "999"
},
"billingAddress": {
"firstName": "Sherlock",
Expand All @@ -81,7 +83,9 @@
"street": "Baker Street 221b",
"city": "London",
"postcode": "NW1",
"provinceName": "Greater London"
"provinceName": "Greater London",
"company": "Detective Inc",
"phoneNumber": "999"
},
"payments": [],
"shipments": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@
"street": "Baker Street 221b",
"city": "London",
"postcode": "NW1",
"provinceName": "Greater London"
"provinceName": "Greater London",
"company": "Detective Inc",
"phoneNumber": "999"
},
"billingAddress": {
"firstName": "John",
Expand All @@ -81,7 +83,9 @@
"street": "Baker Street 21b",
"city": "London",
"postcode": "NW1",
"provinceName": "Greater London"
"provinceName": "Greater London",
"company": "Detective Corp",
"phoneNumber": "111"
},
"payments": [],
"shipments": [],
Expand Down
8 changes: 6 additions & 2 deletions tests/Responses/Expected/order/order_details_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,15 +71,19 @@
"countryCode": "GB",
"street": "McGlynn Island",
"city": "Klingside",
"postcode": "33553"
"postcode": "33553",
"company": "Sylius",
"phoneNumber": "349713"
},
"billingAddress": {
"firstName": "Jeanie",
"lastName": "Metz",
"countryCode": "GB",
"street": "Kupreska",
"city": "Klingside",
"postcode": "33553"
"postcode": "33553",
"company": "Locastic",
"phoneNumber": "349713"
},
"payments": [
{
Expand Down
8 changes: 6 additions & 2 deletions tests/Responses/Expected/order/orders_list_response.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,19 @@
"countryCode": "GB",
"street": "McGlynn Island",
"city": "Klingside",
"postcode": "33553"
"postcode": "33553",
"company": "Sylius",
"phoneNumber": "349713"
},
"billingAddress": {
"firstName": "Jeanie",
"lastName": "Metz",
"countryCode": "GB",
"street": "Kupreska",
"city": "Klingside",
"postcode": "33553"
"postcode": "33553",
"company": "Locastic",
"phoneNumber": "349713"
},
"payments": [
{
Expand Down

0 comments on commit 762ecd7

Please sign in to comment.