Skip to content

Commit a180561

Browse files
author
Oleksii Korshenko
authored
MAGETWO-82529: #7915: customer objects are equal to eachother after observing event customer_save_after_data_object #11649
2 parents 1e20e63 + 51bdc6d commit a180561

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

app/code/Magento/Customer/Model/ResourceModel/CustomerRepository.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ public function save(\Magento\Customer\Api\Data\CustomerInterface $customer, $pa
237237
$savedCustomer = $this->get($customer->getEmail(), $customer->getWebsiteId());
238238
$this->eventManager->dispatch(
239239
'customer_save_after_data_object',
240-
['customer_data_object' => $savedCustomer, 'orig_customer_data_object' => $customer]
240+
['customer_data_object' => $savedCustomer, 'orig_customer_data_object' => $prevCustomerData]
241241
);
242242
return $savedCustomer;
243243
}

app/code/Magento/Customer/Test/Unit/Model/ResourceModel/CustomerRepositoryTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,8 @@ public function testSave()
230230
'save',
231231
]);
232232

233+
$origCustomer = $this->customer;
234+
233235
$this->customer->expects($this->atLeastOnce())
234236
->method('__toArray')
235237
->willReturn(['default_billing', 'default_shipping']);
@@ -406,7 +408,7 @@ public function testSave()
406408
->method('dispatch')
407409
->with(
408410
'customer_save_after_data_object',
409-
['customer_data_object' => $this->customer, 'orig_customer_data_object' => $customerAttributesMetaData]
411+
['customer_data_object' => $this->customer, 'orig_customer_data_object' => $origCustomer]
410412
);
411413

412414
$this->model->save($this->customer);
@@ -464,6 +466,8 @@ public function testSaveWithPasswordHash()
464466
]
465467
);
466468

469+
$origCustomer = $this->customer;
470+
467471
$this->customer->expects($this->atLeastOnce())
468472
->method('__toArray')
469473
->willReturn(['default_billing', 'default_shipping']);
@@ -631,7 +635,7 @@ public function testSaveWithPasswordHash()
631635
->method('dispatch')
632636
->with(
633637
'customer_save_after_data_object',
634-
['customer_data_object' => $this->customer, 'orig_customer_data_object' => $customerAttributesMetaData]
638+
['customer_data_object' => $this->customer, 'orig_customer_data_object' => $origCustomer]
635639
);
636640

637641
$this->model->save($this->customer, $passwordHash);

0 commit comments

Comments
 (0)