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

Commit

Permalink
146 - [Cart Operations] Add downloadable product to Cart
Browse files Browse the repository at this point in the history
1. Scenario #3 test coverage
  • Loading branch information
atwixfirster committed Mar 12, 2019
1 parent e9505cf commit ae310e6
Showing 1 changed file with 73 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ protected function setUp()
}

/**
* Test adding a downloadable product to the shopping cart
* Add a downloadable product into shopping cart when "Links can be purchased separately" is enabled
*
* @magentoApiDataFixture Magento/GraphQl/_files/product_downloadable_with_purchased_separately_links.php
* @magentoApiDataFixture Magento/Checkout/_files/active_quote.php
Expand Down Expand Up @@ -116,6 +116,78 @@ public function testAddDownloadableProductWithCustomLinks()
);
}

/**
* Add a downloadable product into shopping cart when "Links can be purchased separately" is enabled
* There is the same value in couple of `link_id` options
*
* @magentoApiDataFixture Magento/GraphQl/_files/product_downloadable_with_purchased_separately_links.php
* @magentoApiDataFixture Magento/Checkout/_files/active_quote.php
*/
public function testAddDownloadableProductWithCustomLinks2()
{
$this->quoteResource->load(
$this->quote,
'test_order_1',
'reserved_order_id'
);
$maskedQuoteId = $this->quoteIdToMaskedId->execute((int)$this->quote->getId());

$sku = 'graphql-downloadable-product-with-purchased-separately-links';
$qty = 1;
$links = $this->getProductsLinks($sku);
$linkId = key($links);

$query = <<<MUTATION
mutation {
addDownloadableProductsToCart(
input: {
cart_id: "{$maskedQuoteId}",
cartItems: [
{
data: {
qty: {$qty},
sku: "{$sku}"
},
downloadable_product_links: [
{
link_id: {$linkId}
}
{
link_id: {$linkId}
}
]
}
]
}
) {
cart {
items {
qty
... on DownloadableCartItem {
downloadable_product_links {
title
link_type
price
}
downloadable_product_samples {
id
title
}
}
}
}
}
}
MUTATION;
$response = $this->graphQlQuery($query);
self::assertArrayHasKey('items', $response['addDownloadableProductsToCart']['cart']);
self::assertCount($qty, $response['addDownloadableProductsToCart']['cart']);
self::assertEquals(
$links[$linkId],
$response['addDownloadableProductsToCart']['cart']['items'][0]['downloadable_product_links'][0]
);
}

/**
* Test adding a downloadable product to the shopping cart
*
Expand Down

0 comments on commit ae310e6

Please sign in to comment.