@@ -91,77 +91,78 @@ class CustomerRepositoryTest extends \PHPUnit_Framework_TestCase
91
91
protected function setUp ()
92
92
{
93
93
$ this ->customerResourceModel =
94
- $ this ->getMock ('Magento\Customer\Model\ResourceModel\Customer ' , [], [], '' , false );
95
- $ this ->customerRegistry = $ this ->getMock ('Magento\Customer\Model\CustomerRegistry ' , [], [], '' , false );
96
- $ this ->dataObjectHelper = $ this ->getMock ('Magento\Framework\Api\DataObjectHelper ' , [], [], '' , false );
97
- $ this ->customerFactory = $ this ->getMock ('Magento\Customer\Model\CustomerFactory ' , ['create ' ], [], '' , false );
94
+ $ this ->getMock (\Magento \Customer \Model \ResourceModel \Customer::class, [], [], '' , false );
95
+ $ this ->customerRegistry = $ this ->getMock (\Magento \Customer \Model \CustomerRegistry::class, [], [], '' , false );
96
+ $ this ->dataObjectHelper = $ this ->getMock (\Magento \Framework \Api \DataObjectHelper::class, [], [], '' , false );
97
+ $ this ->customerFactory = $ this ->getMock (
98
+ \Magento \Customer \Model \CustomerFactory::class,
99
+ ['create ' ],
100
+ [],
101
+ '' ,
102
+ false
103
+ );
98
104
$ this ->customerSecureFactory = $ this ->getMock (
99
- ' Magento\Customer\Model\Data\CustomerSecureFactory ' ,
105
+ \ Magento \Customer \Model \Data \CustomerSecureFactory::class ,
100
106
['create ' ],
101
107
[],
102
108
'' ,
103
109
false
104
110
);
105
-
106
111
$ this ->addressRepository = $ this ->getMock (
107
- ' Magento\Customer\Model\ResourceModel\AddressRepository ' ,
112
+ \ Magento \Customer \Model \ResourceModel \AddressRepository::class ,
108
113
[],
109
114
[],
110
115
'' ,
111
116
false
112
117
);
113
-
114
118
$ this ->customerMetadata = $ this ->getMockForAbstractClass (
115
- ' Magento\Customer\Api\CustomerMetadataInterface ' ,
119
+ \ Magento \Customer \Api \CustomerMetadataInterface::class ,
116
120
[],
117
121
'' ,
118
122
false
119
123
);
120
124
$ this ->searchResultsFactory = $ this ->getMock (
121
- ' Magento\Customer\Api\Data\CustomerSearchResultsInterfaceFactory ' ,
125
+ \ Magento \Customer \Api \Data \CustomerSearchResultsInterfaceFactory::class ,
122
126
['create ' ],
123
127
[],
124
128
'' ,
125
129
false
126
130
);
127
131
$ this ->eventManager = $ this ->getMockForAbstractClass (
128
- ' Magento\Framework\Event\ManagerInterface ' ,
132
+ \ Magento \Framework \Event \ManagerInterface::class ,
129
133
[],
130
134
'' ,
131
135
false
132
136
);
133
137
$ this ->storeManager = $ this ->getMockForAbstractClass (
134
- ' Magento\Store\Model\StoreManagerInterface ' ,
138
+ \ Magento \Store \Model \StoreManagerInterface::class ,
135
139
[],
136
140
'' ,
137
141
false
138
142
);
139
143
$ this ->extensibleDataObjectConverter = $ this ->getMock (
140
- ' Magento\Framework\Api\ExtensibleDataObjectConverter ' ,
144
+ \ Magento \Framework \Api \ExtensibleDataObjectConverter::class ,
141
145
[],
142
146
[],
143
147
'' ,
144
148
false
145
149
);
146
150
$ this ->imageProcessor = $ this ->getMockForAbstractClass (
147
- ' Magento\Framework\Api\ImageProcessorInterface ' ,
151
+ \ Magento \Framework \Api \ImageProcessorInterface::class ,
148
152
[],
149
153
'' ,
150
154
false
151
155
);
152
156
$ this ->extensionAttributesJoinProcessor = $ this ->getMockForAbstractClass (
153
- 'Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface ' ,
154
- [],
155
- '' ,
156
- false
157
- );
158
- $ this ->customer = $ this ->getMockForAbstractClass (
159
- 'Magento\Customer\Api\Data\CustomerInterface ' ,
157
+ \Magento \Framework \Api \ExtensionAttribute \JoinProcessorInterface::class,
160
158
[],
161
159
'' ,
162
160
false
163
161
);
164
-
162
+ $ this ->customer = $ this ->getMockBuilder (\Magento \Customer \Api \Data \CustomerInterface::class)
163
+ ->setMethods (['__toArray ' ])
164
+ ->disableOriginalConstructor ()
165
+ ->getMockForAbstractClass ();
165
166
$ this ->model = new \Magento \Customer \Model \ResourceModel \CustomerRepository (
166
167
$ this ->customerFactory ,
167
168
$ this ->customerSecureFactory ,
@@ -187,9 +188,9 @@ public function testSave()
187
188
$ customerId = 1 ;
188
189
$ storeId = 2 ;
189
190
190
- $ region = $ this ->getMockForAbstractClass (' Magento\Customer\Api\Data\RegionInterface ' , [], '' , false );
191
+ $ region = $ this ->getMockForAbstractClass (\ Magento \Customer \Api \Data \RegionInterface::class , [], '' , false );
191
192
$ address = $ this ->getMockForAbstractClass (
192
- ' Magento\Customer\Api\Data\AddressInterface ' ,
193
+ \ Magento \Customer \Api \Data \AddressInterface::class ,
193
194
[],
194
195
'' ,
195
196
false ,
@@ -203,7 +204,7 @@ public function testSave()
203
204
]
204
205
);
205
206
$ address2 = $ this ->getMockForAbstractClass (
206
- ' Magento\Customer\Api\Data\AddressInterface ' ,
207
+ \ Magento \Customer \Api \Data \AddressInterface::class ,
207
208
[],
208
209
'' ,
209
210
false ,
@@ -217,7 +218,7 @@ public function testSave()
217
218
]
218
219
);
219
220
$ customerModel = $ this ->getMock (
220
- ' Magento\Customer\Model\Customer ' ,
221
+ \ Magento \Customer \Model \Customer::class ,
221
222
[
222
223
'getId ' ,
223
224
'setId ' ,
@@ -238,8 +239,11 @@ public function testSave()
238
239
'' ,
239
240
false
240
241
);
242
+ $ this ->customer ->expects ($ this ->atLeastOnce ())
243
+ ->method ('__toArray ' )
244
+ ->willReturn (['default_billing ' , 'default_shipping ' ]);
241
245
$ customerAttributesMetaData = $ this ->getMockForAbstractClass (
242
- ' Magento\Framework\Api\CustomAttributesDataInterface ' ,
246
+ \ Magento \Framework \Api \CustomAttributesDataInterface::class ,
243
247
[],
244
248
'' ,
245
249
false ,
@@ -254,7 +258,7 @@ public function testSave()
254
258
]
255
259
);
256
260
$ customerSecureData = $ this ->getMock (
257
- ' Magento\Customer\Model\Data\CustomerSecure ' ,
261
+ \ Magento \Customer \Model \Data \CustomerSecure::class ,
258
262
[
259
263
'getRpToken ' ,
260
264
'getRpTokenCreatedAt ' ,
@@ -305,7 +309,7 @@ public function testSave()
305
309
->with ([$ address ]);
306
310
$ this ->extensibleDataObjectConverter ->expects ($ this ->once ())
307
311
->method ('toNestedArray ' )
308
- ->with ($ customerAttributesMetaData , [], ' \Magento\Customer\Api\Data\CustomerInterface ' )
312
+ ->with ($ customerAttributesMetaData , [], \Magento \Customer \Api \Data \CustomerInterface::class )
309
313
->willReturn (['customerData ' ]);
310
314
$ this ->customerFactory ->expects ($ this ->once ())
311
315
->method ('create ' )
@@ -428,9 +432,9 @@ public function testSaveWithPasswordHash()
428
432
$ storeId = 2 ;
429
433
$ passwordHash = 'ukfa4sdfa56s5df02asdf4rt ' ;
430
434
431
- $ region = $ this ->getMockForAbstractClass (' Magento\Customer\Api\Data\RegionInterface ' , [], '' , false );
435
+ $ region = $ this ->getMockForAbstractClass (\ Magento \Customer \Api \Data \RegionInterface::class , [], '' , false );
432
436
$ address = $ this ->getMockForAbstractClass (
433
- ' Magento\Customer\Api\Data\AddressInterface ' ,
437
+ \ Magento \Customer \Api \Data \AddressInterface::class ,
434
438
[],
435
439
'' ,
436
440
false ,
@@ -444,7 +448,7 @@ public function testSaveWithPasswordHash()
444
448
]
445
449
);
446
450
$ address2 = $ this ->getMockForAbstractClass (
447
- ' Magento\Customer\Api\Data\AddressInterface ' ,
451
+ \ Magento \Customer \Api \Data \AddressInterface::class ,
448
452
[],
449
453
'' ,
450
454
false ,
@@ -457,8 +461,12 @@ public function testSaveWithPasswordHash()
457
461
'getId '
458
462
]
459
463
);
464
+ $ this ->customer ->expects ($ this ->atLeastOnce ())
465
+ ->method ('__toArray ' )
466
+ ->willReturn (['default_billing ' , 'default_shipping ' ]);
467
+
460
468
$ customerModel = $ this ->getMock (
461
- ' Magento\Customer\Model\Customer ' ,
469
+ \ Magento \Customer \Model \Customer::class ,
462
470
[
463
471
'getId ' ,
464
472
'setId ' ,
@@ -477,7 +485,7 @@ public function testSaveWithPasswordHash()
477
485
false
478
486
);
479
487
$ customerAttributesMetaData = $ this ->getMockForAbstractClass (
480
- ' Magento\Framework\Api\CustomAttributesDataInterface ' ,
488
+ \ Magento \Framework \Api \CustomAttributesDataInterface::class ,
481
489
[],
482
490
'' ,
483
491
false ,
@@ -529,7 +537,7 @@ public function testSaveWithPasswordHash()
529
537
->with ([$ address ]);
530
538
$ this ->extensibleDataObjectConverter ->expects ($ this ->once ())
531
539
->method ('toNestedArray ' )
532
- ->with ($ customerAttributesMetaData , [], ' \Magento\Customer\Api\Data\CustomerInterface ' )
540
+ ->with ($ customerAttributesMetaData , [], \Magento \Customer \Api \Data \CustomerInterface::class )
533
541
->willReturn (['customerData ' ]);
534
542
$ this ->customerFactory ->expects ($ this ->once ())
535
543
->method ('create ' )
@@ -600,24 +608,30 @@ public function testSaveWithPasswordHash()
600
608
*/
601
609
public function testGetList ()
602
610
{
603
- $ sortOrder = $ this ->getMock ('Magento\Framework\Api\SortOrder ' , [], [], '' , false );
604
- $ filterGroup = $ this ->getMock ('Magento\Framework\Api\Search\FilterGroup ' , [], [], '' , false );
605
- $ filter = $ this ->getMock ('Magento\Framework\Api\Filter ' , [], [], '' , false );
606
- $ collection = $ this ->getMock ('Magento\Customer\Model\ResourceModel\Customer\Collection ' , [], [], '' , false );
611
+ $ sortOrder = $ this ->getMock (\Magento \Framework \Api \SortOrder::class, [], [], '' , false );
612
+ $ filterGroup = $ this ->getMock (\Magento \Framework \Api \Search \FilterGroup::class, [], [], '' , false );
613
+ $ filter = $ this ->getMock (\Magento \Framework \Api \Filter::class, [], [], '' , false );
614
+ $ collection = $ this ->getMock (
615
+ \Magento \Customer \Model \ResourceModel \Customer \Collection::class,
616
+ [],
617
+ [],
618
+ '' ,
619
+ false
620
+ );
607
621
$ searchResults = $ this ->getMockForAbstractClass (
608
- ' Magento\Customer\Api\Data\AddressSearchResultsInterface ' ,
622
+ \ Magento \Customer \Api \Data \AddressSearchResultsInterface::class ,
609
623
[],
610
624
'' ,
611
625
false
612
626
);
613
627
$ searchCriteria = $ this ->getMockForAbstractClass (
614
- ' Magento\Framework\Api\SearchCriteriaInterface ' ,
628
+ \ Magento \Framework \Api \SearchCriteriaInterface::class ,
615
629
[],
616
630
'' ,
617
631
false
618
632
);
619
633
$ customerModel = $ this ->getMock (
620
- ' Magento\Customer\Model\Customer ' ,
634
+ \ Magento \Customer \Model \Customer::class ,
621
635
[
622
636
'getId ' ,
623
637
'setId ' ,
@@ -636,7 +650,7 @@ public function testGetList()
636
650
false
637
651
);
638
652
$ metadata = $ this ->getMockForAbstractClass (
639
- ' Magento\Customer\Api\Data\AttributeMetadataInterface ' ,
653
+ \ Magento \Customer \Api \Data \AttributeMetadataInterface::class ,
640
654
[],
641
655
'' ,
642
656
false
@@ -656,7 +670,7 @@ public function testGetList()
656
670
->willReturn ($ collection );
657
671
$ this ->extensionAttributesJoinProcessor ->expects ($ this ->once ())
658
672
->method ('process ' )
659
- ->with ($ collection , ' Magento\Customer\Api\Data\CustomerInterface ' );
673
+ ->with ($ collection , \ Magento \Customer \Api \Data \CustomerInterface::class );
660
674
$ this ->customerMetadata ->expects ($ this ->once ())
661
675
->method ('getAllAttributesMetadata ' )
662
676
->willReturn ([$ metadata ]);
@@ -757,7 +771,7 @@ public function testDeleteById()
757
771
{
758
772
$ customerId = 14 ;
759
773
$ customerModel = $ this ->getMock (
760
- ' Magento\Customer\Model\Customer ' ,
774
+ \ Magento \Customer \Model \Customer::class ,
761
775
['delete ' ],
762
776
[],
763
777
'' ,
@@ -781,7 +795,7 @@ public function testDelete()
781
795
{
782
796
$ customerId = 14 ;
783
797
$ customerModel = $ this ->getMock (
784
- ' Magento\Customer\Model\Customer ' ,
798
+ \ Magento \Customer \Model \Customer::class ,
785
799
['delete ' ],
786
800
[],
787
801
'' ,
0 commit comments