Skip to content

Commit e8ae44e

Browse files
author
Oleksii Korshenko
authored
MAGETWO-82652: #7915: customer objects are equal to eachother after observing event customer_save_after_data_object #11676
2 parents b78dacf + e88eed6 commit e8ae44e

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
@@ -246,7 +246,7 @@ public function save(\Magento\Customer\Api\Data\CustomerInterface $customer, $pa
246246
$savedCustomer = $this->get($customer->getEmail(), $customer->getWebsiteId());
247247
$this->eventManager->dispatch(
248248
'customer_save_after_data_object',
249-
['customer_data_object' => $savedCustomer, 'orig_customer_data_object' => $customer]
249+
['customer_data_object' => $savedCustomer, 'orig_customer_data_object' => $prevCustomerData]
250250
);
251251
return $savedCustomer;
252252
}

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,8 @@ public function testSave()
241241
'save',
242242
]);
243243

244+
$origCustomer = $this->customer;
245+
244246
$this->customer->expects($this->atLeastOnce())
245247
->method('__toArray')
246248
->willReturn(['default_billing', 'default_shipping']);
@@ -417,7 +419,7 @@ public function testSave()
417419
->method('dispatch')
418420
->with(
419421
'customer_save_after_data_object',
420-
['customer_data_object' => $this->customer, 'orig_customer_data_object' => $customerAttributesMetaData]
422+
['customer_data_object' => $this->customer, 'orig_customer_data_object' => $origCustomer]
421423
);
422424

423425
$this->model->save($this->customer);
@@ -475,6 +477,8 @@ public function testSaveWithPasswordHash()
475477
]
476478
);
477479

480+
$origCustomer = $this->customer;
481+
478482
$this->customer->expects($this->atLeastOnce())
479483
->method('__toArray')
480484
->willReturn(['default_billing', 'default_shipping']);
@@ -642,7 +646,7 @@ public function testSaveWithPasswordHash()
642646
->method('dispatch')
643647
->with(
644648
'customer_save_after_data_object',
645-
['customer_data_object' => $this->customer, 'orig_customer_data_object' => $customerAttributesMetaData]
649+
['customer_data_object' => $this->customer, 'orig_customer_data_object' => $origCustomer]
646650
);
647651

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

0 commit comments

Comments
 (0)