Skip to content

Commit 13e2cee

Browse files
committed
ENGCOM-3056: Unit tests fix.
1 parent 67edfb6 commit 13e2cee

File tree

1 file changed

+35
-26
lines changed

1 file changed

+35
-26
lines changed

app/code/Magento/Customer/Test/Unit/Model/AccountManagementTest.php

Lines changed: 35 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66

77
namespace Magento\Customer\Test\Unit\Model;
88

9+
use Magento\Customer\Api\Data\CustomerInterface;
910
use Magento\Customer\Model\AccountConfirmation;
1011
use Magento\Customer\Model\AccountManagement;
1112
use Magento\Customer\Model\AuthenticationInterface;
13+
use Magento\Customer\Model\Data\Customer;
1214
use Magento\Customer\Model\EmailNotificationInterface;
1315
use Magento\Framework\Api\SearchCriteriaBuilder;
1416
use Magento\Framework\App\Area;
@@ -283,7 +285,7 @@ public function testCreateAccountWithPasswordHashWithExistingCustomer()
283285
$website->expects($this->once())
284286
->method('getStoreIds')
285287
->willReturn([1, 2, 3]);
286-
$customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)->getMock();
288+
$customer = $this->getMockBuilder(Customer::class)->disableOriginalConstructor()->getMock();
287289
$customer->expects($this->once())
288290
->method('getId')
289291
->willReturn($customerId);
@@ -339,7 +341,7 @@ public function testCreateAccountWithPasswordHashWithCustomerWithoutStoreId()
339341
$website->expects($this->once())
340342
->method('getDefaultStore')
341343
->willReturn($store);
342-
$customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)->getMock();
344+
$customer = $this->getMockBuilder(Customer::class)->disableOriginalConstructor()->getMock();
343345
$customer->expects($this->atLeastOnce())
344346
->method('getId')
345347
->willReturn($customerId);
@@ -415,7 +417,7 @@ public function testCreateAccountWithPasswordHashWithLocalizedException()
415417
$website->expects($this->once())
416418
->method('getDefaultStore')
417419
->willReturn($store);
418-
$customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)->getMock();
420+
$customer = $this->getMockBuilder(Customer::class)->disableOriginalConstructor()->getMock();
419421
$customer->expects($this->atLeastOnce())
420422
->method('getId')
421423
->willReturn($customerId);
@@ -494,7 +496,7 @@ public function testCreateAccountWithPasswordHashWithAddressException()
494496
$website->expects($this->once())
495497
->method('getDefaultStore')
496498
->willReturn($store);
497-
$customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)->getMock();
499+
$customer = $this->getMockBuilder(Customer::class)->disableOriginalConstructor()->getMock();
498500
$customer->expects($this->atLeastOnce())
499501
->method('getId')
500502
->willReturn($customerId);
@@ -563,8 +565,9 @@ public function testCreateAccountWithPasswordHashWithNewCustomerAndLocalizedExce
563565
$websiteId = 1;
564566
$hash = '4nj54lkj5jfi03j49f8bgujfgsd';
565567

566-
$customerMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)
567-
->getMockForAbstractClass();
568+
$customerMock = $this->getMockBuilder(Customer::class)
569+
->disableOriginalConstructor()
570+
->getMock();
568571

569572
$customerMock->expects($this->atLeastOnce())
570573
->method('getId')
@@ -655,7 +658,7 @@ public function testCreateAccountWithoutPassword()
655658
$website->expects($this->once())
656659
->method('getDefaultStore')
657660
->willReturn($store);
658-
$customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)->getMock();
661+
$customer = $this->getMockBuilder(Customer::class)->disableOriginalConstructor()->getMock();
659662
$customer->expects($this->atLeastOnce())
660663
->method('getId')
661664
->willReturn($customerId);
@@ -800,7 +803,7 @@ public function testCreateAccountWithPasswordInputException(
800803
$minCharacterSetsNum . '. Classes of characters: Lower Case, Upper Case, Digits, Special Characters.');
801804
}
802805

803-
$customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)->getMock();
806+
$customer = $this->getMockBuilder(Customer::class)->disableOriginalConstructor()->getMock();
804807
$this->accountManagement->createAccount($customer, $password);
805808
}
806809

@@ -821,7 +824,7 @@ public function testCreateAccountInputExceptionExtraLongPassword()
821824
$this->expectException(\Magento\Framework\Exception\InputException::class);
822825
$this->expectExceptionMessage('Please enter a password with at most 256 characters.');
823826

824-
$customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)->getMock();
827+
$customer = $this->getMockBuilder(Customer::class)->disableOriginalConstructor()->getMock();
825828
$this->accountManagement->createAccount($customer, $password);
826829
}
827830

@@ -900,7 +903,7 @@ public function testCreateAccountWithPassword()
900903
$website->expects($this->once())
901904
->method('getDefaultStore')
902905
->willReturn($store);
903-
$customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)->getMock();
906+
$customer = $this->getMockBuilder(Customer::class)->disableOriginalConstructor()->getMock();
904907
$customer->expects($this->atLeastOnce())
905908
->method('getId')
906909
->willReturn($customerId);
@@ -984,7 +987,8 @@ public function testSendPasswordReminderEmail()
984987
$templateIdentifier = 'Template Identifier';
985988
$sender = 'Sender';
986989

