@@ -28,6 +28,13 @@ class AddSimpleProductToCartTest extends GraphQlAbstract
28
28
*/
29
29
private $ getMaskedQuoteIdByReservedOrderId ;
30
30
31
+ protected function setUp ()
32
+ {
33
+ $ objectManager = Bootstrap::getObjectManager ();
34
+ $ this ->customerTokenService = $ objectManager ->get (CustomerTokenServiceInterface::class);
35
+ $ this ->getMaskedQuoteIdByReservedOrderId = $ objectManager ->get (GetMaskedQuoteIdByReservedOrderId::class);
36
+ }
37
+
31
38
/**
32
39
* @magentoApiDataFixture Magento/Customer/_files/customer.php
33
40
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
@@ -49,40 +56,39 @@ public function testAddSimpleProductToCart()
49
56
/**
50
57
* @magentoApiDataFixture Magento/Customer/_files/customer.php
51
58
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
59
+ *
60
+ * @expectedException \Exception
61
+ * @expectedExceptionMessage Could not find a cart with ID "non_existent_masked_id"
52
62
*/
53
63
public function testAddProductToNonExistentCart ()
54
64
{
55
65
$ sku = 'simple_product ' ;
56
66
$ qty = 2 ;
57
67
$ maskedQuoteId = 'non_existent_masked_id ' ;
58
- $ query = $ this ->getQuery ($ maskedQuoteId , $ sku , $ qty );
59
-
60
- $ this ->expectExceptionMessage (
61
- "Could not find a cart with ID \"$ maskedQuoteId \""
62
- );
63
68
69
+ $ query = $ this ->getQuery ($ maskedQuoteId , $ sku , $ qty );
64
70
$ this ->graphQlMutation ($ query , [], '' , $ this ->getHeaderMap ());
65
71
}
66
72
67
73
/**
68
74
* @magentoApiDataFixture Magento/Customer/_files/customer.php
69
75
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer/create_empty_cart.php
76
+ *
77
+ * @expectedException \Exception
78
+ * @expectedExceptionMessage Could not find a product with SKU "simple_product"
70
79
*/
71
80
public function testNonExistentProductToCart ()
72
81
{
73
82
$ sku = 'simple_product ' ;
74
83
$ qty = 2 ;
75
84
$ maskedQuoteId = $ this ->getMaskedQuoteIdByReservedOrderId ->execute ('test_quote ' );
76
- $ query = $ this ->getQuery ($ maskedQuoteId , $ sku , $ qty );
77
-
78
- $ this ->expectExceptionMessage (
79
- "Could not find a product with SKU \"simple_product \""
80
- );
81
85
86
+ $ query = $ this ->getQuery ($ maskedQuoteId , $ sku , $ qty );
82
87
$ this ->graphQlMutation ($ query , [], '' , $ this ->getHeaderMap ());
83
88
}
84
89
85
90
/**
91
+ * _security
86
92
* @magentoApiDataFixture Magento/Customer/_files/customer.php
87
93
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
88
94
* @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest/create_empty_cart.php
@@ -102,9 +108,10 @@ public function testAddSimpleProductToGuestCart()
102
108
}
103
109
104
110
/**
111
+ * _security
105
112
* @magentoApiDataFixture Magento/Customer/_files/three_customers.php
106
113
* @magentoApiDataFixture Magento/GraphQl/Catalog/_files/simple_product.php
107
- * @magentoApiDataFixture Magento/GraphQl/Quote/_files/guest /create_empty_cart.php
114
+ * @magentoApiDataFixture Magento/GraphQl/Quote/_files/customer /create_empty_cart.php
108
115
*/
109
116
public function testAddSimpleProductToAnotherCustomerCart ()
110
117
{
@@ -120,15 +127,10 @@ public function testAddSimpleProductToAnotherCustomerCart()
120
127
$ this ->graphQlMutation ($ query , [], '' , $ this ->getHeaderMap ('customer2@search.example.com ' ));
121
128
}
122
129
123
- protected function setUp ()
124
- {
125
- $ objectManager = Bootstrap::getObjectManager ();
126
- $ this ->customerTokenService = $ objectManager ->get (CustomerTokenServiceInterface::class);
127
- $ this ->getMaskedQuoteIdByReservedOrderId = $ objectManager ->get (GetMaskedQuoteIdByReservedOrderId::class);
128
- }
129
-
130
130
/**
131
131
* @param string $maskedQuoteId
132
+ * @param string $sku
133
+ * @param int $qty
132
134
* @return string
133
135
*/
134
136
private function getQuery (string $ maskedQuoteId , string $ sku , int $ qty ): string
@@ -140,8 +142,8 @@ private function getQuery(string $maskedQuoteId, string $sku, int $qty): string
140
142
cartItems: [
141
143
{
142
144
data: {
143
- qty: $ qty
144
- sku: " $ sku"
145
+ qty: { $ qty}
146
+ sku: " { $ sku} "
145
147
}
146
148
}
147
149
]
0 commit comments