@@ -101,7 +101,7 @@ protected function setUp()
101
101
false ,
102
102
true ,
103
103
true ,
104
- ['getPost ' ]
104
+ ['getPost ' , ' getParam ' ]
105
105
);
106
106
$ this ->response = $ this ->getMockForAbstractClass (
107
107
\Magento \Framework \App \ResponseInterface::class,
@@ -169,6 +169,17 @@ public function testExecute()
169
169
'_template_ ' => null ,
170
170
'address_index ' => null
171
171
]);
172
+ $ customerEntityId = 2 ;
173
+ $ this ->request ->expects ($ this ->once ())
174
+ ->method ('getParam ' )
175
+ ->with ('customer ' )
176
+ ->willReturn ([
177
+ 'entity_id ' => $ customerEntityId
178
+ ]);
179
+
180
+ $ this ->customer ->expects ($ this ->once ())
181
+ ->method ('setId ' )
182
+ ->with ($ customerEntityId );
172
183
173
184
$ this ->form ->expects ($ this ->once ())->method ('setInvisibleIgnored ' );
174
185
$ this ->form ->expects ($ this ->atLeastOnce ())->method ('extractData ' )->willReturn ([]);
@@ -273,4 +284,47 @@ public function testExecuteWithException()
273
284
274
285
$ this ->controller ->execute ();
275
286
}
287
+
288
+ public function testExecuteWithNewCustomerAndNoEntityId ()
289
+ {
290
+ $ this ->request ->expects ($ this ->once ())
291
+ ->method ('getPost ' )
292
+ ->willReturn ([
293
+ '_template_ ' => null ,
294
+ 'address_index ' => null
295
+ ]);
296
+ $ this ->request ->expects ($ this ->once ())
297
+ ->method ('getParam ' )
298
+ ->with ('customer ' )
299
+ ->willReturn ([]);
300
+
301
+ $ this ->customer ->expects ($ this ->never ())
302
+ ->method ('setId ' );
303
+
304
+ $ this ->form ->expects ($ this ->once ())->method ('setInvisibleIgnored ' );
305
+ $ this ->form ->expects ($ this ->atLeastOnce ())->method ('extractData ' )->willReturn ([]);
306
+
307
+ $ error = $ this ->getMock (\Magento \Framework \Message \Error::class, [], [], '' , false );
308
+ $ this ->form ->expects ($ this ->once ())
309
+ ->method ('validateData ' )
310
+ ->willReturn ([$ error ]);
311
+
312
+ $ validationResult = $ this ->getMockForAbstractClass (
313
+ \Magento \Customer \Api \Data \ValidationResultsInterface::class,
314
+ [],
315
+ '' ,
316
+ false ,
317
+ true ,
318
+ true
319
+ );
320
+ $ validationResult ->expects ($ this ->once ())
321
+ ->method ('getMessages ' )
322
+ ->willReturn (['Error message ' ]);
323
+
324
+ $ this ->customerAccountManagement ->expects ($ this ->once ())
325
+ ->method ('validate ' )
326
+ ->willReturn ($ validationResult );
327
+
328
+ $ this ->controller ->execute ();
329
+ }
276
330
}
0 commit comments