@@ -246,4 +246,90 @@ function ($origName) {
246
246
247
247
return [$ attributeMock ];
248
248
}
249
+
250
+ public function testGetData ()
251
+ {
252
+ $ customer = $ this ->getMockBuilder ('Magento\Customer\Model\Customer ' )
253
+ ->disableOriginalConstructor ()
254
+ ->getMock ();
255
+ $ address = $ this ->getMockBuilder ('Magento\Customer\Model\Address ' )
256
+ ->disableOriginalConstructor ()
257
+ ->getMock ();
258
+ $ collectionMock = $ this ->getMockBuilder ('Magento\Customer\Model\Resource\Customer\Collection ' )
259
+ ->disableOriginalConstructor ()
260
+ ->getMock ();
261
+
262
+ $ collectionMock ->expects ($ this ->once ())
263
+ ->method ('addAttributeToSelect ' )
264
+ ->with ('* ' );
265
+
266
+ $ this ->customerCollectionFactoryMock ->expects ($ this ->once ())
267
+ ->method ('create ' )
268
+ ->willReturn ($ collectionMock );
269
+
270
+ $ collectionMock ->expects ($ this ->once ())
271
+ ->method ('getItems ' )
272
+ ->willReturn ([$ customer ]);
273
+ $ customer ->expects ($ this ->once ())
274
+ ->method ('getData ' )
275
+ ->willReturn ([
276
+ 'email ' => 'test@test.ua ' ,
277
+ 'default_billing ' => 2 ,
278
+ 'default_shipping ' => 2 ,
279
+ ]);
280
+ $ customer ->expects ($ this ->once ())
281
+ ->method ('getAddresses ' )
282
+ ->willReturn ([$ address ]);
283
+ $ address ->expects ($ this ->atLeastOnce ())
284
+ ->method ('getId ' )
285
+ ->willReturn (2 );
286
+ $ address ->expects ($ this ->once ())
287
+ ->method ('load ' )
288
+ ->with (2 )
289
+ ->willReturnSelf ();
290
+ $ address ->expects ($ this ->once ())
291
+ ->method ('getData ' )
292
+ ->willReturn ([
293
+ 'firstname ' => 'firstname ' ,
294
+ 'lastname ' => 'lastname ' ,
295
+ 'street ' => "street \nstreet " ,
296
+ ]);
297
+
298
+ $ helper = new ObjectManager ($ this );
299
+ $ dataProvider = $ helper ->getObject (
300
+ '\Magento\Customer\Model\Customer\DataProvider ' ,
301
+ [
302
+ 'name ' => 'test-name ' ,
303
+ 'primaryFieldName ' => 'primary-field-name ' ,
304
+ 'requestFieldName ' => 'request-field-name ' ,
305
+ 'eavValidationRules ' => $ this ->eavValidationRulesMock ,
306
+ 'customerCollectionFactory ' => $ this ->customerCollectionFactoryMock ,
307
+ 'eavConfig ' => $ this ->getEavConfigMock ()
308
+ ]
309
+ );
310
+ $ this ->assertEquals (
311
+ [
312
+ '' => [
313
+ 'customer ' => [
314
+ 'email ' => 'test@test.ua ' ,
315
+ 'default_billing ' => 2 ,
316
+ 'default_shipping ' => 2 ,
317
+ ],
318
+ 'address ' => [
319
+ 2 => [
320
+ 'firstname ' => 'firstname ' ,
321
+ 'lastname ' => 'lastname ' ,
322
+ 'street ' => [
323
+ 'street ' ,
324
+ 'street ' ,
325
+ ],
326
+ 'default_billing ' => 2 ,
327
+ 'default_shipping ' => 2 ,
328
+ ]
329
+ ]
330
+ ]
331
+ ],
332
+ $ dataProvider ->getData ()
333
+ );
334
+ }
249
335
}
0 commit comments