Skip to content

Commit

Permalink
GraphQL-474: Cannot return null for non-nullable field SelectedCustom…
Browse files Browse the repository at this point in the history
…izableOptionValue.sort_order and Call to a member function getPriceType() on null
  • Loading branch information
naydav committed Apr 30, 2019
1 parent 1315577 commit b115f1c
Showing 1 changed file with 0 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,89 +46,6 @@ public function testAddProductIfQuantityIsNotAvailable()
$this->graphQlMutation($query);
}

/**
* @magentoApiDataFixture Magento/Catalog/_files/product_simple_with_custom_options.php
* @magentoApiDataFixture Magento/Checkout/_files/active_quote.php
* @expectedException \Exception
* @expectedExceptionMessage The product's required option(s) weren't entered. Make sure the options are entered and try again.
*/
public function testAddProductWithoutRequiredCustomOptions()
{
$sku = 'simple_with_custom_options';
$qty = 1;

$maskedQuoteId = $this->getMaskedQuoteId();
$query = $this->getAddSimpleProductQuery($maskedQuoteId, $sku, $qty);
$this->graphQlQuery($query);
}

/**
* @magentoApiDataFixture Magento/Catalog/_files/product_simple_with_custom_options.php
* @magentoApiDataFixture Magento/Checkout/_files/active_quote.php
*/
public function testAddProductWithRequiredCustomOptions()
{
$sku = 'simple_with_custom_options';
$qty = 1;
$productCustomOptions = Bootstrap::getObjectManager()
->get(\Magento\Catalog\Api\ProductCustomOptionRepositoryInterface::class)
->getList($sku);
$customizableOptions = '';
foreach ($productCustomOptions as $option) {
$value = $option->getValues() ?
'[' . key($option->getValues()) . ']' :
'Test';
$customizableOptions .= ' {
id: ' . $option->getId() . '
value: "' . $value . '"
}';
}

$maskedQuoteId = $this->getMaskedQuoteId();
$query = <<<QUERY
mutation {
addSimpleProductsToCart(
input: {
cart_id: "{$maskedQuoteId}"
cartItems: {
data: {
qty: {$qty}
sku: "{$sku}"
}
customizable_options: [
{$customizableOptions}
]
}
}
)
{
cart {
items {
product {
sku
}
... on SimpleCartItem {
customizable_options {
id
is_required
sort_order
}
}
}
}
}
}
QUERY;
$response = $this->graphQlQuery($query);
self::assertArrayHasKey('cart', $response['addSimpleProductsToCart']);

self::assertEquals($sku, $response['addSimpleProductsToCart']['cart']['items'][0]['product']['sku']);
self::assertEquals(
1,
$response['addSimpleProductsToCart']['cart']['items'][0]['customizable_options'][0]['is_required']
);
}

/**
* @magentoApiDataFixture Magento/Catalog/_files/products.php
* @magentoApiDataFixture Magento/Checkout/_files/active_quote.php
Expand Down

0 comments on commit b115f1c

Please sign in to comment.