1212use Magento \Quote \Model \Quote ;
1313use Magento \Quote \Model \QuoteIdToMaskedQuoteIdInterface ;
1414use Magento \Quote \Model \ResourceModel \Quote as QuoteResource ;
15+ use Magento \Config \Model \ResourceModel \Config ;
1516
1617class AddSimpleProductToCartTest extends GraphQlAbstract
1718{
@@ -30,6 +31,11 @@ class AddSimpleProductToCartTest extends GraphQlAbstract
3031 */
3132 private $ quoteIdToMaskedId ;
3233
34+ /**
35+ * @var Config
36+ */
37+ private $ config ;
38+
3339 /**
3440 * @inheritdoc
3541 */
@@ -39,6 +45,7 @@ protected function setUp()
3945 $ this ->quoteResource = $ objectManager ->get (QuoteResource::class);
4046 $ this ->quote = $ objectManager ->create (Quote::class);
4147 $ this ->quoteIdToMaskedId = $ objectManager ->get (QuoteIdToMaskedQuoteIdInterface::class);
48+ $ this ->config = $ objectManager ->get (Config::class);
4249 }
4350
4451 /**
@@ -60,15 +67,18 @@ public function testAddSimpleProductsToCart()
6067
6168 /**
6269 * @magentoApiDataFixture Magento/Catalog/_files/products.php
70+
6371 * @magentoApiDataFixture Magento/Checkout/_files/active_quote.php
6472 * @expectedException \Exception
65- * @expectedExceptionMessage The requested qty is not available
73+ * @expectedExceptionMessage The most you may purchase is 5.
6674 */
67- public function testAddProductIfQuantityIsNotAvailable ()
75+ public function testAddMoreProductsThatAllowed ()
6876 {
6977 $ sku = 'simple ' ;
70- $ qty = 200 ;
78+ $ qty = 7 ;
79+ $ maxQty = 5 ;
7180
81+ $ this ->config ->saveConfig ('cataloginventory/item_options/max_sale_qty ' , $ maxQty , 'default ' , 0 );
7282 $ maskedQuoteId = $ this ->getMaskedQuoteId ();
7383 $ query = $ this ->getQueryAddSimpleProduct ($ maskedQuoteId , $ sku , $ qty );
7484 $ this ->graphQlQuery ($ query );
@@ -78,23 +88,23 @@ public function testAddProductIfQuantityIsNotAvailable()
7888 * @magentoApiDataFixture Magento/Catalog/_files/products.php
7989 * @magentoApiDataFixture Magento/Checkout/_files/active_quote.php
8090 * @expectedException \Exception
81- * @expectedExceptionMessage The most you may purchase is 10000.
91+ * @expectedExceptionMessage The requested qty is not available
8292 */
83- public function testAddMoreProductsThatAllowed ()
93+ public function testAddProductIfQuantityIsNotAvailable ()
8494 {
85- $ sku = 'simple-product-with-huge-amount ' ;
86- $ qty = 20000 ;
95+ $ sku = 'simple ' ;
96+ $ qty = 200 ;
97+
8798 $ maskedQuoteId = $ this ->getMaskedQuoteId ();
8899 $ query = $ this ->getQueryAddSimpleProduct ($ maskedQuoteId , $ sku , $ qty );
89100 $ this ->graphQlQuery ($ query );
90101 }
91102
92103 /**
93- * @magentoApiDataFixture Magento/Checkout/_files/active_quote.php
94104 * @return string
95105 * @throws \Magento\Framework\Exception\NoSuchEntityException
96106 */
97- public function getMaskedQuoteId ()
107+ public function getMaskedQuoteId () : string
98108 {
99109 $ this ->quoteResource ->load (
100110 $ this ->quote ,
0 commit comments