Skip to content
This repository has been archived by the owner on Dec 19, 2019. It is now read-only.

Commit

Permalink
GraphQL-631: Schema inconsistency of "Quantity / Qty" declaration
Browse files Browse the repository at this point in the history
  • Loading branch information
naydav committed Apr 29, 2019
1 parent 109182e commit c44df1c
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class CartAddressTypeResolver implements TypeResolverInterface
/**
* @inheritdoc
*/
public function resolveType(array $data) : string
public function resolveType(array $data): string
{
if (!isset($data['model'])) {
throw new LocalizedException(__('Missing key "model" in cart address data'));
Expand All @@ -33,7 +33,7 @@ public function resolveType(array $data) : string
} elseif ($address->getAddressType() == AbstractAddress::TYPE_BILLING) {
$addressType = 'BillingCartAddress';
} else {
throw new LocalizedException( __('Unsupported cart address type'));
throw new LocalizedException(__('Unsupported cart address type'));
}
return $addressType;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ public function testAddMoreProductsThatAllowed()
* @expectedException \Exception
* @expectedExceptionMessage Please enter a number greater than 0 in this field.
*/
public function testAddSimpleProductToCartWithNegativeQty()
public function testAddSimpleProductToCartWithNegativeQuantity()
{
$sku = 'simple';
$qty = -2;
$quantity = -2;
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_order_1');

$query = $this->getQuery($maskedQuoteId, $sku, $qty);
$query = $this->getQuery($maskedQuoteId, $sku, $quantity);
$this->graphQlMutation($query);
}

Expand All @@ -88,10 +88,10 @@ public function testAddSimpleProductToCartWithNegativeQty()
public function testAddProductIfQuantityIsDecimal()
{
$sku = 'simple_product';
$qty = 0.2;
$quantity = 0.2;

$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
$query = $this->getQuery($maskedQuoteId, $sku, $qty);
$query = $this->getQuery($maskedQuoteId, $sku, $quantity);

$this->expectExceptionMessage(
"Could not add the product with SKU {$sku} to the shopping cart: The fewest you may purchase is 1"
Expand All @@ -102,10 +102,10 @@ public function testAddProductIfQuantityIsDecimal()
/**
* @param string $maskedQuoteId
* @param string $sku
* @param float $qty
* @param float $quantity
* @return string
*/
private function getQuery(string $maskedQuoteId, string $sku, float $qty) : string
private function getQuery(string $maskedQuoteId, string $sku, float $quantity) : string
{
return <<<QUERY
mutation {
Expand All @@ -115,7 +115,7 @@ private function getQuery(string $maskedQuoteId, string $sku, float $qty) : stri
cartItems: [
{
data: {
quantity: $qty
quantity: $quantity
sku: "$sku"
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,26 +41,26 @@ protected function setUp()
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/add_simple_product.php
*/
public function testUpdateCartItemDecimalQty()
public function testUpdateCartItemDecimalQuantity()
{
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
$itemId = $this->getQuoteItemIdByReservedQuoteIdAndSku->execute('test_quote', 'simple_product');

$qty = 0.5;
$quantity = 0.5;
$this->expectExceptionMessage(
"Could not update the product with SKU simple_product: The fewest you may purchase is 1"
);
$query = $this->getQuery($maskedQuoteId, $itemId, $qty);
$query = $this->getQuery($maskedQuoteId, $itemId, $quantity);
$this->graphQlMutation($query);
}

/**
* @param string $maskedQuoteId
* @param int $itemId
* @param float $qty
* @param float $quantity
* @return string
*/
private function getQuery(string $maskedQuoteId, int $itemId, float $qty): string
private function getQuery(string $maskedQuoteId, int $itemId, float $quantity): string
{
return <<<QUERY
mutation {
Expand All @@ -69,14 +69,14 @@ private function getQuery(string $maskedQuoteId, int $itemId, float $qty): strin
cart_items:[
{
cart_item_id: {$itemId}
quantity: {$qty}
quantity: {$quantity}
}
]
}) {
cart {
items {
id
qty
quantity
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public function testGeSpecifiedBillingAddressIfBillingAddressIsNotSet()
'label' => null,
],
'telephone' => null,
'__typename' => 'BillingCartAddress',
'__typename' => null,
];
self::assertEquals($expectedBillingAddressData, $response['cart']['billing_address']);
}
Expand Down

0 comments on commit c44df1c

Please sign in to comment.