@@ -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,45 @@ 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 ' )
186
+ ->willReturn (trim ($ post ['oar_billing_lastname ' ]));
187
+ $ billingAddressMock ->expects ($ this ->any ())->method ('getEmail ' )->willReturn (trim ($ post ['oar_email ' ]));
188
+ $ billingAddressMock ->expects ($ this ->any ())->method ('getPostcode ' )->willReturn (trim ($ post ['oar_zip ' ]));
174
189
$ this ->salesOrderMock ->expects ($ this ->once ())->method ('getBillingAddress ' )->willReturn ($ billingAddressMock );
175
190
$ this ->salesOrderMock ->expects ($ this ->once ())->method ('getProtectCode ' )->willReturn ($ protectedCode );
176
191
$ metaDataMock = $ this ->createMock (PublicCookieMetadata::class);
@@ -190,17 +205,69 @@ public function testLoadValidOrderNotEmptyPost()
190
205
$ this ->assertTrue ($ this ->guest ->loadValidOrder ($ requestMock ));
191
206
}
192
207
208
+ /**
209
+ * Load valid order with non empty post data provider.
210
+ *
211
+ * @return array
212
+ */
213
+ public function loadValidOrderNotEmptyPostDataProvider ()
214
+ {
215
+ return [
216
+ [
217
+ [
218
+ 'oar_order_id ' => '1 ' ,
219
+ 'oar_type ' => 'email ' ,
220
+ 'oar_billing_lastname ' => 'White ' ,
221
+ 'oar_email ' => 'test@magento-test.com ' ,
222
+ 'oar_zip ' => '' ,
223
+
224
+ ]
225
+ ],
226
+ [
227
+ [
228
+ 'oar_order_id ' => ' 14 ' ,
229
+ 'oar_type ' => 'email ' ,
230
+ 'oar_billing_lastname ' => 'Black ' ,
231
+ 'oar_email ' => ' test1@magento-test.com ' ,
232
+ 'oar_zip ' => '' ,
233
+ ]
234
+ ],
235
+ [
236
+ [
237
+ 'oar_order_id ' => ' 14 ' ,
238
+ 'oar_type ' => 'zip ' ,
239
+ 'oar_billing_lastname ' => 'Black ' ,
240
+ 'oar_email ' => ' test1@magento-test.com ' ,
241
+ 'oar_zip ' => '123456 ' ,
242
+ ]
243
+ ]
244
+ ];
245
+ }
246
+
193
247
public function testLoadValidOrderStoredCookie ()
194
248
{
195
249
$ protectedCode = 'protectedCode ' ;
196
- $ incrementId = 1 ;
250
+ $ incrementId = ' 1 ' ;
197
251
$ cookieData = $ protectedCode . ': ' . $ incrementId ;
198
252
$ cookieDataHash = base64_encode ($ cookieData );
199
253
$ this ->sessionMock ->expects ($ this ->once ())->method ('isLoggedIn ' )->willReturn (false );
200
254
$ this ->cookieManagerMock ->expects ($ this ->once ())
201
255
->method ('getCookie ' )
202
256
->with (Guest::COOKIE_NAME )
203
257
->willReturn ($ cookieDataHash );
258
+
259
+ $ this ->searchCriteriaBuilder
260
+ ->expects ($ this ->at (0 ))
261
+ ->method ('addFilter ' )
262
+ ->with ('increment_id ' , trim ($ incrementId ))
263
+ ->willReturnSelf ();
264
+
265
+ $ this ->searchCriteriaBuilder
266
+ ->expects ($ this ->at (1 ))
267
+ ->method ('addFilter ' )
268
+ ->with ('store_id ' , $ this ->storeModelMock ->getId ())
269
+ ->willReturnSelf ();
270
+
204
271
$ this ->salesOrderMock ->expects ($ this ->any ())->method ('getId ' )->willReturn ($ incrementId );
205
272
$ this ->salesOrderMock ->expects ($ this ->once ())->method ('getProtectCode ' )->willReturn ($ protectedCode );
206
273
$ metaDataMock = $ this ->createMock (PublicCookieMetadata::class);
0 commit comments