Skip to content

Commit 2f1860b

Browse files
committed
MC-17648: Registration email confirmation bugfix
1 parent 200eab7 commit 2f1860b

File tree

2 files changed

+45
-20
lines changed

2 files changed

+45
-20
lines changed

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

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,15 @@ public function testGetCustomerData()
215215

216216
public function testGetCustomerActivateCustomer()
217217
{
218+
// Update the customer's confirmation key to a known value
219+
$this->customerData = $this->customerHelper->updateSampleCustomer(
220+
$this->customerData[Customer::ID],
221+
[
222+
'id' => $this->customerData[Customer::ID],
223+
'confirmation' => CustomerHelper::CONFIRMATION
224+
]
225+
);
226+
218227
$serviceInfo = [
219228
'rest' => [
220229
'resourcePath' => self::RESOURCE_PATH . '/activate',
@@ -228,14 +237,22 @@ public function testGetCustomerActivateCustomer()
228237
'token' => $this->token
229238
]
230239
];
231-
$requestData = ['confirmationKey' => $this->customerData[CustomerInterface::CONFIRMATION]];
240+
241+
$requestData = ['confirmationKey' => CustomerHelper::CONFIRMATION];
232242
if (TESTS_WEB_API_ADAPTER === 'soap') {
233243
$requestData['customerId'] = 0;
234244
}
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]));
245+
246+
try {
247+
$customerResponseData = $this->_webApiCall($serviceInfo, $requestData);
248+
$this->assertEquals(
249+
$this->customerData[CustomerInterface::ID],
250+
$customerResponseData[CustomerInterface::ID]
251+
);
252+
} catch (\Exception $e) {
253+
$this->fail('Customer is not activated.');
254+
}
255+
239256
}
240257

241258
/**

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

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,15 @@ public function testCreateCustomerWithoutOptionalFields()
249249
public function testActivateCustomer()
250250
{
251251
$customerData = $this->_createCustomer();
252-
$this->assertNotNull($customerData[Customer::CONFIRMATION], 'Customer activation is not required');
252+
253+
// Update the customer's confirmation key to a known value
254+
$customerData = $this->customerHelper->updateSampleCustomer(
255+
$customerData[Customer::ID],
256+
[
257+
'id' => $customerData[Customer::ID],
258+
'confirmation' => CustomerHelper::CONFIRMATION
259+
]
260+
);
253261

254262
$serviceInfo = [
255263
'rest' => [
@@ -265,16 +273,15 @@ public function testActivateCustomer()
265273

266274
$requestData = [
267275
'email' => $customerData[Customer::EMAIL],
268-
'confirmationKey' => $customerData[Customer::CONFIRMATION],
276+
'confirmationKey' => CustomerHelper::CONFIRMATION
269277
];
270278

271-
$result = $this->_webApiCall($serviceInfo, $requestData);
272-
273-
$this->assertEquals($customerData[Customer::ID], $result[Customer::ID], 'Wrong customer!');
274-
$this->assertTrue(
275-
!isset($result[Customer::CONFIRMATION]) || $result[Customer::CONFIRMATION] === null,
276-
'Customer is not activated!'
277-
);
279+
try {
280+
$result = $this->_webApiCall($serviceInfo, $requestData);
281+
$this->assertEquals($customerData[Customer::ID], $result[Customer::ID], 'Wrong customer!');
282+
} catch (\Exception $e) {
283+
$this->fail('Customer is not activated.');
284+
}
278285
}
279286

280287
public function testGetCustomerActivateCustomer()
@@ -294,14 +301,15 @@ public function testGetCustomerActivateCustomer()
294301
];
295302
$requestData = [
296303
'email' => $customerData[Customer::EMAIL],
297-
'confirmationKey' => $customerData[Customer::CONFIRMATION],
304+
'confirmationKey' => CustomerHelper::CONFIRMATION
298305
];
299306

300-
$customerResponseData = $this->_webApiCall($serviceInfo, $requestData);
301-
302-
$this->assertEquals($customerData[Customer::ID], $customerResponseData[Customer::ID]);
303-
// Confirmation key is removed after confirmation
304-
$this->assertFalse(isset($customerResponseData[Customer::CONFIRMATION]));
307+
try {
308+
$customerResponseData = $this->_webApiCall($serviceInfo, $requestData);
309+
$this->assertEquals($customerData[Customer::ID], $customerResponseData[Customer::ID]);
310+
} catch (\Exception $e) {
311+
$this->fail('Customer is not activated.');
312+
}
305313
}
306314

307315
public function testValidateResetPasswordLinkToken()

0 commit comments

Comments
 (0)