6
6
7
7
namespace Magento \Customer \Test \Unit \Model ;
8
8
9
+ use Magento \Customer \Api \Data \CustomerInterface ;
9
10
use Magento \Customer \Model \AccountConfirmation ;
10
11
use Magento \Customer \Model \AccountManagement ;
11
12
use Magento \Customer \Model \AuthenticationInterface ;
13
+ use Magento \Customer \Model \Data \Customer ;
12
14
use Magento \Customer \Model \EmailNotificationInterface ;
13
15
use Magento \Framework \Api \SearchCriteriaBuilder ;
14
16
use Magento \Framework \App \Area ;
@@ -283,7 +285,7 @@ public function testCreateAccountWithPasswordHashWithExistingCustomer()
283
285
$ website ->expects ($ this ->once ())
284
286
->method ('getStoreIds ' )
285
287
->willReturn ([1 , 2 , 3 ]);
286
- $ customer = $ this ->getMockBuilder (\ Magento \ Customer \ Api \ Data \CustomerInterface ::class)->getMock ();
288
+ $ customer = $ this ->getMockBuilder (Customer::class)-> disableOriginalConstructor ( )->getMock ();
287
289
$ customer ->expects ($ this ->once ())
288
290
->method ('getId ' )
289
291
->willReturn ($ customerId );
@@ -339,7 +341,7 @@ public function testCreateAccountWithPasswordHashWithCustomerWithoutStoreId()
339
341
$ website ->expects ($ this ->once ())
340
342
->method ('getDefaultStore ' )
341
343
->willReturn ($ store );
342
- $ customer = $ this ->getMockBuilder (\ Magento \ Customer \ Api \ Data \CustomerInterface ::class)->getMock ();
344
+ $ customer = $ this ->getMockBuilder (Customer::class)-> disableOriginalConstructor ( )->getMock ();
343
345
$ customer ->expects ($ this ->atLeastOnce ())
344
346
->method ('getId ' )
345
347
->willReturn ($ customerId );
@@ -415,7 +417,7 @@ public function testCreateAccountWithPasswordHashWithLocalizedException()
415
417
$ website ->expects ($ this ->once ())
416
418
->method ('getDefaultStore ' )
417
419
->willReturn ($ store );
418
- $ customer = $ this ->getMockBuilder (\ Magento \ Customer \ Api \ Data \CustomerInterface ::class)->getMock ();
420
+ $ customer = $ this ->getMockBuilder (Customer::class)-> disableOriginalConstructor ( )->getMock ();
419
421
$ customer ->expects ($ this ->atLeastOnce ())
420
422
->method ('getId ' )
421
423
->willReturn ($ customerId );
@@ -494,7 +496,7 @@ public function testCreateAccountWithPasswordHashWithAddressException()
494
496
$ website ->expects ($ this ->once ())
495
497
->method ('getDefaultStore ' )
496
498
->willReturn ($ store );
497
- $ customer = $ this ->getMockBuilder (\ Magento \ Customer \ Api \ Data \CustomerInterface ::class)->getMock ();
499
+ $ customer = $ this ->getMockBuilder (Customer::class)-> disableOriginalConstructor ( )->getMock ();
498
500
$ customer ->expects ($ this ->atLeastOnce ())
499
501
->method ('getId ' )
500
502
->willReturn ($ customerId );
@@ -563,8 +565,9 @@ public function testCreateAccountWithPasswordHashWithNewCustomerAndLocalizedExce
563
565
$ websiteId = 1 ;
564
566
$ hash = '4nj54lkj5jfi03j49f8bgujfgsd ' ;
565
567
566
- $ customerMock = $ this ->getMockBuilder (\Magento \Customer \Api \Data \CustomerInterface::class)
567
- ->getMockForAbstractClass ();
568
+ $ customerMock = $ this ->getMockBuilder (Customer::class)
569
+ ->disableOriginalConstructor ()
570
+ ->getMock ();
568
571
569
572
$ customerMock ->expects ($ this ->atLeastOnce ())
570
573
->method ('getId ' )
@@ -655,7 +658,7 @@ public function testCreateAccountWithoutPassword()
655
658
$ website ->expects ($ this ->once ())
656
659
->method ('getDefaultStore ' )
657
660
->willReturn ($ store );
658
- $ customer = $ this ->getMockBuilder (\ Magento \ Customer \ Api \ Data \CustomerInterface ::class)->getMock ();
661
+ $ customer = $ this ->getMockBuilder (Customer::class)-> disableOriginalConstructor ( )->getMock ();
659
662
$ customer ->expects ($ this ->atLeastOnce ())
660
663
->method ('getId ' )
661
664
->willReturn ($ customerId );
@@ -800,7 +803,7 @@ public function testCreateAccountWithPasswordInputException(
800
803
$ minCharacterSetsNum . '. Classes of characters: Lower Case, Upper Case, Digits, Special Characters. ' );
801
804
}
802
805
803
- $ customer = $ this ->getMockBuilder (\ Magento \ Customer \ Api \ Data \CustomerInterface ::class)->getMock ();
806
+ $ customer = $ this ->getMockBuilder (Customer::class)-> disableOriginalConstructor ( )->getMock ();
804
807
$ this ->accountManagement ->createAccount ($ customer , $ password );
805
808
}
806
809
@@ -821,7 +824,7 @@ public function testCreateAccountInputExceptionExtraLongPassword()
821
824
$ this ->expectException (\Magento \Framework \Exception \InputException::class);
822
825
$ this ->expectExceptionMessage ('Please enter a password with at most 256 characters. ' );
823
826
824
- $ customer = $ this ->getMockBuilder (\ Magento \ Customer \ Api \ Data \CustomerInterface ::class)->getMock ();
827
+ $ customer = $ this ->getMockBuilder (Customer::class)-> disableOriginalConstructor ( )->getMock ();
825
828
$ this ->accountManagement ->createAccount ($ customer , $ password );
826
829
}
827
830
@@ -900,7 +903,7 @@ public function testCreateAccountWithPassword()
900
903
$ website ->expects ($ this ->once ())
901
904
->method ('getDefaultStore ' )
902
905
->willReturn ($ store );
903
- $ customer = $ this ->getMockBuilder (\ Magento \ Customer \ Api \ Data \CustomerInterface ::class)->getMock ();
906
+ $ customer = $ this ->getMockBuilder (Customer::class)-> disableOriginalConstructor ( )->getMock ();
904
907
$ customer ->expects ($ this ->atLeastOnce ())
905
908
->method ('getId ' )
906
909
->willReturn ($ customerId );
@@ -984,7 +987,8 @@ public function testSendPasswordReminderEmail()
984
987
$ templateIdentifier = 'Template Identifier ' ;
985
988
$ sender = 'Sender ' ;
986
989
987
- $ customer = $ this ->getMockBuilder (\Magento \Customer \Api \Data \CustomerInterface::class)
990
+ $ customer = $ this ->getMockBuilder (Customer::class)
991
+ ->disableOriginalConstructor ()
988
992
->getMock ();
989
993
$ customer ->expects ($ this ->any ())
990
994
->method ('getStoreId ' )
@@ -1016,7 +1020,7 @@ public function testSendPasswordReminderEmail()
1016
1020
1017
1021
$ this ->dataObjectProcessor ->expects ($ this ->once ())
1018
1022
->method ('buildOutputDataArray ' )
1019
- ->with ($ customer , \ Magento \ Customer \ Api \ Data \ CustomerInterface::class)
1023
+ ->with ($ customer , CustomerInterface::class)
1020
1024
->willReturn ($ customerData );
1021
1025
1022
1026
$ this ->customerViewHelper ->expects ($ this ->any ())
@@ -1111,8 +1115,9 @@ protected function prepareInitiatePasswordReset($email, $templateIdentifier, $se
1111
1115
->method ('getId ' )
1112
1116
->willReturn ($ addressId );
1113
1117
1114
- /** @var \Magento\Customer\Api\Data\CustomerInterface|\PHPUnit_Framework_MockObject_MockObject $customer */
1115
- $ customer = $ this ->getMockBuilder (\Magento \Customer \Api \Data \CustomerInterface::class)
1118
+ /** @var Customer|\PHPUnit_Framework_MockObject_MockObject $customer */
1119
+ $ customer = $ this ->getMockBuilder (Customer::class)
1120
+ ->disableOriginalConstructor ()
1116
1121
->getMock ();
1117
1122
$ customer ->expects ($ this ->any ())
1118
1123
->method ('getEmail ' )
@@ -1173,7 +1178,7 @@ protected function prepareInitiatePasswordReset($email, $templateIdentifier, $se
1173
1178
->willReturn ($ this ->customerSecure );
1174
1179
$ this ->dataObjectProcessor ->expects ($ this ->any ())
1175
1180
->method ('buildOutputDataArray ' )
1176
- ->with ($ customer , \ Magento \ Customer \ Api \ Data \CustomerInterface ::class)
1181
+ ->with ($ customer , Customer::class)
1177
1182
->willReturn ($ customerData );
1178
1183
1179
1184
$ this ->prepareEmailSend ($ email , $ templateIdentifier , $ sender , $ storeId , $ customerName );
@@ -1467,7 +1472,8 @@ public function testChangePassword()
1467
1472
$ passwordHash = '1a2b3f4c ' ;
1468
1473
1469
1474
$ this ->reInitModel ();
1470
- $ customer = $ this ->getMockBuilder (\Magento \Customer \Api \Data \CustomerInterface::class)
1475
+ $ customer = $ this ->getMockBuilder (Customer::class)
1476
+ ->disableOriginalConstructor ()
1471
1477
->getMock ();
1472
1478
$ customer ->expects ($ this ->any ())
1473
1479
->method ('getId ' )
@@ -1572,8 +1578,8 @@ public function testResetPassword()
1572
1578
->method ('getId ' )
1573
1579
->willReturn ($ addressId );
1574
1580
1575
- /** @var \Magento\ Customer\Api\Data\CustomerInterface |\PHPUnit_Framework_MockObject_MockObject $customer */
1576
- $ customer = $ this ->getMockBuilder (\ Magento \ Customer \ Api \ Data \CustomerInterface ::class)->getMock ();
1581
+ /** @var Customer|\PHPUnit_Framework_MockObject_MockObject $customer */
1582
+ $ customer = $ this ->getMockBuilder (Customer::class)-> disableOriginalConstructor ( )->getMock ();
1577
1583
$ customer ->expects ($ this ->any ())->method ('getId ' )->willReturn ($ customerId );
1578
1584
$ customer ->expects ($ this ->any ())
1579
1585
->method ('getAddresses ' )
@@ -1658,7 +1664,8 @@ public function testAuthenticate()
1658
1664
$ password = '1234567 ' ;
1659
1665
$ passwordHash = '1a2b3f4c ' ;
1660
1666
1661
- $ customerData = $ this ->getMockBuilder (\Magento \Customer \Api \Data \CustomerInterface::class)
1667
+ $ customerData = $ this ->getMockBuilder (Customer::class)
1668
+ ->disableOriginalConstructor ()
1662
1669
->getMock ();
1663
1670
1664
1671
$ customerModel = $ this ->getMockBuilder (\Magento \Customer \Model \Customer::class)
@@ -1723,7 +1730,7 @@ public function testGetConfirmationStatus(
1723
1730
$ customerId = 1 ;
1724
1731
$ customerEmail = 'test1@example.com ' ;
1725
1732
1726
- $ customerMock = $ this ->getMockBuilder (\ Magento \ Customer \ Api \ Data \CustomerInterface ::class)
1733
+ $ customerMock = $ this ->getMockBuilder (Customer::class)
1727
1734
->disableOriginalConstructor ()
1728
1735
->getMock ();
1729
1736
$ customerMock ->expects ($ this ->once ())
@@ -1793,8 +1800,9 @@ public function testCreateAccountWithPasswordHashForGuest()
1793
1800
->method ('getStore ' )
1794
1801
->willReturn ($ storeMock );
1795
1802
1796
- $ customerMock = $ this ->getMockBuilder (\Magento \Customer \Api \Data \CustomerInterface::class)
1797
- ->getMockForAbstractClass ();
1803
+ $ customerMock = $ this ->getMockBuilder (Customer::class)
1804
+ ->disableOriginalConstructor ()
1805
+ ->getMock ();
1798
1806
$ customerMock ->expects ($ this ->exactly (2 ))
1799
1807
->method ('getId ' )
1800
1808
->willReturn (null );
@@ -1877,7 +1885,7 @@ public function testCreateAccountWithPasswordHashWithCustomerAddresses()
1877
1885
->method ("setId " )
1878
1886
->with (null );
1879
1887
//Handle Customer calls
1880
- $ customer = $ this ->getMockBuilder (\ Magento \ Customer \ Api \ Data \CustomerInterface ::class)->getMock ();
1888
+ $ customer = $ this ->getMockBuilder (Customer::class)-> disableOriginalConstructor ( )->getMock ();
1881
1889
$ customer
1882
1890
->expects ($ this ->atLeastOnce ())
1883
1891
->method ('getWebsiteId ' )
@@ -2003,7 +2011,7 @@ public function testCreateAccountUnexpectedValueException(): void
2003
2011
$ website ->expects ($ this ->once ())
2004
2012
->method ('getDefaultStore ' )
2005
2013
->willReturn ($ store );
2006
- $ customer = $ this ->createMock (\ Magento \ Customer \ Api \ Data \CustomerInterface ::class);
2014
+ $ customer = $ this ->createMock (Customer::class);
2007
2015
$ customer ->expects ($ this ->atLeastOnce ())
2008
2016
->method ('getId ' )
2009
2017
->willReturn ($ customerId );
@@ -2082,8 +2090,9 @@ public function testCreateAccountWithStoreNotInWebsite()
2082
2090
$ storeId = 1 ;
2083
2091
$ websiteId = 1 ;
2084
2092
$ hash = '4nj54lkj5jfi03j49f8bgujfgsd ' ;
2085
- $ customerMock = $ this ->getMockBuilder (\Magento \Customer \Api \Data \CustomerInterface::class)
2086
- ->getMockForAbstractClass ();
2093
+ $ customerMock = $ this ->getMockBuilder (Customer::class)
2094
+ ->disableOriginalConstructor ()
2095
+ ->getMock ();
2087
2096
$ customerMock ->expects ($ this ->atLeastOnce ())
2088
2097
->method ('getId ' )
2089
2098
->willReturn (null );
0 commit comments