Skip to content

Commit 0718f39

Browse files
committed
Merge remote-tracking branch 'tango-ce/MAGETWO-60155' into MAGETWO-60347
2 parents 203886e + 79cb90f commit 0718f39

File tree

2 files changed

+33
-91
lines changed
  • app/code/Magento/Customer

2 files changed

+33
-91
lines changed

app/code/Magento/Customer/Controller/Adminhtml/Index/Save.php

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ protected function _extractData(
7272
) {
7373
$metadataForm = $this->getMetadataForm($entityType, $formCode, $scope);
7474
$formData = $metadataForm->extractData($this->getRequest(), $scope);
75+
$formData = $metadataForm->compactData($formData);
7576

7677
// Initialize additional attributes
7778
/** @var \Magento\Framework\DataObject $object */
@@ -81,11 +82,6 @@ protected function _extractData(
8182
$formData[$attributeCode] = isset($requestData[$attributeCode]) ? $requestData[$attributeCode] : false;
8283
}
8384

84-
$result = $metadataForm->compactData($formData);
85-
86-
// Re-initialize additional attributes
87-
$formData = array_replace($result, $formData);
88-
8985
// Unset unused attributes
9086
$formAttributes = $metadataForm->getAttributes();
9187
foreach ($formAttributes as $attribute) {

app/code/Magento/Customer/Test/Unit/Controller/Adminhtml/Index/SaveTest.php

Lines changed: 32 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -304,33 +304,28 @@ public function testExecuteWithExistentCustomer()
304304
],
305305
'subscription' => $subscription,
306306
];
307-
$filteredData = [
307+
$extractedData = [
308308
'entity_id' => $customerId,
309309
'code' => 'value',
310310
'coolness' => false,
311311
'disable_auto_group_change' => 'false',
312312
];
313-
$dataToCompact = [
313+
$compactedData = [
314314
'entity_id' => $customerId,
315315
'code' => 'value',
316316
'coolness' => false,
317317
'disable_auto_group_change' => 'false',
318-
CustomerInterface::DEFAULT_BILLING => false,
319-
CustomerInterface::DEFAULT_SHIPPING => false,
320-
'confirmation' => false,
321-
'sendemail_store_id' => false,
322-
'extension_attributes' => false,
318+
CustomerInterface::DEFAULT_BILLING => 2,
319+
CustomerInterface::DEFAULT_SHIPPING => 2
323320
];
324-
$addressFilteredData = [
321+
$addressExtractedData = [
325322
'entity_id' => $addressId,
326-
'default_billing' => 'true',
327-
'default_shipping' => 'true',
328323
'code' => 'value',
329324
'coolness' => false,
330325
'region' => 'region',
331326
'region_id' => 'region_id',
332327
];
333-
$addressDataToCompact = [
328+
$addressCompactedData = [
334329
'entity_id' => $addressId,
335330
'default_billing' => 'true',
336331
'default_shipping' => 'true',
@@ -430,11 +425,11 @@ public function testExecuteWithExistentCustomer()
430425
$customerFormMock->expects($this->once())
431426
->method('extractData')
432427
->with($this->requestMock, 'customer')
433-
->willReturn($filteredData);
428+
->willReturn($extractedData);
434429
$customerFormMock->expects($this->once())
435430
->method('compactData')
436-
->with($dataToCompact)
437-
->willReturn($filteredData);
431+
->with($extractedData)
432+
->willReturn($compactedData);
438433
$customerFormMock->expects($this->once())
439434
->method('getAttributes')
440435
->willReturn($attributes);
@@ -445,11 +440,11 @@ public function testExecuteWithExistentCustomer()
445440
$customerAddressFormMock->expects($this->once())
446441
->method('extractData')
447442
->with($this->requestMock, 'address/' . $addressId)
448-
->willReturn($addressFilteredData);
443+
->willReturn($addressExtractedData);
449444
$customerAddressFormMock->expects($this->once())
450445
->method('compactData')
451-
->with($addressDataToCompact)
452-
->willReturn($addressFilteredData);
446+
->with($addressExtractedData)
447+
->willReturn($addressCompactedData);
453448
$customerAddressFormMock->expects($this->once())
454449
->method('getAttributes')
455450
->willReturn($attributes);
@@ -625,8 +620,6 @@ public function testExecuteWithNewCustomer()
625620
'_template_' => '_template_',
626621
$addressId => [
627622
'entity_id' => $addressId,
628-
'default_billing' => 'false',
629-
'default_shipping' => 'false',
630623
'code' => 'value',
631624
'coolness' => false,
632625
'region' => 'region',
@@ -635,32 +628,12 @@ public function testExecuteWithNewCustomer()
635628
],
636629
'subscription' => $subscription,
637630
];
638-
$filteredData = [
631+
$extractedData = [
639632
'coolness' => false,
640633
'disable_auto_group_change' => 'false',
641634
];
642-
$dataToCompact = [
643-
'coolness' => false,
644-
'disable_auto_group_change' => 'false',
645-
CustomerInterface::DEFAULT_BILLING => false,
646-
CustomerInterface::DEFAULT_SHIPPING => false,
647-
'confirmation' => false,
648-
'sendemail_store_id' => false,
649-
'extension_attributes' => false,
650-
];
651-
$addressFilteredData = [
635+
$addressExtractedData = [
652636
'entity_id' => $addressId,
653-
'default_billing' => 'false',
654-
'default_shipping' => 'false',
655-
'code' => 'value',
656-
'coolness' => false,
657-
'region' => 'region',
658-
'region_id' => 'region_id',
659-
];
660-
$addressDataToCompact = [
661-
'entity_id' => $addressId,
662-
'default_billing' => 'false',
663-
'default_shipping' => 'false',
664637
'code' => 'value',
665638
'coolness' => false,
666639
'region' => 'region',
@@ -739,11 +712,11 @@ public function testExecuteWithNewCustomer()
739712
$customerFormMock->expects($this->once())
740713
->method('extractData')
741714
->with($this->requestMock, 'customer')
742-
->willReturn($filteredData);
715+
->willReturn($extractedData);
743716
$customerFormMock->expects($this->once())
744717
->method('compactData')
745-
->with($dataToCompact)
746-
->willReturn($filteredData);
718+
->with($extractedData)
719+
->willReturn($extractedData);
747720
$customerFormMock->expects($this->once())
748721
->method('getAttributes')
749722
->willReturn($attributes);
@@ -754,11 +727,11 @@ public function testExecuteWithNewCustomer()
754727
$customerAddressFormMock->expects($this->once())
755728
->method('extractData')
756729
->with($this->requestMock, 'address/' . $addressId)
757-
->willReturn($addressFilteredData);
730+
->willReturn($addressExtractedData);
758731
$customerAddressFormMock->expects($this->once())
759732
->method('compactData')
760-
->with($addressDataToCompact)
761-
->willReturn($addressFilteredData);
733+
->with($addressExtractedData)
734+
->willReturn($addressExtractedData);
762735
$customerAddressFormMock->expects($this->once())
763736
->method('getAttributes')
764737
->willReturn($attributes);
@@ -910,19 +883,10 @@ public function testExecuteWithNewCustomerAndValidationException()
910883
],
911884
'subscription' => $subscription,
912885
];
913-
$filteredData = [
886+
$extractedData = [
914887
'coolness' => false,
915888
'disable_auto_group_change' => 'false',
916889
];
917-
$dataToCompact = [
918-
'coolness' => false,
919-
'disable_auto_group_change' => 'false',
920-
CustomerInterface::DEFAULT_BILLING => false,
921-
CustomerInterface::DEFAULT_SHIPPING => false,
922-
'confirmation' => false,
923-
'sendemail_store_id' => false,
924-
'extension_attributes' => false,
925-
];
926890

927891
/** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $customerFormMock */
928892
$attributeMock = $this->getMockBuilder(
@@ -971,11 +935,11 @@ public function testExecuteWithNewCustomerAndValidationException()
971935
$customerFormMock->expects($this->once())
972936
->method('extractData')
973937
->with($this->requestMock, 'customer')
974-
->willReturn($filteredData);
938+
->willReturn($extractedData);
975939
$customerFormMock->expects($this->once())
976940
->method('compactData')
977-
->with($dataToCompact)
978-
->willReturn($filteredData);
941+
->with($extractedData)
942+
->willReturn($extractedData);
979943
$customerFormMock->expects($this->once())
980944
->method('getAttributes')
981945
->willReturn($attributes);
@@ -1062,19 +1026,10 @@ public function testExecuteWithNewCustomerAndLocalizedException()
10621026
],
10631027
'subscription' => $subscription,
10641028
];
1065-
$filteredData = [
1029+
$extractedData = [
10661030
'coolness' => false,
10671031
'disable_auto_group_change' => 'false',
10681032
];
1069-
$dataToCompact = [
1070-
'coolness' => false,
1071-
'disable_auto_group_change' => 'false',
1072-
CustomerInterface::DEFAULT_BILLING => false,
1073-
CustomerInterface::DEFAULT_SHIPPING => false,
1074-
'confirmation' => false,
1075-
'sendemail_store_id' => false,
1076-
'extension_attributes' => false,
1077-
];
10781033

10791034
/** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $customerFormMock */
10801035
$attributeMock = $this->getMockBuilder(
@@ -1124,11 +1079,11 @@ public function testExecuteWithNewCustomerAndLocalizedException()
11241079
$customerFormMock->expects($this->once())
11251080
->method('extractData')
11261081
->with($this->requestMock, 'customer')
1127-
->willReturn($filteredData);
1082+
->willReturn($extractedData);
11281083
$customerFormMock->expects($this->once())
11291084
->method('compactData')
1130-
->with($dataToCompact)
1131-
->willReturn($filteredData);
1085+
->with($extractedData)
1086+
->willReturn($extractedData);
11321087
$customerFormMock->expects($this->once())
11331088
->method('getAttributes')
11341089
->willReturn($attributes);
@@ -1214,18 +1169,9 @@ public function testExecuteWithNewCustomerAndException()
12141169
],
12151170
'subscription' => $subscription,
12161171
];
1217-
$filteredData = [
1218-
'coolness' => false,
1219-
'disable_auto_group_change' => 'false',
1220-
];
1221-
$dataToCompact = [
1172+
$extractedData = [
12221173
'coolness' => false,
12231174
'disable_auto_group_change' => 'false',
1224-
CustomerInterface::DEFAULT_BILLING => false,
1225-
CustomerInterface::DEFAULT_SHIPPING => false,
1226-
'confirmation' => false,
1227-
'sendemail_store_id' => false,
1228-
'extension_attributes' => false,
12291175
];
12301176

12311177
/** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $customerFormMock */
@@ -1275,11 +1221,11 @@ public function testExecuteWithNewCustomerAndException()
12751221
$customerFormMock->expects($this->once())
12761222
->method('extractData')
12771223
->with($this->requestMock, 'customer')
1278-
->willReturn($filteredData);
1224+
->willReturn($extractedData);
12791225
$customerFormMock->expects($this->once())
12801226
->method('compactData')
1281-
->with($dataToCompact)
1282-
->willReturn($filteredData);
1227+
->with($extractedData)
1228+
->willReturn($extractedData);
12831229
$customerFormMock->expects($this->once())
12841230
->method('getAttributes')
12851231
->willReturn($attributes);

0 commit comments

Comments
 (0)