Skip to content

Commit 7b31a79

Browse files
author
Joan He
committed
Merge remote-tracking branch 'arcticfoxes/MC-17649' into 2.2.10-develop-pr
2 parents 3c10b02 + 1087cc9 commit 7b31a79

File tree

3 files changed

+36
-20
lines changed

3 files changed

+36
-20
lines changed

app/code/Magento/Customer/Model/AccountManagement.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,7 @@ protected function sendEmailConfirmation(CustomerInterface $customer, $redirectU
970970
null,
971971
$extensions
972972
);
973+
$customer->setConfirmation(null);
973974
} catch (MailException $e) {
974975
// If we are not able to send a new account email, this should be ignored
975976
$this->logger->critical($e);

dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementMeTest.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,14 +228,21 @@ public function testGetCustomerActivateCustomer()
228228
'token' => $this->token
229229
]
230230
];
231-
$requestData = ['confirmationKey' => $this->customerData[CustomerInterface::CONFIRMATION]];
231+
232+
$requestData = ['confirmationKey' => CustomerHelper::CONFIRMATION];
232233
if (TESTS_WEB_API_ADAPTER === 'soap') {
233234
$requestData['customerId'] = 0;
234235
}
235-
$customerResponseData = $this->_webApiCall($serviceInfo, $requestData);
236-
$this->assertEquals($this->customerData[CustomerInterface::ID], $customerResponseData[CustomerInterface::ID]);
237-
// Confirmation key is removed after confirmation
238-
$this->assertFalse(isset($customerResponseData[CustomerInterface::CONFIRMATION]));
236+
237+
try {
238+
$customerResponseData = $this->_webApiCall($serviceInfo, $requestData);
239+
$this->assertEquals(
240+
$this->customerData[CustomerInterface::ID],
241+
$customerResponseData[CustomerInterface::ID]
242+
);
243+
} catch (\Exception $e) {
244+
$this->fail('Customer is not activated.');
245+
}
239246
}
240247

241248
/**

dev/tests/api-functional/testsuite/Magento/Customer/Api/AccountManagementTest.php

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,15 @@ public function testCreateCustomerWithErrors()
220220
public function testActivateCustomer()
221221
{
222222
$customerData = $this->_createCustomer();
223-
$this->assertNotNull($customerData[Customer::CONFIRMATION], 'Customer activation is not required');
223+
224+
// Update the customer's confirmation key to a known value
225+
$customerData = $this->customerHelper->updateSampleCustomer(
226+
$customerData[Customer::ID],
227+
[
228+
'id' => $customerData[Customer::ID],
229+
'confirmation' => CustomerHelper::CONFIRMATION
230+
]
231+
);
224232

225233
$serviceInfo = [
226234
'rest' => [
@@ -236,16 +244,15 @@ public function testActivateCustomer()
236244

237245
$requestData = [
238246
'email' => $customerData[Customer::EMAIL],
239-
'confirmationKey' => $customerData[Customer::CONFIRMATION],
247+
'confirmationKey' => CustomerHelper::CONFIRMATION
240248
];
241249

242-
$result = $this->_webApiCall($serviceInfo, $requestData);
243-
244-
$this->assertEquals($customerData[Customer::ID], $result[Customer::ID], 'Wrong customer!');
245-
$this->assertTrue(
246-
!isset($result[Customer::CONFIRMATION]) || $result[Customer::CONFIRMATION] === null,
247-
'Customer is not activated!'
248-
);
250+
try {
251+
$result = $this->_webApiCall($serviceInfo, $requestData);
252+
$this->assertEquals($customerData[Customer::ID], $result[Customer::ID], 'Wrong customer!');
253+
} catch (\Exception $e) {
254+
$this->fail('Customer is not activated.');
255+
}
249256
}
250257

251258
public function testGetCustomerActivateCustomer()
@@ -265,14 +272,15 @@ public function testGetCustomerActivateCustomer()
265272
];
266273
$requestData = [
267274
'email' => $customerData[Customer::EMAIL],
268-
'confirmationKey' => $customerData[Customer::CONFIRMATION],
275+
'confirmationKey' => CustomerHelper::CONFIRMATION
269276
];
270277

271-
$customerResponseData = $this->_webApiCall($serviceInfo, $requestData);
272-
273-
$this->assertEquals($customerData[Customer::ID], $customerResponseData[Customer::ID]);
274-
// Confirmation key is removed after confirmation
275-
$this->assertFalse(isset($customerResponseData[Customer::CONFIRMATION]));
278+
try {
279+
$customerResponseData = $this->_webApiCall($serviceInfo, $requestData);
280+
$this->assertEquals($customerData[Customer::ID], $customerResponseData[Customer::ID]);
281+
} catch (\Exception $e) {
282+
$this->fail('Customer is not activated.');
283+
}
276284
}
277285

278286
public function testValidateResetPasswordLinkToken()

0 commit comments

Comments
 (0)