@@ -91,75 +91,81 @@ class CustomerRepositoryTest extends \PHPUnit_Framework_TestCase
91
91
public 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 =
98
+ $ this ->getMock (\Magento \Customer \Model \CustomerFactory::class, ['create ' ], [], '' , false );
98
99
$ this ->customerSecureFactory = $ this ->getMock (
99
- ' Magento\Customer\Model\Data\CustomerSecureFactory ' ,
100
+ \ Magento \Customer \Model \Data \CustomerSecureFactory::class ,
100
101
['create ' ],
101
102
[],
102
103
'' ,
103
104
false
104
105
);
105
106
106
107
$ this ->addressRepository = $ this ->getMock (
107
- ' Magento\Customer\Model\ResourceModel\AddressRepository ' ,
108
+ \ Magento \Customer \Model \ResourceModel \AddressRepository::class ,
108
109
[],
109
110
[],
110
111
'' ,
111
112
false
112
113
);
113
114
114
115
$ this ->customerMetadata = $ this ->getMockForAbstractClass (
115
- ' Magento\Customer\Api\CustomerMetadataInterface ' ,
116
+ \ Magento \Customer \Api \CustomerMetadataInterface::class ,
116
117
[],
117
118
'' ,
118
119
false
119
120
);
120
121
$ this ->searchResultsFactory = $ this ->getMock (
121
- ' Magento\Customer\Api\Data\CustomerSearchResultsInterfaceFactory ' ,
122
+ \ Magento \Customer \Api \Data \CustomerSearchResultsInterfaceFactory::class ,
122
123
['create ' ],
123
124
[],
124
125
'' ,
125
126
false
126
127
);
127
128
$ this ->eventManager = $ this ->getMockForAbstractClass (
128
- ' Magento\Framework\Event\ManagerInterface ' ,
129
+ \ Magento \Framework \Event \ManagerInterface::class ,
129
130
[],
130
131
'' ,
131
132
false
132
133
);
133
134
$ this ->storeManager = $ this ->getMockForAbstractClass (
134
- ' Magento\Store\Model\StoreManagerInterface ' ,
135
+ \ Magento \Store \Model \StoreManagerInterface::class ,
135
136
[],
136
137
'' ,
137
138
false
138
139
);
139
140
$ this ->extensibleDataObjectConverter = $ this ->getMock (
140
- ' Magento\Framework\Api\ExtensibleDataObjectConverter ' ,
141
+ \ Magento \Framework \Api \ExtensibleDataObjectConverter::class ,
141
142
[],
142
143
[],
143
144
'' ,
144
145
false
145
146
);
146
147
$ this ->imageProcessor = $ this ->getMockForAbstractClass (
147
- ' Magento\Framework\Api\ImageProcessorInterface ' ,
148
+ \ Magento \Framework \Api \ImageProcessorInterface::class ,
148
149
[],
149
150
'' ,
150
151
false
151
152
);
152
153
$ this ->extensionAttributesJoinProcessor = $ this ->getMockForAbstractClass (
153
- ' Magento\Framework\Api\ExtensionAttribute\JoinProcessorInterface ' ,
154
+ \ Magento \Framework \Api \ExtensionAttribute \JoinProcessorInterface::class ,
154
155
[],
155
156
'' ,
156
157
false
157
158
);
158
159
$ this ->customer = $ this ->getMockForAbstractClass (
159
- ' Magento\Customer\Api\Data\CustomerInterface ' ,
160
+ \ Magento \Customer \Api \Data \CustomerInterface::class ,
160
161
[],
161
162
'' ,
162
- false
163
+ true ,
164
+ true ,
165
+ true ,
166
+ [
167
+ '__toArray '
168
+ ]
163
169
);
164
170
165
171
$ this ->model = new \Magento \Customer \Model \ResourceModel \CustomerRepository (
@@ -185,7 +191,7 @@ public function setUp()
185
191
protected function prepareMocksForValidation ($ isValid = false )
186
192
{
187
193
$ attributeMetaData = $ this ->getMockForAbstractClass (
188
- ' Magento\Customer\Api\Data\AttributeMetadataInterface ' ,
194
+ \ Magento \Customer \Api \Data \AttributeMetadataInterface::class ,
189
195
[],
190
196
'' ,
191
197
false
@@ -226,9 +232,9 @@ public function testSave()
226
232
$ storeId = 2 ;
227
233
$ this ->prepareMocksForValidation (true );
228
234
229
- $ region = $ this ->getMockForAbstractClass (' Magento\Customer\Api\Data\RegionInterface ' , [], '' , false );
235
+ $ region = $ this ->getMockForAbstractClass (\ Magento \Customer \Api \Data \RegionInterface::class , [], '' , false );
230
236
$ address = $ this ->getMockForAbstractClass (
231
- ' Magento\Customer\Api\Data\AddressInterface ' ,
237
+ \ Magento \Customer \Api \Data \AddressInterface::class ,
232
238
[],
233
239
'' ,
234
240
false ,
@@ -242,7 +248,7 @@ public function testSave()
242
248
]
243
249
);
244
250
$ address2 = $ this ->getMockForAbstractClass (
245
- ' Magento\Customer\Api\Data\AddressInterface ' ,
251
+ \ Magento \Customer \Api \Data \AddressInterface::class ,
246
252
[],
247
253
'' ,
248
254
false ,
@@ -256,7 +262,7 @@ public function testSave()
256
262
]
257
263
);
258
264
$ customerModel = $ this ->getMock (
259
- ' Magento\Customer\Model\Customer ' ,
265
+ \ Magento \Customer \Model \Customer::class ,
260
266
[
261
267
'getId ' ,
262
268
'setId ' ,
@@ -274,8 +280,13 @@ public function testSave()
274
280
'' ,
275
281
false
276
282
);
283
+
284
+ $ this ->customer ->expects ($ this ->atLeastOnce ())
285
+ ->method ('__toArray ' )
286
+ ->willReturn (['default_billing ' , 'default_shipping ' ]);
287
+
277
288
$ customerAttributesMetaData = $ this ->getMockForAbstractClass (
278
- ' Magento\Framework\Api\CustomAttributesDataInterface ' ,
289
+ \ Magento \Framework \Api \CustomAttributesDataInterface::class ,
279
290
[],
280
291
'' ,
281
292
false ,
@@ -290,7 +301,7 @@ public function testSave()
290
301
]
291
302
);
292
303
$ customerSecureData = $ this ->getMock (
293
- ' Magento\Customer\Model\Data\CustomerSecure ' ,
304
+ \ Magento \Customer \Model \Data \CustomerSecure::class ,
294
305
[
295
306
'getRpToken ' ,
296
307
'getRpTokenCreatedAt ' ,
@@ -338,7 +349,7 @@ public function testSave()
338
349
->with ([$ address ]);
339
350
$ this ->extensibleDataObjectConverter ->expects ($ this ->once ())
340
351
->method ('toNestedArray ' )
341
- ->with ($ customerAttributesMetaData , [], ' \Magento\Customer\Api\Data\CustomerInterface ' )
352
+ ->with ($ customerAttributesMetaData , [], \Magento \Customer \Api \Data \CustomerInterface::class )
342
353
->willReturn (['customerData ' ]);
343
354
$ this ->customerFactory ->expects ($ this ->once ())
344
355
->method ('create ' )
@@ -347,7 +358,7 @@ public function testSave()
347
358
$ customerModel ->expects ($ this ->once ())
348
359
->method ('getStoreId ' )
349
360
->willReturn (null );
350
- $ store = $ this ->getMock (' Magento\Store\Model\Store ' , [], [], '' , false );
361
+ $ store = $ this ->getMock (\ Magento \Store \Model \Store::class , [], [], '' , false );
351
362
$ store ->expects ($ this ->once ())
352
363
->method ('getId ' )
353
364
->willReturn ($ storeId );
@@ -444,9 +455,9 @@ public function testSaveWithPasswordHash()
444
455
$ passwordHash = 'ukfa4sdfa56s5df02asdf4rt ' ;
445
456
$ this ->prepareMocksForValidation (true );
446
457
447
- $ region = $ this ->getMockForAbstractClass (' Magento\Customer\Api\Data\RegionInterface ' , [], '' , false );
458
+ $ region = $ this ->getMockForAbstractClass (\ Magento \Customer \Api \Data \RegionInterface::class , [], '' , false );
448
459
$ address = $ this ->getMockForAbstractClass (
449
- ' Magento\Customer\Api\Data\AddressInterface ' ,
460
+ \ Magento \Customer \Api \Data \AddressInterface::class ,
450
461
[],
451
462
'' ,
452
463
false ,
@@ -460,7 +471,7 @@ public function testSaveWithPasswordHash()
460
471
]
461
472
);
462
473
$ address2 = $ this ->getMockForAbstractClass (
463
- ' Magento\Customer\Api\Data\AddressInterface ' ,
474
+ \ Magento \Customer \Api \Data \AddressInterface::class ,
464
475
[],
465
476
'' ,
466
477
false ,
@@ -473,8 +484,13 @@ public function testSaveWithPasswordHash()
473
484
'getId '
474
485
]
475
486
);
487
+
488
+ $ this ->customer ->expects ($ this ->atLeastOnce ())
489
+ ->method ('__toArray ' )
490
+ ->willReturn (['default_billing ' , 'default_shipping ' ]);
491
+
476
492
$ customerModel = $ this ->getMock (
477
- ' Magento\Customer\Model\Customer ' ,
493
+ \ Magento \Customer \Model \Customer::class ,
478
494
[
479
495
'getId ' ,
480
496
'setId ' ,
@@ -493,7 +509,7 @@ public function testSaveWithPasswordHash()
493
509
false
494
510
);
495
511
$ customerAttributesMetaData = $ this ->getMockForAbstractClass (
496
- ' Magento\Framework\Api\CustomAttributesDataInterface ' ,
512
+ \ Magento \Framework \Api \CustomAttributesDataInterface::class ,
497
513
[],
498
514
'' ,
499
515
false ,
@@ -545,7 +561,7 @@ public function testSaveWithPasswordHash()
545
561
->with ([$ address ]);
546
562
$ this ->extensibleDataObjectConverter ->expects ($ this ->once ())
547
563
->method ('toNestedArray ' )
548
- ->with ($ customerAttributesMetaData , [], ' \Magento\Customer\Api\Data\CustomerInterface ' )
564
+ ->with ($ customerAttributesMetaData , [], \Magento \Customer \Api \Data \CustomerInterface::class )
549
565
->willReturn (['customerData ' ]);
550
566
$ this ->customerFactory ->expects ($ this ->once ())
551
567
->method ('create ' )
@@ -554,7 +570,7 @@ public function testSaveWithPasswordHash()
554
570
$ customerModel ->expects ($ this ->once ())
555
571
->method ('getStoreId ' )
556
572
->willReturn (null );
557
- $ store = $ this ->getMock (' Magento\Store\Model\Store ' , [], [], '' , false );
573
+ $ store = $ this ->getMock (\ Magento \Store \Model \Store::class , [], [], '' , false );
558
574
$ store ->expects ($ this ->once ())
559
575
->method ('getId ' )
560
576
->willReturn ($ storeId );
@@ -625,24 +641,24 @@ public function testSaveWithException()
625
641
*/
626
642
public function testGetList ()
627
643
{
628
- $ sortOrder = $ this ->getMock (' Magento\Framework\Api\SortOrder ' , [], [], '' , false );
629
- $ filterGroup = $ this ->getMock (' Magento\Framework\Api\Search\FilterGroup ' , [], [], '' , false );
630
- $ filter = $ this ->getMock (' Magento\Framework\Api\Filter ' , [], [], '' , false );
631
- $ collection = $ this ->getMock (' Magento\Customer\Model\ResourceModel\Customer\Collection ' , [], [], '' , false );
644
+ $ sortOrder = $ this ->getMock (\ Magento \Framework \Api \SortOrder::class , [], [], '' , false );
645
+ $ filterGroup = $ this ->getMock (\ Magento \Framework \Api \Search \FilterGroup::class , [], [], '' , false );
646
+ $ filter = $ this ->getMock (\ Magento \Framework \Api \Filter::class , [], [], '' , false );
647
+ $ collection = $ this ->getMock (\ Magento \Customer \Model \ResourceModel \Customer \Collection::class , [], [], '' , false );
632
648
$ searchResults = $ this ->getMockForAbstractClass (
633
- ' Magento\Customer\Api\Data\AddressSearchResultsInterface ' ,
649
+ \ Magento \Customer \Api \Data \AddressSearchResultsInterface::class ,
634
650
[],
635
651
'' ,
636
652
false
637
653
);
638
654
$ searchCriteria = $ this ->getMockForAbstractClass (
639
- ' Magento\Framework\Api\SearchCriteriaInterface ' ,
655
+ \ Magento \Framework \Api \SearchCriteriaInterface::class ,
640
656
[],
641
657
'' ,
642
658
false
643
659
);
644
660
$ customerModel = $ this ->getMock (
645
- ' Magento\Customer\Model\Customer ' ,
661
+ \ Magento \Customer \Model \Customer::class ,
646
662
[
647
663
'getId ' ,
648
664
'setId ' ,
@@ -661,7 +677,7 @@ public function testGetList()
661
677
false
662
678
);
663
679
$ metadata = $ this ->getMockForAbstractClass (
664
- ' Magento\Customer\Api\Data\AttributeMetadataInterface ' ,
680
+ \ Magento \Customer \Api \Data \AttributeMetadataInterface::class ,
665
681
[],
666
682
'' ,
667
683
false
@@ -681,7 +697,7 @@ public function testGetList()
681
697
->willReturn ($ collection );
682
698
$ this ->extensionAttributesJoinProcessor ->expects ($ this ->once ())
683
699
->method ('process ' )
684
- ->with ($ collection , ' Magento\Customer\Api\Data\CustomerInterface ' );
700
+ ->with ($ collection , \ Magento \Customer \Api \Data \CustomerInterface::class );
685
701
$ this ->customerMetadata ->expects ($ this ->once ())
686
702
->method ('getAllAttributesMetadata ' )
687
703
->willReturn ([$ metadata ]);
@@ -782,7 +798,7 @@ public function testDeleteById()
782
798
{
783
799
$ customerId = 14 ;
784
800
$ customerModel = $ this ->getMock (
785
- ' Magento\Customer\Model\Customer ' ,
801
+ \ Magento \Customer \Model \Customer::class ,
786
802
['delete ' ],
787
803
[],
788
804
'' ,
@@ -807,7 +823,7 @@ public function testDelete()
807
823
{
808
824
$ customerId = 14 ;
809
825
$ customerModel = $ this ->getMock (
810
- ' Magento\Customer\Model\Customer ' ,
826
+ \ Magento \Customer \Model \Customer::class ,
811
827
['delete ' ],
812
828
[],
813
829
'' ,
0 commit comments