@@ -90,10 +90,8 @@ public function testGetLoggedInCustomerCartWithoutMaskedQuoteId()
90
90
*/
91
91
public function testGetNewCustomerCart ()
92
92
{
93
- $ customerToken = $ this ->generateCustomerToken ();
94
93
$ customerCartQuery = $ this ->getCustomerCartQuery ();
95
- $ headers = ['Authorization ' => 'Bearer ' . $ customerToken ];
96
- $ response = $ this ->graphQlQuery ($ customerCartQuery , [], '' , $ headers );
94
+ $ response = $ this ->graphQlQuery ($ customerCartQuery , [], '' , $ this ->getHeaderMap ());
97
95
$ this ->assertArrayHasKey ('customerCart ' , $ response );
98
96
$ this ->assertArrayHasKey ('id ' , $ response ['customerCart ' ]);
99
97
$ this ->assertNotNull ($ response ['customerCart ' ]['id ' ]);
@@ -118,22 +116,20 @@ public function testGetCustomerCartWithNoCustomerToken()
118
116
* Query for customer cart after customer token is revoked
119
117
*
120
118
* @magentoApiDataFixture Magento/Customer/_files/customer.php
119
+ * @expectedException \Exception
120
+ * @expectedExceptionMessage The request is allowed for logged in customer
121
121
*/
122
122
public function testGetCustomerCartAfterTokenRevoked ()
123
123
{
124
- $ customerToken = $ this ->generateCustomerToken ();
125
- $ headers = ['Authorization ' => 'Bearer ' . $ customerToken ];
126
124
$ customerCartQuery = $ this ->getCustomerCartQuery ();
125
+ $ headers = $ this ->getHeaderMap ();
127
126
$ response = $ this ->graphQlMutation ($ customerCartQuery , [], '' , $ headers );
128
127
$ this ->assertArrayHasKey ('customerCart ' , $ response );
129
128
$ this ->assertArrayHasKey ('id ' , $ response ['customerCart ' ]);
130
129
$ this ->assertNotNull ($ response ['customerCart ' ]['id ' ]);
131
130
$ this ->assertNotEmpty ($ response ['customerCart ' ]['id ' ]);
132
131
$ this ->revokeCustomerToken ();
133
132
$ customerCartQuery = $ this ->getCustomerCartQuery ();
134
- $ this ->expectExceptionMessage (
135
- 'The request is allowed for logged in customer '
136
- );
137
133
$ this ->graphQlQuery ($ customerCartQuery , [], '' , $ headers );
138
134
}
139
135
@@ -144,16 +140,14 @@ public function testGetCustomerCartAfterTokenRevoked()
144
140
*/
145
141
public function testRequestCustomerCartTwice ()
146
142
{
147
- $ customerToken = $ this ->generateCustomerToken ();
148
- $ headers = ['Authorization ' => 'Bearer ' . $ customerToken ];
149
143
$ customerCartQuery = $ this ->getCustomerCartQuery ();
150
- $ response = $ this ->graphQlMutation ($ customerCartQuery , [], '' , $ headers );
144
+ $ response = $ this ->graphQlMutation ($ customerCartQuery , [], '' , $ this -> getHeaderMap () );
151
145
$ this ->assertArrayHasKey ('customerCart ' , $ response );
152
146
$ this ->assertArrayHasKey ('id ' , $ response ['customerCart ' ]);
153
147
$ this ->assertNotNull ($ response ['customerCart ' ]['id ' ]);
154
148
$ cartId = $ response ['customerCart ' ]['id ' ];
155
149
$ customerCartQuery = $ this ->getCustomerCartQuery ();
156
- $ response2 = $ this ->graphQlQuery ($ customerCartQuery , [], '' , $ headers );
150
+ $ response2 = $ this ->graphQlQuery ($ customerCartQuery , [], '' , $ this -> getHeaderMap () );
157
151
$ this ->assertEquals ($ cartId , $ response2 ['customerCart ' ]['id ' ]);
158
152
}
159
153
@@ -192,31 +186,6 @@ public function testGetCustomerCartSecondStore()
192
186
$ this ->assertEquals ($ maskedQuoteIdSecondStore , $ responseSecondStore ['customerCart ' ]['id ' ]);
193
187
}
194
188
195
- /**
196
- * Query to generate customer token
197
- *
198
- * @return string
199
- */
200
- private function generateCustomerToken (): string
201
- {
202
- $ query = <<<QUERY
203
- mutation {
204
- generateCustomerToken(
205
-
206
- password: "password"
207
- ) {
208
- token
209
- }
210
- }
211
- QUERY ;
212
- $ response = $ this ->graphQlMutation ($ query );
213
- self ::assertArrayHasKey ('generateCustomerToken ' , $ response );
214
- self ::assertArrayHasKey ('token ' , $ response ['generateCustomerToken ' ]);
215
- self ::assertNotEmpty ($ response ['generateCustomerToken ' ]['token ' ]);
216
-
217
- return $ response ['generateCustomerToken ' ]['token ' ];
218
- }
219
-
220
189
/**
221
190
* Query to revoke customer token
222
191
*
@@ -232,8 +201,7 @@ private function revokeCustomerToken(): void
232
201
}
233
202
QUERY ;
234
203
235
- $ response = $ this ->graphQlMutation ($ query , [], '' , $ this ->getHeaderMap ());
236
- $ this ->assertTrue ($ response ['revokeCustomerToken ' ]['result ' ]);
204
+ $ this ->graphQlMutation ($ query , [], '' , $ this ->getHeaderMap ());
237
205
}
238
206
239
207
/**
0 commit comments