12
12
use Magento \Quote \Model \Quote ;
13
13
use Magento \Quote \Model \QuoteIdToMaskedQuoteIdInterface ;
14
14
use Magento \Quote \Model \ResourceModel \Quote as QuoteResource ;
15
+ use Magento \Config \Model \ResourceModel \Config ;
15
16
16
17
class AddSimpleProductToCartTest extends GraphQlAbstract
17
18
{
@@ -30,6 +31,11 @@ class AddSimpleProductToCartTest extends GraphQlAbstract
30
31
*/
31
32
private $ quoteIdToMaskedId ;
32
33
34
+ /**
35
+ * @var Config
36
+ */
37
+ private $ config ;
38
+
33
39
/**
34
40
* @inheritdoc
35
41
*/
@@ -39,6 +45,7 @@ protected function setUp()
39
45
$ this ->quoteResource = $ objectManager ->get (QuoteResource::class);
40
46
$ this ->quote = $ objectManager ->create (Quote::class);
41
47
$ this ->quoteIdToMaskedId = $ objectManager ->get (QuoteIdToMaskedQuoteIdInterface::class);
48
+ $ this ->config = $ objectManager ->get (Config::class);
42
49
}
43
50
44
51
/**
@@ -60,15 +67,18 @@ public function testAddSimpleProductsToCart()
60
67
61
68
/**
62
69
* @magentoApiDataFixture Magento/Catalog/_files/products.php
70
+
63
71
* @magentoApiDataFixture Magento/Checkout/_files/active_quote.php
64
72
* @expectedException \Exception
65
- * @expectedExceptionMessage The requested qty is not available
73
+ * @expectedExceptionMessage The most you may purchase is 5.
66
74
*/
67
- public function testAddProductIfQuantityIsNotAvailable ()
75
+ public function testAddMoreProductsThatAllowed ()
68
76
{
69
77
$ sku = 'simple ' ;
70
- $ qty = 200 ;
78
+ $ qty = 7 ;
79
+ $ maxQty = 5 ;
71
80
81
+ $ this ->config ->saveConfig ('cataloginventory/item_options/max_sale_qty ' , $ maxQty , 'default ' , 0 );
72
82
$ maskedQuoteId = $ this ->getMaskedQuoteId ();
73
83
$ query = $ this ->getQueryAddSimpleProduct ($ maskedQuoteId , $ sku , $ qty );
74
84
$ this ->graphQlQuery ($ query );
@@ -78,23 +88,23 @@ public function testAddProductIfQuantityIsNotAvailable()
78
88
* @magentoApiDataFixture Magento/Catalog/_files/products.php
79
89
* @magentoApiDataFixture Magento/Checkout/_files/active_quote.php
80
90
* @expectedException \Exception
81
- * @expectedExceptionMessage The most you may purchase is 10000.
91
+ * @expectedExceptionMessage The requested qty is not available
82
92
*/
83
- public function testAddMoreProductsThatAllowed ()
93
+ public function testAddProductIfQuantityIsNotAvailable ()
84
94
{
85
- $ sku = 'simple-product-with-huge-amount ' ;
86
- $ qty = 20000 ;
95
+ $ sku = 'simple ' ;
96
+ $ qty = 200 ;
97
+
87
98
$ maskedQuoteId = $ this ->getMaskedQuoteId ();
88
99
$ query = $ this ->getQueryAddSimpleProduct ($ maskedQuoteId , $ sku , $ qty );
89
100
$ this ->graphQlQuery ($ query );
90
101
}
91
102
92
103
/**
93
- * @magentoApiDataFixture Magento/Checkout/_files/active_quote.php
94
104
* @return string
95
105
* @throws \Magento\Framework\Exception\NoSuchEntityException
96
106
*/
97
- public function getMaskedQuoteId ()
107
+ public function getMaskedQuoteId () : string
98
108
{
99
109
$ this ->quoteResource ->load (
100
110
$ this ->quote ,
0 commit comments