@@ -68,9 +68,12 @@ public function testCheckSessionCookieWithGetCategoryList(): void
68
68
}
69
69
QUERY ;
70
70
// Using cURL feature of flushing cookies upon completion of request
71
- $ this ->graphQlClient ->getWithResponseHeaders ($ query , [], '' , [], true );
71
+ $ result = $ this ->graphQlClient ->getWithResponseHeaders ($ query , [], '' , [], true );
72
+ $ this ->assertEmpty ($ result ['cookies ' ]);
72
73
// perform secondary request after cookies have been flushed
73
74
$ result = $ this ->graphQlClient ->getWithResponseHeaders ($ query , [], '' , []);
75
+
76
+ // may have other cookies than session
74
77
$ this ->assertNotEmpty ($ result ['cookies ' ]);
75
78
$ this ->assertAnyCookieMatchesRegex ('/PHPSESSID=[a-z0-9]+;/ ' , $ result ['cookies ' ]);
76
79
$ this ->assertCount (1 , $ result ['body ' ]['categoryList ' ]);
@@ -100,9 +103,12 @@ public function testCheckSessionCookieNotPresentWithGetCategoryList(): void
100
103
QUERY ;
101
104
// CURL flushes cookies only upon completion of the request is the flag is set
102
105
// perform graphql request with flushing cookies upon completion
103
- $ this ->graphQlClient ->getWithResponseHeaders ($ query , [], '' , [], true );
106
+ $ result = $ this ->graphQlClient ->getWithResponseHeaders ($ query , [], '' , [], true );
107
+ $ this ->assertEmpty ($ result ['cookies ' ]);
108
+
104
109
// perform secondary request after cookies have been flushed
105
110
$ result = $ this ->graphQlClient ->getWithResponseHeaders ($ query , [], '' , []);
111
+
106
112
// may have other cookies than session
107
113
$ this ->assertNoCookiesMatchRegex ('/PHPSESSID=[a-z0-9]+;/ ' , $ result ['cookies ' ]);
108
114
$ this ->assertCount (1 , $ result ['body ' ]['categoryList ' ]);
@@ -121,8 +127,14 @@ public function testSessionStartsInAddProductToCartMutation()
121
127
$ maskedQuoteId = $ this ->getMaskedQuoteIdByReservedOrderId ->execute ('test_quote ' );
122
128
$ query = $ this ->getQuery ($ maskedQuoteId , $ sku , $ quantity );
123
129
124
- $ this ->graphQlClient ->postWithResponseHeaders ($ query , [], '' , $ this ->getAuthHeaders (), true );
130
+ $ result = $ this ->graphQlClient ->postWithResponseHeaders ($ query , [], '' , $ this ->getAuthHeaders (), true );
131
+ // cookies are never empty and session is restarted for the authorized customer regardless current session
132
+ $ this ->assertNotEmpty ($ result ['cookies ' ]);
133
+ $ this ->assertAnyCookieMatchesRegex ('/PHPSESSID=[a-z0-9]+;/ ' , $ result ['cookies ' ]);
125
134
$ result = $ this ->graphQlClient ->postWithResponseHeaders ($ query , [], '' , $ this ->getAuthHeaders ());
135
+
136
+ // cookies are never empty and session is restarted for the authorized customer
137
+ // regardless current session and missing flush
126
138
$ this ->assertNotEmpty ($ result ['cookies ' ]);
127
139
$ this ->assertAnyCookieMatchesRegex ('/PHPSESSID=[a-z0-9]+;/ ' , $ result ['cookies ' ]);
128
140
}
@@ -140,8 +152,11 @@ public function testSessionDoesNotStartInAddProductToCartMutation()
140
152
$ maskedQuoteId = $ this ->getMaskedQuoteIdByReservedOrderId ->execute ('test_quote ' );
141
153
$ query = $ this ->getQuery ($ maskedQuoteId , $ sku , $ quantity );
142
154
143
- $ this ->graphQlClient ->postWithResponseHeaders ($ query , [], '' , $ this ->getAuthHeaders (), true );
155
+ $ result = $ this ->graphQlClient ->postWithResponseHeaders ($ query , [], '' , $ this ->getAuthHeaders (), true );
156
+ // cookies may be empty or contain page cache private content version
157
+ $ this ->assertNoCookiesMatchRegex ('/PHPSESSID=[a-z0-9]+;/ ' , $ result ['cookies ' ]);
144
158
$ result = $ this ->graphQlClient ->postWithResponseHeaders ($ query , [], '' , $ this ->getAuthHeaders ());
159
+ // cookies may be empty or contain page cache private content version
145
160
$ this ->assertNoCookiesMatchRegex ('/PHPSESSID=[a-z0-9]+;/ ' , $ result ['cookies ' ]);
146
161
}
147
162
0 commit comments