@@ -19,95 +19,95 @@ class CustomerRepositoryTest extends \PHPUnit\Framework\TestCase
19
19
/**
20
20
* @var \Magento\Customer\Model\CustomerFactory|\PHPUnit_Framework_MockObject_MockObject
21
21
*/
22
- protected $ customerFactory ;
22
+ private $ customerFactory ;
23
23
24
24
/**
25
25
* @var \Magento\Customer\Model\Data\CustomerSecureFactory|\PHPUnit_Framework_MockObject_MockObject
26
26
*/
27
- protected $ customerSecureFactory ;
27
+ private $ customerSecureFactory ;
28
28
29
29
/**
30
30
* @var \Magento\Customer\Model\CustomerRegistry|\PHPUnit_Framework_MockObject_MockObject
31
31
*/
32
- protected $ customerRegistry ;
32
+ private $ customerRegistry ;
33
33
34
34
/**
35
35
* @var \Magento\Customer\Model\ResourceModel\AddressRepository|\PHPUnit_Framework_MockObject_MockObject
36
36
*/
37
- protected $ addressRepository ;
37
+ private $ addressRepository ;
38
38
39
39
/**
40
40
* @var \Magento\Customer\Model\ResourceModel\Customer|\PHPUnit_Framework_MockObject_MockObject
41
41
*/
42
- protected $ customerResourceModel ;
42
+ private $ customerResourceModel ;
43
43
44
44
/**
45
45
* @var \Magento\Customer\Api\CustomerMetadataInterface|\PHPUnit_Framework_MockObject_MockObject
46
46
*/
47
- protected $ customerMetadata ;
47
+ private $ customerMetadata ;
48
48
49
49
/**
50
50
* @var \Magento\Customer\Api\Data\CustomerSearchResultsInterfaceFactory|\PHPUnit_Framework_MockObject_MockObject
51
51
*/
52
- protected $ searchResultsFactory ;
52
+ private $ searchResultsFactory ;
53
53
54
54
/**
55
55
* @var \Magento\Framework\Event\ManagerInterface|\PHPUnit_Framework_MockObject_MockObject
56
56
*/
57
- protected $ eventManager ;
57
+ private $ eventManager ;
58
58
59
59
/**
60
60
* @var \Magento\Store\Model\StoreManagerInterface|\PHPUnit_Framework_MockObject_MockObject
61
61
*/
62
- protected $ storeManager ;
62
+ private $ storeManager ;
63
63
64
64
/**
65
65
* @var \Magento\Framework\Api\ExtensibleDataObjectConverter|\PHPUnit_Framework_MockObject_MockObject
66
66
*/
67
- protected $ extensibleDataObjectConverter ;
67
+ private $ extensibleDataObjectConverter ;
68
68
69
69
/**
70
70
* @var \Magento\Framework\Api\DataObjectHelper|\PHPUnit_Framework_MockObject_MockObject
71
71
*/
72
- protected $ dataObjectHelper ;
72
+ private $ dataObjectHelper ;
73
73
74
74
/**
75
75
* @var \Magento\Framework\Api\ImageProcessorInterface|\PHPUnit_Framework_MockObject_MockObject
76
76
*/
77
- protected $ imageProcessor ;
77
+ private $ imageProcessor ;
78
78
79
79
/**
80
80
* @var \Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface|\PHPUnit_Framework_MockObject_MockObject
81
81
*/
82
- protected $ extensionAttributesJoinProcessor ;
82
+ private $ extensionAttributesJoinProcessor ;
83
83
84
84
/**
85
85
* @var \Magento\Customer\Api\Data\CustomerInterface|\PHPUnit_Framework_MockObject_MockObject
86
86
*/
87
- protected $ customer ;
87
+ private $ customer ;
88
88
89
89
/**
90
90
* @var CollectionProcessorInterface|\PHPUnit_Framework_MockObject_MockObject
91
91
*/
92
92
private $ collectionProcessorMock ;
93
93
94
94
/**
95
- * @var \Magento\Customer\Model\ResourceModel\CustomerRepository
95
+ * @var NotificationStorage|\PHPUnit_Framework_MockObject_MockObject
96
96
*/
97
- protected $ model ;
97
+ private $ notificationStorage ;
98
98
99
99
/**
100
- * @var NotificationStorage
100
+ * @var \Magento\Customer\Model\ResourceModel\CustomerRepository
101
101
*/
102
- private $ notificationStorage ;
102
+ private $ model ;
103
103
104
104
protected function setUp ()
105
105
{
106
106
$ this ->customerResourceModel =
107
107
$ this ->createMock (\Magento \Customer \Model \ResourceModel \Customer::class);
108
108
$ this ->customerRegistry = $ this ->createMock (\Magento \Customer \Model \CustomerRegistry::class);
109
109
$ this ->dataObjectHelper = $ this ->createMock (\Magento \Framework \Api \DataObjectHelper::class);
110
- $ this ->customerFactory =
110
+ $ this ->customerFactory =
111
111
$ this ->createPartialMock (\Magento \Customer \Model \CustomerFactory::class, ['create ' ]);
112
112
$ this ->customerSecureFactory = $ this ->createPartialMock (
113
113
\Magento \Customer \Model \Data \CustomerSecureFactory::class,
@@ -193,37 +193,7 @@ protected function setUp()
193
193
public function testSave ()
194
194
{
195
195
$ customerId = 1 ;
196
- $ storeId = 2 ;
197
196
198
- $ region = $ this ->getMockForAbstractClass (\Magento \Customer \Api \Data \RegionInterface::class, [], '' , false );
199
- $ address = $ this ->getMockForAbstractClass (
200
- \Magento \Customer \Api \Data \AddressInterface::class,
201
- [],
202
- '' ,
203
- false ,
204
- false ,
205
- true ,
206
- [
207
- 'setCustomerId ' ,
208
- 'setRegion ' ,
209
- 'getRegion ' ,
210
- 'getId '
211
- ]
212
- );
213
- $ address2 = $ this ->getMockForAbstractClass (
214
- \Magento \Customer \Api \Data \AddressInterface::class,
215
- [],
216
- '' ,
217
- false ,
218
- false ,
219
- true ,
220
- [
221
- 'setCustomerId ' ,
222
- 'setRegion ' ,
223
- 'getRegion ' ,
224
- 'getId '
225
- ]
226
- );
227
197
$ customerModel = $ this ->createPartialMock (
228
198
\Magento \Customer \Model \Customer::class,
229
199
[
@@ -246,10 +216,6 @@ public function testSave()
246
216
247
217
$ origCustomer = $ this ->customer ;
248
218
249
- $ this ->customer ->expects ($ this ->atLeastOnce ())
250
- ->method ('__toArray ' )
251
- ->willReturn (['default_billing ' , 'default_shipping ' ]);
252
-
253
219
$ customerAttributesMetaData = $ this ->getMockForAbstractClass (
254
220
\Magento \Framework \Api \CustomAttributesDataInterface::class,
255
221
[],
@@ -265,17 +231,23 @@ public function testSave()
265
231
'setAddresses '
266
232
]
267
233
);
268
- $ customerSecureData = $ this ->createPartialMock (\Magento \Customer \Model \Data \CustomerSecure::class, [
234
+ $ customerSecureData = $ this ->createPartialMock (
235
+ \Magento \Customer \Model \Data \CustomerSecure::class,
236
+ [
269
237
'getRpToken ' ,
270
238
'getRpTokenCreatedAt ' ,
271
239
'getPasswordHash ' ,
272
240
'getFailuresNum ' ,
273
241
'getFirstFailure ' ,
274
242
'getLockExpires ' ,
275
- ]);
243
+ ]
244
+ );
276
245
$ this ->customer ->expects ($ this ->atLeastOnce ())
277
246
->method ('getId ' )
278
247
->willReturn ($ customerId );
248
+ $ this ->customer ->expects ($ this ->atLeastOnce ())
249
+ ->method ('__toArray ' )
250
+ ->willReturn ([]);
279
251
$ this ->customerRegistry ->expects ($ this ->atLeastOnce ())
280
252
->method ('retrieve ' )
281
253
->with ($ customerId )
@@ -290,28 +262,6 @@ public function testSave()
290
262
$ this ->customerRegistry ->expects ($ this ->atLeastOnce ())
291
263
->method ("remove " )
292
264
->with ($ customerId );
293
- $ address ->expects ($ this ->once ())
294
- ->method ('setCustomerId ' )
295
- ->with ($ customerId )
296
- ->willReturnSelf ();
297
- $ address ->expects ($ this ->once ())
298
- ->method ('getRegion ' )
299
- ->willReturn ($ region );
300
- $ address ->expects ($ this ->atLeastOnce ())
301
- ->method ('getId ' )
302
- ->willReturn (7 );
303
- $ address ->expects ($ this ->once ())
304
- ->method ('setRegion ' )
305
- ->with ($ region );
306
- $ customerAttributesMetaData ->expects ($ this ->atLeastOnce ())
307
- ->method ('getAddresses ' )
308
- ->willReturn ([$ address ]);
309
- $ customerAttributesMetaData ->expects ($ this ->at (1 ))
310
- ->method ('setAddresses ' )
311
- ->with ([]);
312
- $ customerAttributesMetaData ->expects ($ this ->at (2 ))
313
- ->method ('setAddresses ' )
314
- ->with ([$ address ]);
315
265
$ this ->extensibleDataObjectConverter ->expects ($ this ->once ())
316
266
->method ('toNestedArray ' )
317
267
->with ($ customerAttributesMetaData , [], \Magento \Customer \Api \Data \CustomerInterface::class)
@@ -323,17 +273,6 @@ public function testSave()
323
273
$ customerModel ->expects ($ this ->once ())
324
274
->method ('getStoreId ' )
325
275
->willReturn (null );
326
- $ store = $ this ->createMock (\Magento \Store \Model \Store::class);
327
- $ store ->expects ($ this ->once ())
328
- ->method ('getId ' )
329
- ->willReturn ($ storeId );
330
- $ this ->storeManager
331
- ->expects ($ this ->once ())
332
- ->method ('getStore ' )
333
- ->willReturn ($ store );
334
- $ customerModel ->expects ($ this ->once ())
335
- ->method ('setStoreId ' )
336
- ->with ($ storeId );
337
276
$ customerModel ->expects ($ this ->once ())
338
277
->method ('setId ' )
339
278
->with ($ customerId );
@@ -400,12 +339,6 @@ public function testSave()
400
339
$ this ->customerRegistry ->expects ($ this ->once ())
401
340
->method ('push ' )
402
341
->with ($ customerModel );
403
- $ this ->customer ->expects ($ this ->once ())
404
- ->method ('getAddresses ' )
405
- ->willReturn ([$ address , $ address2 ]);
406
- $ this ->addressRepository ->expects ($ this ->once ())
407
- ->method ('save ' )
408
- ->with ($ address );
409
342
$ customerAttributesMetaData ->expects ($ this ->once ())
410
343
->method ('getEmail ' )
411
344
->willReturn ('example@example.com ' );
@@ -436,7 +369,6 @@ public function testSave()
436
369
public function testSaveWithPasswordHash ()
437
370
{
438
371
$ customerId = 1 ;
439
- $ storeId = 2 ;
440
372
$ passwordHash = 'ukfa4sdfa56s5df02asdf4rt ' ;
441
373
442
374
$ customerSecureData = $ this ->createPartialMock (
@@ -450,47 +382,8 @@ public function testSaveWithPasswordHash()
450
382
'getLockExpires ' ,
451
383
]
452
384
);
453
- $ region = $ this ->getMockForAbstractClass (
454
- \Magento \Customer \Api \Data \RegionInterface::class,
455
- [],
456
- '' ,
457
- false
458
- );
459
- $ address = $ this ->getMockForAbstractClass (
460
- \Magento \Customer \Api \Data \AddressInterface::class,
461
- [],
462
- '' ,
463
- false ,
464
- false ,
465
- true ,
466
- [
467
- 'setCustomerId ' ,
468
- 'setRegion ' ,
469
- 'getRegion ' ,
470
- 'getId '
471
- ]
472
- );
473
- $ address2 = $ this ->getMockForAbstractClass (
474
- \Magento \Customer \Api \Data \AddressInterface::class,
475
- [],
476
- '' ,
477
- false ,
478
- false ,
479
- true ,
480
- [
481
- 'setCustomerId ' ,
482
- 'setRegion ' ,
483
- 'getRegion ' ,
484
- 'getId '
485
- ]
486
- );
487
-
488
385
$ origCustomer = $ this ->customer ;
489
386
490
- $ this ->customer ->expects ($ this ->atLeastOnce ())
491
- ->method ('__toArray ' )
492
- ->willReturn (['default_billing ' , 'default_shipping ' ]);
493
-
494
387
$ customerModel = $ this ->createPartialMock (
495
388
\Magento \Customer \Model \Customer::class,
496
389
[
@@ -534,6 +427,7 @@ public function testSaveWithPasswordHash()
534
427
$ this ->customerRegistry ->expects ($ this ->atLeastOnce ())
535
428
->method ('remove ' )
536
429
->with ($ customerId );
430
+
537
431
$ this ->customerRegistry ->expects ($ this ->once ())
538
432
->method ('retrieveSecureData ' )
539
433
->with ($ customerId )
@@ -559,6 +453,9 @@ public function testSaveWithPasswordHash()
559
453
$ this ->customer ->expects ($ this ->atLeastOnce ())
560
454
->method ('getId ' )
561
455
->willReturn ($ customerId );
456
+ $ this ->customer ->expects ($ this ->atLeastOnce ())
457
+ ->method ('__toArray ' )
458
+ ->willReturn ([]);
562
459
$ this ->customerRegistry ->expects ($ this ->atLeastOnce ())
563
460
->method ('retrieve ' )
564
461
->with ($ customerId )
@@ -570,28 +467,6 @@ public function testSaveWithPasswordHash()
570
467
->method ('save ' )
571
468
->with ($ this ->customer , CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER , $ this ->customer )
572
469
->willReturn ($ customerAttributesMetaData );
573
- $ address ->expects ($ this ->once ())
574
- ->method ('setCustomerId ' )
575
- ->with ($ customerId )
576
- ->willReturnSelf ();
577
- $ address ->expects ($ this ->once ())
578
- ->method ('getRegion ' )
579
- ->willReturn ($ region );
580
- $ address ->expects ($ this ->atLeastOnce ())
581
- ->method ('getId ' )
582
- ->willReturn (7 );
583
- $ address ->expects ($ this ->once ())
584
- ->method ('setRegion ' )
585
- ->with ($ region );
586
- $ customerAttributesMetaData ->expects ($ this ->any ())
587
- ->method ('getAddresses ' )
588
- ->willReturn ([$ address ]);
589
- $ customerAttributesMetaData ->expects ($ this ->at (1 ))
590
- ->method ('setAddresses ' )
591
- ->with ([]);
592
- $ customerAttributesMetaData ->expects ($ this ->at (2 ))
593
- ->method ('setAddresses ' )
594
- ->with ([$ address ]);
595
470
$ customerAttributesMetaData
596
471
->expects ($ this ->atLeastOnce ())
597
472
->method ('getId ' )
@@ -604,20 +479,6 @@ public function testSaveWithPasswordHash()
604
479
->method ('create ' )
605
480
->with (['data ' => ['customerData ' ]])
606
481
->willReturn ($ customerModel );
607
- $ customerModel ->expects ($ this ->once ())
608
- ->method ('getStoreId ' )
609
- ->willReturn (null );
610
- $ store = $ this ->createMock (\Magento \Store \Model \Store::class);
611
- $ store ->expects ($ this ->once ())
612
- ->method ('getId ' )
613
- ->willReturn ($ storeId );
614
- $ this ->storeManager
615
- ->expects ($ this ->once ())
616
- ->method ('getStore ' )
617
- ->willReturn ($ store );
618
- $ customerModel ->expects ($ this ->once ())
619
- ->method ('setStoreId ' )
620
- ->with ($ storeId );
621
482
$ customerModel ->expects ($ this ->once ())
622
483
->method ('setId ' )
623
484
->with ($ customerId );
@@ -629,12 +490,6 @@ public function testSaveWithPasswordHash()
629
490
$ this ->customerRegistry ->expects ($ this ->once ())
630
491
->method ('push ' )
631
492
->with ($ customerModel );
632
- $ this ->customer ->expects ($ this ->any ())
633
- ->method ('getAddresses ' )
634
- ->willReturn ([$ address , $ address2 ]);
635
- $ this ->addressRepository ->expects ($ this ->once ())
636
- ->method ('save ' )
637
- ->with ($ address );
638
493
$ customerAttributesMetaData ->expects ($ this ->once ())
639
494
->method ('getEmail ' )
640
495
->willReturn ('example@example.com ' );
0 commit comments