@@ -112,7 +112,6 @@ protected function setUp(): void
112
112
->setMethods (['getTotalCount ' , 'getItems ' ])
113
113
->disableOriginalConstructor ()
114
114
->getMockForAbstractClass ();
115
- $ this ->searchCriteriaBuilder ->method ('addFilter ' )->willReturnSelf ();
116
115
$ resultRedirectFactory =
117
116
$ this ->getMockBuilder (RedirectFactory::class)
118
117
->setMethods (['create ' ])
@@ -148,29 +147,44 @@ protected function setUp(): void
148
147
);
149
148
}
150
149
151
- public function testLoadValidOrderNotEmptyPost ()
150
+ /**
151
+ * Test load valid order with non empty post data.
152
+ *
153
+ * @param array $post
154
+ * @dataProvider loadValidOrderNotEmptyPostDataProvider
155
+ * @throws \Magento\Framework\Exception\InputException
156
+ * @throws \Magento\Framework\Stdlib\Cookie\CookieSizeLimitReachedException
157
+ * @throws \Magento\Framework\Stdlib\Cookie\FailureToSendException
158
+ */
159
+ public function testLoadValidOrderNotEmptyPost ($ post )
152
160
{
153
- $ post = [
154
- 'oar_order_id ' => 1 ,
155
- 'oar_type ' => 'email ' ,
156
- 'oar_billing_lastname ' => 'oar_billing_lastname ' ,
157
- 'oar_email ' => 'oar_email ' ,
158
- 'oar_zip ' => 'oar_zip ' ,
159
-
160
- ];
161
161
$ incrementId = $ post ['oar_order_id ' ];
162
162
$ protectedCode = 'protectedCode ' ;
163
163
$ this ->sessionMock ->expects ($ this ->once ())->method ('isLoggedIn ' )->willReturn (false );
164
164
$ requestMock = $ this ->createMock (Http::class);
165
165
$ requestMock ->expects ($ this ->once ())->method ('getPostValue ' )->willReturn ($ post );
166
+
167
+ $ this ->searchCriteriaBuilder
168
+ ->expects ($ this ->at (0 ))
169
+ ->method ('addFilter ' )
170
+ ->with ('increment_id ' , trim ($ incrementId ))
171
+ ->willReturnSelf ();
172
+
173
+ $ this ->searchCriteriaBuilder
174
+ ->expects ($ this ->at (1 ))
175
+ ->method ('addFilter ' )
176
+ ->with ('store_id ' , $ this ->storeModelMock ->getId ())
177
+ ->willReturnSelf ();
178
+
166
179
$ this ->salesOrderMock ->expects ($ this ->any ())->method ('getId ' )->willReturn ($ incrementId );
167
180
168
181
$ billingAddressMock = $ this ->createPartialMock (
169
182
Address::class,
170
- ['getLastname ' , 'getEmail ' ]
183
+ ['getLastname ' , 'getEmail ' , ' getPostcode ' ]
171
184
);
172
- $ billingAddressMock ->expects ($ this ->once ())->method ('getLastname ' )->willReturn (($ post ['oar_billing_lastname ' ]));
173
- $ billingAddressMock ->expects ($ this ->once ())->method ('getEmail ' )->willReturn (($ post ['oar_email ' ]));
185
+ $ billingAddressMock ->expects ($ this ->once ())->method ('getLastname ' )->willReturn (trim ($ post ['oar_billing_lastname ' ]));
186
+ $ billingAddressMock ->expects ($ this ->any ())->method ('getEmail ' )->willReturn (trim ($ post ['oar_email ' ]));
187
+ $ billingAddressMock ->expects ($ this ->any ())->method ('getPostcode ' )->willReturn (trim ($ post ['oar_zip ' ]));
174
188
$ this ->salesOrderMock ->expects ($ this ->once ())->method ('getBillingAddress ' )->willReturn ($ billingAddressMock );
175
189
$ this ->salesOrderMock ->expects ($ this ->once ())->method ('getProtectCode ' )->willReturn ($ protectedCode );
176
190
$ metaDataMock = $ this ->createMock (PublicCookieMetadata::class);
@@ -190,17 +204,69 @@ public function testLoadValidOrderNotEmptyPost()
190
204
$ this ->assertTrue ($ this ->guest ->loadValidOrder ($ requestMock ));
191
205
}
192
206
207
+ /**
208
+ * Load valid order with non empty post data provider.
209
+ *
210
+ * @return array
211
+ */
212
+ public function loadValidOrderNotEmptyPostDataProvider ()
213
+ {
214
+ return [
215
+ [
216
+ [
217
+ 'oar_order_id ' => '1 ' ,
218
+ 'oar_type ' => 'email ' ,
219
+ 'oar_billing_lastname ' => 'White ' ,
220
+ 'oar_email ' => 'test@magento-test.com ' ,
221
+ 'oar_zip ' => '' ,
222
+
223
+ ]
224
+ ],
225
+ [
226
+ [
227
+ 'oar_order_id ' => ' 14 ' ,
228
+ 'oar_type ' => 'email ' ,
229
+ 'oar_billing_lastname ' => 'Black ' ,
230
+ 'oar_email ' => ' test1@magento-test.com ' ,
231
+ 'oar_zip ' => '' ,
232
+ ]
233
+ ],
234
+ [
235
+ [
236
+ 'oar_order_id ' => ' 14 ' ,
237
+ 'oar_type ' => 'zip ' ,
238
+ 'oar_billing_lastname ' => 'Black ' ,
239
+ 'oar_email ' => ' test1@magento-test.com ' ,
240
+ 'oar_zip ' => '123456 ' ,
241
+ ]
242
+ ]
243
+ ];
244
+ }
245
+
193
246
public function testLoadValidOrderStoredCookie ()
194
247
{
195
248
$ protectedCode = 'protectedCode ' ;
196
- $ incrementId = 1 ;
249
+ $ incrementId = ' 1 ' ;
197
250
$ cookieData = $ protectedCode . ': ' . $ incrementId ;
198
251
$ cookieDataHash = base64_encode ($ cookieData );
199
252
$ this ->sessionMock ->expects ($ this ->once ())->method ('isLoggedIn ' )->willReturn (false );
200
253
$ this ->cookieManagerMock ->expects ($ this ->once ())
201
254
->method ('getCookie ' )
202
255
->with (Guest::COOKIE_NAME )
203
256
->willReturn ($ cookieDataHash );
257
+
258
+ $ this ->searchCriteriaBuilder
259
+ ->expects ($ this ->at (0 ))
260
+ ->method ('addFilter ' )
261
+ ->with ('increment_id ' , trim ($ incrementId ))
262
+ ->willReturnSelf ();
263
+
264
+ $ this ->searchCriteriaBuilder
265
+ ->expects ($ this ->at (1 ))
266
+ ->method ('addFilter ' )
267
+ ->with ('store_id ' , $ this ->storeModelMock ->getId ())
268
+ ->willReturnSelf ();
269
+
204
270
$ this ->salesOrderMock ->expects ($ this ->any ())->method ('getId ' )->willReturn ($ incrementId );
205
271
$ this ->salesOrderMock ->expects ($ this ->once ())->method ('getProtectCode ' )->willReturn ($ protectedCode );
206
272
$ metaDataMock = $ this ->createMock (PublicCookieMetadata::class);
0 commit comments