@@ -142,6 +142,11 @@ class AccountManagementTest extends \PHPUnit\Framework\TestCase
142
142
*/
143
143
private $ saveHandler ;
144
144
145
+ /**
146
+ * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Customer\Model\AddressRegistry
147
+ */
148
+ private $ addressRegistryMock ;
149
+
145
150
/**
146
151
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
147
152
*/
@@ -176,6 +181,7 @@ protected function setUp()
176
181
$ this ->dateTime = $ this ->createMock (\Magento \Framework \Stdlib \DateTime::class);
177
182
$ this ->customer = $ this ->createMock (\Magento \Customer \Model \Customer::class);
178
183
$ this ->objectFactory = $ this ->createMock (\Magento \Framework \DataObjectFactory::class);
184
+ $ this ->addressRegistryMock = $ this ->createMock (\Magento \Customer \Model \AddressRegistry::class);
179
185
$ this ->extensibleDataObjectConverter = $ this ->createMock (
180
186
\Magento \Framework \Api \ExtensibleDataObjectConverter::class
181
187
);
@@ -239,6 +245,7 @@ protected function setUp()
239
245
'sessionManager ' => $ this ->sessionManager ,
240
246
'saveHandler ' => $ this ->saveHandler ,
241
247
'visitorCollectionFactory ' => $ this ->visitorCollectionFactory ,
248
+ 'addressRegistry ' => $ this ->addressRegistryMock ,
242
249
]
243
250
);
244
251
$ this ->objectManagerHelper ->setBackwardCompatibleProperty (
@@ -1071,6 +1078,7 @@ public function testSendPasswordReminderEmail()
1071
1078
protected function prepareInitiatePasswordReset ($ email , $ templateIdentifier , $ sender , $ storeId , $ customerId , $ hash )
1072
1079
{
1073
1080
$ websiteId = 1 ;
1081
+ $ addressId = 5 ;
1074
1082
1075
1083
$ datetime = $ this ->prepareDateTimeFactory ();
1076
1084
@@ -1088,6 +1096,17 @@ protected function prepareInitiatePasswordReset($email, $templateIdentifier, $se
1088
1096
->method ('getStore ' )
1089
1097
->willReturn ($ this ->store );
1090
1098
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 */
1091
1110
$ customer = $ this ->getMockBuilder (\Magento \Customer \Api \Data \CustomerInterface::class)
1092
1111
->getMock ();
1093
1112
$ customer ->expects ($ this ->any ())
@@ -1099,6 +1118,20 @@ protected function prepareInitiatePasswordReset($email, $templateIdentifier, $se
1099
1118
$ customer ->expects ($ this ->any ())
1100
1119
->method ('getStoreId ' )
1101
1120
->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 );
1102
1135
1103
1136
$ this ->customerRepository ->expects ($ this ->once ())
1104
1137
->method ('get ' )
0 commit comments