@@ -142,6 +142,11 @@ class AccountManagementTest extends \PHPUnit\Framework\TestCase
142142 */
143143 private $ saveHandler ;
144144
145+ /**
146+ * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Customer\Model\AddressRegistry
147+ */
148+ private $ addressRegistryMock ;
149+
145150 /**
146151 * @SuppressWarnings(PHPMD.ExcessiveMethodLength)
147152 */
@@ -176,6 +181,7 @@ protected function setUp()
176181 $ this ->dateTime = $ this ->createMock (\Magento \Framework \Stdlib \DateTime::class);
177182 $ this ->customer = $ this ->createMock (\Magento \Customer \Model \Customer::class);
178183 $ this ->objectFactory = $ this ->createMock (\Magento \Framework \DataObjectFactory::class);
184+ $ this ->addressRegistryMock = $ this ->createMock (\Magento \Customer \Model \AddressRegistry::class);
179185 $ this ->extensibleDataObjectConverter = $ this ->createMock (
180186 \Magento \Framework \Api \ExtensibleDataObjectConverter::class
181187 );
@@ -239,6 +245,7 @@ protected function setUp()
239245 'sessionManager ' => $ this ->sessionManager ,
240246 'saveHandler ' => $ this ->saveHandler ,
241247 'visitorCollectionFactory ' => $ this ->visitorCollectionFactory ,
248+ 'addressRegistry ' => $ this ->addressRegistryMock ,
242249 ]
243250 );
244251 $ this ->objectManagerHelper ->setBackwardCompatibleProperty (
@@ -1071,6 +1078,7 @@ public function testSendPasswordReminderEmail()
10711078 protected function prepareInitiatePasswordReset ($ email , $ templateIdentifier , $ sender , $ storeId , $ customerId , $ hash )
10721079 {
10731080 $ websiteId = 1 ;
1081+ $ addressId = 5 ;
10741082
10751083 $ datetime = $ this ->prepareDateTimeFactory ();
10761084
@@ -1088,6 +1096,17 @@ protected function prepareInitiatePasswordReset($email, $templateIdentifier, $se
10881096 ->method ('getStore ' )
10891097 ->willReturn ($ this ->store );
10901098
1099+ /** @var \Magento\Customer\Model\Address|\PHPUnit_Framework_MockObject_MockObject $addressModel */
1100+ $ addressModel = $ this ->getMockBuilder (\Magento \Customer \Model \Address::class)->disableOriginalConstructor ()
1101+ ->setMethods (['setShouldIgnoreValidation ' ])->getMock ();
1102+
1103+ /** @var \Magento\Customer\Api\Data\AddressInterface|\PHPUnit_Framework_MockObject_MockObject $customer */
1104+ $ address = $ this ->createMock (\Magento \Customer \Api \Data \AddressInterface::class);
1105+ $ address ->expects ($ this ->once ())
1106+ ->method ('getId ' )
1107+ ->willReturn ($ addressId );
1108+
1109+ /** @var \Magento\Customer\Api\Data\CustomerInterface|\PHPUnit_Framework_MockObject_MockObject $customer */
10911110 $ customer = $ this ->getMockBuilder (\Magento \Customer \Api \Data \CustomerInterface::class)
10921111 ->getMock ();
10931112 $ customer ->expects ($ this ->any ())
@@ -1099,6 +1118,20 @@ protected function prepareInitiatePasswordReset($email, $templateIdentifier, $se
10991118 $ customer ->expects ($ this ->any ())
11001119 ->method ('getStoreId ' )
11011120 ->willReturn ($ storeId );
1121+ $ customer ->expects ($ this ->any ())
1122+ ->method ('getAddresses ' )
1123+ ->willReturn ([$ address ]);
1124+
1125+ $ this ->customerRepository ->expects ($ this ->once ())
1126+ ->method ('get ' )
1127+ ->willReturn ($ customer );
1128+ $ this ->addressRegistryMock ->expects ($ this ->once ())
1129+ ->method ('retrieve ' )
1130+ ->with ($ addressId )
1131+ ->willReturn ($ addressModel );
1132+ $ addressModel ->expects ($ this ->once ())
1133+ ->method ('setShouldIgnoreValidation ' )
1134+ ->with (true );
11021135
11031136 $ this ->customerRepository ->expects ($ this ->once ())
11041137 ->method ('get ' )
0 commit comments