Skip to content

Commit 2d87219

Browse files
changes requested; add out stock product to cart test
1 parent 39ade1f commit 2d87219

File tree

1 file changed

+29
-5
lines changed

1 file changed

+29
-5
lines changed

dev/tests/api-functional/testsuite/Magento/GraphQl/Quote/Guest/AddSimpleProductToCartTest.php

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,24 +80,48 @@ public function testAddSimpleProductToCart()
8080
self::assertEquals('USD', $rowTotalIncludingTax['currency']);
8181
}
8282

83+
/**
84+
* Add disabled product to cart
85+
*
86+
* @magentoApiDataFixture Magento/Catalog/_files/multiple_products.php
87+
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
88+
* @return void
89+
*/
90+
public function testAddDisabledProductToCart(): void
91+
{
92+
$sku = 'simple3';
93+
$quantity = 2;
94+
95+
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
96+
$query = $this->getQuery($maskedQuoteId, $sku, $quantity);
97+
98+
$this->expectException(ResponseContainsErrorsException::class);
99+
$this->expectExceptionMessage(
100+
'Could not add the product with SKU ' . $sku . ' to the shopping cart: ' .
101+
'Product that you are trying to add is not available.'
102+
);
103+
104+
$this->graphQlMutation($query);
105+
}
106+
83107
/**
84108
* Add out of stock product to cart
85109
*
86-
* @@magentoApiDataFixture Magento/Catalog/_files/multiple_products.php
110+
* @magentoApiDataFixture Magento/Catalog/_files/product_virtual_out_of_stock.php
87111
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
88112
* @return void
89113
*/
90-
public function testAddProductToCartWithError(): void
114+
public function testAddOutOfStockProductToCart(): void
91115
{
92-
$disabledProductSku = 'simple3';
116+
$sku = 'virtual-product-out';
93117
$quantity = 2;
94118

95119
$maskedQuoteId = $this->getMaskedQuoteIdByReservedOrderId->execute('test_quote');
96-
$query = $this->getQuery($maskedQuoteId, $disabledProductSku, $quantity);
120+
$query = $this->getQuery($maskedQuoteId, $sku, $quantity);
97121

98122
$this->expectException(ResponseContainsErrorsException::class);
99123
$this->expectExceptionMessage(
100-
'Could not add the product with SKU simple3 to the shopping cart: ' .
124+
'Could not add the product with SKU ' . $sku . ' to the shopping cart: ' .
101125
'Product that you are trying to add is not available.'
102126
);
103127

0 commit comments

Comments
 (0)