987-
$customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)
990+
$customer = $this->getMockBuilder(Customer::class)
991+
->disableOriginalConstructor()
988992
->getMock();
989993
$customer->expects($this->any())
990994
->method('getStoreId')
@@ -1016,7 +1020,7 @@ public function testSendPasswordReminderEmail()
10161020

10171021
$this->dataObjectProcessor->expects($this->once())
10181022
->method('buildOutputDataArray')
1019-
->with($customer, \Magento\Customer\Api\Data\CustomerInterface::class)
1023+
->with($customer, CustomerInterface::class)
10201024
->willReturn($customerData);
10211025

10221026
$this->customerViewHelper->expects($this->any())
@@ -1111,8 +1115,9 @@ protected function prepareInitiatePasswordReset($email, $templateIdentifier, $se
11111115
->method('getId')
11121116
->willReturn($addressId);
11131117

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()
11161121
->getMock();
11171122
$customer->expects($this->any())
11181123
->method('getEmail')
@@ -1173,7 +1178,7 @@ protected function prepareInitiatePasswordReset($email, $templateIdentifier, $se
11731178
->willReturn($this->customerSecure);
11741179
$this->dataObjectProcessor->expects($this->any())
11751180
->method('buildOutputDataArray')
1176-
->with($customer, \Magento\Customer\Api\Data\CustomerInterface::class)
1181+
->with($customer, Customer::class)
11771182
->willReturn($customerData);
11781183

11791184
$this->prepareEmailSend($email, $templateIdentifier, $sender, $storeId, $customerName);
@@ -1467,7 +1472,8 @@ public function testChangePassword()
14671472
$passwordHash = '1a2b3f4c';
14681473

14691474
$this->reInitModel();
1470-
$customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)
1475+
$customer = $this->getMockBuilder(Customer::class)
1476+
->disableOriginalConstructor()
14711477
->getMock();
14721478
$customer->expects($this->any())
14731479
->method('getId')
@@ -1572,8 +1578,8 @@ public function testResetPassword()
15721578
->method('getId')
15731579
->willReturn($addressId);
15741580

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();
15771583
$customer->expects($this->any())->method('getId')->willReturn($customerId);
15781584
$customer->expects($this->any())
15791585
->method('getAddresses')
@@ -1658,7 +1664,8 @@ public function testAuthenticate()
16581664
$password = '1234567';
16591665
$passwordHash = '1a2b3f4c';
16601666

1661-
$customerData = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)
1667+
$customerData = $this->getMockBuilder(Customer::class)
1668+
->disableOriginalConstructor()
16621669
->getMock();
16631670

16641671
$customerModel = $this->getMockBuilder(\Magento\Customer\Model\Customer::class)
@@ -1723,7 +1730,7 @@ public function testGetConfirmationStatus(
17231730
$customerId = 1;
17241731
$customerEmail = 'test1@example.com';
17251732

1726-
$customerMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)
1733+
$customerMock = $this->getMockBuilder(Customer::class)
17271734
->disableOriginalConstructor()
17281735
->getMock();
17291736
$customerMock->expects($this->once())
@@ -1793,8 +1800,9 @@ public function testCreateAccountWithPasswordHashForGuest()
17931800
->method('getStore')
17941801
->willReturn($storeMock);
17951802

1796-
$customerMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)
1797-
->getMockForAbstractClass();
1803+
$customerMock = $this->getMockBuilder(Customer::class)
1804+
->disableOriginalConstructor()
1805+
->getMock();
17981806
$customerMock->expects($this->exactly(2))
17991807
->method('getId')
18001808
->willReturn(null);
@@ -1877,7 +1885,7 @@ public function testCreateAccountWithPasswordHashWithCustomerAddresses()
18771885
->method("setId")
18781886
->with(null);
18791887
//Handle Customer calls
1880-
$customer = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)->getMock();
1888+
$customer = $this->getMockBuilder(Customer::class)->disableOriginalConstructor()->getMock();
18811889
$customer
18821890
->expects($this->atLeastOnce())
18831891
->method('getWebsiteId')
@@ -2003,7 +2011,7 @@ public function testCreateAccountUnexpectedValueException(): void
20032011
$website->expects($this->once())
20042012
->method('getDefaultStore')
20052013
->willReturn($store);
2006-
$customer = $this->createMock(\Magento\Customer\Api\Data\CustomerInterface::class);
2014+
$customer = $this->createMock(Customer::class);
20072015
$customer->expects($this->atLeastOnce())
20082016
->method('getId')
20092017
->willReturn($customerId);
@@ -2082,8 +2090,9 @@ public function testCreateAccountWithStoreNotInWebsite()
20822090
$storeId = 1;
20832091
$websiteId = 1;
20842092
$hash = '4nj54lkj5jfi03j49f8bgujfgsd';
2085-
$customerMock = $this->getMockBuilder(\Magento\Customer\Api\Data\CustomerInterface::class)
2086-
->getMockForAbstractClass();
2093+
$customerMock = $this->getMockBuilder(Customer::class)
2094+
->disableOriginalConstructor()
2095+
->getMock();
20872096
$customerMock->expects($this->atLeastOnce())
20882097
->method('getId')
20892098
->willReturn(null);

0 commit comments

Comments
 (0)