Skip to content

Commit

Permalink
Merge pull request #3810 from magento-engcom/graphql-develop-prs
Browse files Browse the repository at this point in the history
[EngCom] Public Pull Requests - GraphQL
  • Loading branch information
naydav authored Feb 26, 2019
2 parents 697978e + 20f85f1 commit e5b0392
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function execute(QuoteAddress $address): array
$addressData['model'] = $address;

$addressData = array_merge($addressData, [
'address_id' => $address->getId(),
'country' => [
'code' => $address->getCountryId(),
'label' => $address->getCountry()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public function execute(ContextInterface $context, CartInterface $cart, array $b
);
}
if (null === $customerAddressId) {
$addressInput['country_id'] = $addressInput['country_code'] ?? '';
$billingAddress = $this->addressModel->addData($addressInput);
} else {
$this->checkCustomerAccount->execute($context->getUserId(), $context->getUserType());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public function execute(ContextInterface $context, CartInterface $cart, array $s
);
}
if (null === $customerAddressId) {
$addressInput['country_id'] = $addressInput['country_code'] ?? '';
$shippingAddress = $this->addressModel->addData($addressInput);
} else {
$this->checkCustomerAccount->execute($context->getUserId(), $context->getUserType());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
if (!$shippingMethod['cart_address_id']) {
throw new GraphQlInputException(__('Required parameter "cart_address_id" is missing'));
}
if (!$shippingMethod['shipping_carrier_code']) {
if (!$shippingMethod['carrier_code']) {
throw new GraphQlInputException(__('Required parameter "shipping_carrier_code" is missing'));
}
if (!$shippingMethod['shipping_method_code']) {
if (!$shippingMethod['method_code']) {
throw new GraphQlInputException(__('Required parameter "shipping_method_code" is missing'));
}

Expand All @@ -85,8 +85,8 @@ public function resolve(Field $field, $context, ResolveInfo $info, array $value
$this->setShippingMethodOnCart->execute(
$cart,
$shippingMethod['cart_address_id'],
$shippingMethod['shipping_carrier_code'],
$shippingMethod['shipping_method_code']
$shippingMethod['carrier_code'],
$shippingMethod['method_code']
);

return [
Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/QuoteGraphQl/etc/schema.graphqls
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ type Cart {
}

type CartAddress {
address_id: Int
firstname: String
lastname: String
company: String
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ public function testSetNewBillingAddressByGuest()
city
postcode
telephone
country {
code
label
}
}
}
}
Expand Down Expand Up @@ -140,6 +144,10 @@ public function testSetNewBillingAddressWithUseForShippingParameterByGuest()
city
postcode
telephone
country {
code
label
}
}
shipping_addresses {
firstname
Expand All @@ -149,6 +157,10 @@ public function testSetNewBillingAddressWithUseForShippingParameterByGuest()
city
postcode
telephone
country {
code
label
}
}
}
}
Expand Down Expand Up @@ -234,6 +246,10 @@ public function testSetNewBillingAddressByRegisteredCustomer()
city
postcode
telephone
country {
code
label
}
}
}
}
Expand Down Expand Up @@ -413,7 +429,8 @@ private function assertNewAddressFields(array $billingAddressResponse): void
['response_field' => 'street', 'expected_value' => [0 => 'test street 1', 1 => 'test street 2']],
['response_field' => 'city', 'expected_value' => 'test city'],
['response_field' => 'postcode', 'expected_value' => '887766'],
['response_field' => 'telephone', 'expected_value' => '88776655']
['response_field' => 'telephone', 'expected_value' => '88776655'],
['response_field' => 'country', 'expected_value' => ['code' => 'US', 'label' => 'US']],
];

$this->assertResponseFields($billingAddressResponse, $assertionMap);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ public function testSetNewShippingAddressByGuest()
city
postcode
telephone
country {
code
label
}
}
}
}
Expand Down Expand Up @@ -176,6 +180,10 @@ public function testSetNewShippingAddressByRegisteredCustomer()
city
postcode
telephone
country {
label
code
}
}
}
}
Expand Down Expand Up @@ -462,7 +470,8 @@ private function assertNewShippingAddressFields(array $shippingAddressResponse):
['response_field' => 'street', 'expected_value' => [0 => 'test street 1', 1 => 'test street 2']],
['response_field' => 'city', 'expected_value' => 'test city'],
['response_field' => 'postcode', 'expected_value' => '887766'],
['response_field' => 'telephone', 'expected_value' => '88776655']
['response_field' => 'telephone', 'expected_value' => '88776655'],
['response_field' => 'country', 'expected_value' => ['code' => 'US', 'label' => 'US']],
];

$this->assertResponseFields($shippingAddressResponse, $assertionMap);
Expand Down

0 comments on commit e5b0392

Please sign in to comment.