@@ -28,9 +28,6 @@ class GetCustomerCartTest extends GraphQlAbstract
28
28
*/
29
29
private $ customerTokenService ;
30
30
31
- /** @var array */
32
- private $ headers ;
33
-
34
31
protected function setUp ()
35
32
{
36
33
$ objectManager = Bootstrap::getObjectManager ();
@@ -74,8 +71,8 @@ public function testGetNewCustomerCart()
74
71
{
75
72
$ customerToken = $ this ->generateCustomerToken ();
76
73
$ customerCartQuery = $ this ->getCustomerCartQuery ();
77
- $ this -> headers = ['Authorization ' => 'Bearer ' . $ customerToken ];
78
- $ response = $ this ->graphQlQuery ($ customerCartQuery , [], '' , $ this -> headers );
74
+ $ headers = ['Authorization ' => 'Bearer ' . $ customerToken ];
75
+ $ response = $ this ->graphQlQuery ($ customerCartQuery , [], '' , $ headers );
79
76
$ this ->assertArrayHasKey ('customerCart ' , $ response );
80
77
$ this ->assertArrayHasKey ('cart_id ' , $ response ['customerCart ' ]);
81
78
$ this ->assertNotNull ($ response ['customerCart ' ]['cart_id ' ]);
@@ -103,9 +100,9 @@ public function testGetCustomerCartWithNoCustomerToken()
103
100
public function testGetCustomerCartAfterTokenRevoked ()
104
101
{
105
102
$ customerToken = $ this ->generateCustomerToken ();
106
- $ this -> headers = ['Authorization ' => 'Bearer ' . $ customerToken ];
103
+ $ headers = ['Authorization ' => 'Bearer ' . $ customerToken ];
107
104
$ customerCartQuery = $ this ->getCustomerCartQuery ();
108
- $ response = $ this ->graphQlMutation ($ customerCartQuery , [], '' , $ this -> headers );
105
+ $ response = $ this ->graphQlMutation ($ customerCartQuery , [], '' , $ headers );
109
106
$ this ->assertArrayHasKey ('customerCart ' , $ response );
110
107
$ this ->assertArrayHasKey ('cart_id ' , $ response ['customerCart ' ]);
111
108
$ this ->assertNotNull ($ response ['customerCart ' ]['cart_id ' ]);
@@ -114,7 +111,7 @@ public function testGetCustomerCartAfterTokenRevoked()
114
111
$ this ->expectExceptionMessage (
115
112
'The request is allowed for logged in customer '
116
113
);
117
- $ this ->graphQlQuery ($ customerCartQuery , [], '' , $ this -> headers );
114
+ $ this ->graphQlQuery ($ customerCartQuery , [], '' , $ headers );
118
115
}
119
116
120
117
/**
@@ -125,15 +122,15 @@ public function testGetCustomerCartAfterTokenRevoked()
125
122
public function testRequestCustomerCartTwice ()
126
123
{
127
124
$ customerToken = $ this ->generateCustomerToken ();
128
- $ this -> headers = ['Authorization ' => 'Bearer ' . $ customerToken ];
125
+ $ headers = ['Authorization ' => 'Bearer ' . $ customerToken ];
129
126
$ customerCartQuery = $ this ->getCustomerCartQuery ();
130
- $ response = $ this ->graphQlMutation ($ customerCartQuery , [], '' , $ this -> headers );
127
+ $ response = $ this ->graphQlMutation ($ customerCartQuery , [], '' , $ headers );
131
128
$ this ->assertArrayHasKey ('customerCart ' , $ response );
132
129
$ this ->assertArrayHasKey ('cart_id ' , $ response ['customerCart ' ]);
133
130
$ this ->assertNotNull ($ response ['customerCart ' ]['cart_id ' ]);
134
131
$ cartId = $ response ['customerCart ' ]['cart_id ' ];
135
132
$ customerCartQuery = $ this ->getCustomerCartQuery ();
136
- $ response2 = $ this ->graphQlQuery ($ customerCartQuery , [], '' , $ this -> headers );
133
+ $ response2 = $ this ->graphQlQuery ($ customerCartQuery , [], '' , $ headers );
137
134
$ this ->assertEquals ($ cartId , $ response2 ['customerCart ' ]['cart_id ' ]);
138
135
}
139
136
@@ -173,6 +170,8 @@ public function testGetCustomerCartSecondStore()
173
170
}
174
171
175
172
/**
173
+ * Query to generate customer token
174
+ *
176
175
* @return string
177
176
*/
178
177
private function generateCustomerToken (): string
@@ -195,7 +194,12 @@ private function generateCustomerToken(): string
195
194
return $ response ['generateCustomerToken ' ]['token ' ];
196
195
}
197
196
198
- private function revokeCustomerToken ()
197
+ /**
198
+ * Query to revoke customer token
199
+ *
200
+ * @return void
201
+ */
202
+ private function revokeCustomerToken (): void
199
203
{
200
204
$ query = <<<QUERY
201
205
mutation{
@@ -210,7 +214,8 @@ private function revokeCustomerToken()
210
214
}
211
215
212
216
/**
213
- * @param string $maskedQuoteId
217
+ * Query customer cart
218
+ *
214
219
* @return string
215
220
*/
216
221
private function getCustomerCartQuery (): string
@@ -233,6 +238,8 @@ private function getCustomerCartQuery(): string
233
238
}
234
239
235
240
/**
241
+ * Create a header with customer token
242
+ *
236
243
* @param string $username
237
244
* @param string $password
238
245
* @return array
0 commit comments