Skip to content

Commit d91fd5d

Browse files
committed
Merge remote-tracking branch 'origin/MAGETWO-60247' into 2.0-develop-pr1
2 parents 49ea588 + c40ff47 commit d91fd5d

File tree

2 files changed

+35
-86
lines changed
  • app/code/Magento/Customer

2 files changed

+35
-86
lines changed

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ protected function _extractData(
7272
$scope = null
7373
) {
7474
$metadataForm = $this->getMetadataForm($entityType, $formCode, $scope);
75+
76+
/** @var array $formData */
7577
$formData = $metadataForm->extractData($this->getRequest(), $scope);
78+
$formData = $metadataForm->compactData($formData);
7679

7780
// Initialize additional attributes
7881
/** @var \Magento\Framework\DataObject $object */
@@ -82,11 +85,6 @@ protected function _extractData(
8285
$formData[$attributeCode] = isset($requestData[$attributeCode]) ? $requestData[$attributeCode] : false;
8386
}
8487

85-
$result = $metadataForm->compactData($formData);
86-
87-
// Re-initialize additional attributes
88-
$formData = array_replace($formData, $result);
89-
9088
// Unset unused attributes
9189
$formAttributes = $metadataForm->getAttributes();
9290
foreach ($formAttributes as $attribute) {

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

Lines changed: 32 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -291,32 +291,28 @@ public function testExecuteWithExistentCustomer()
291291
],
292292
'subscription' => $subscription,
293293
];
294-
$filteredData = [
294+
$extractedData = [
295295
'entity_id' => $customerId,
296296
'code' => 'value',
297297
'coolness' => false,
298298
'disable_auto_group_change' => 'false',
299299
];
300-
$dataToCompact = [
300+
$compactedData = [
301301
'entity_id' => $customerId,
302302
'code' => 'value',
303303
'coolness' => false,
304304
'disable_auto_group_change' => 'false',
305-
CustomerInterface::DEFAULT_BILLING => false,
306-
CustomerInterface::DEFAULT_SHIPPING => false,
307-
'confirmation' => false,
308-
'sendemail_store_id' => false,
305+
CustomerInterface::DEFAULT_BILLING => 2,
306+
CustomerInterface::DEFAULT_SHIPPING => 2,
309307
];
310-
$addressFilteredData = [
308+
$addressExtractedData = [
311309
'entity_id' => $addressId,
312-
'default_billing' => 'true',
313-
'default_shipping' => 'true',
314310
'code' => 'value',
315311
'coolness' => false,
316312
'region' => 'region',
317313
'region_id' => 'region_id',
318314
];
319-
$addressDataToCompact = [
315+
$addressCompactedData = [
320316
'entity_id' => $addressId,
321317
'default_billing' => 'true',
322318
'default_shipping' => 'true',
@@ -417,11 +413,11 @@ public function testExecuteWithExistentCustomer()
417413
$customerFormMock->expects($this->once())
418414
->method('extractData')
419415
->with($this->requestMock, 'customer')
420-
->willReturn($filteredData);
416+
->willReturn($extractedData);
421417
$customerFormMock->expects($this->once())
422418
->method('compactData')
423-
->with($dataToCompact)
424-
->willReturn($filteredData);
419+
->with($extractedData)
420+
->willReturn($compactedData);
425421
$customerFormMock->expects($this->once())
426422
->method('getAttributes')
427423
->willReturn($attributes);
@@ -432,11 +428,11 @@ public function testExecuteWithExistentCustomer()
432428
$customerAddressFormMock->expects($this->once())
433429
->method('extractData')
434430
->with($this->requestMock, 'address/' . $addressId)
435-
->willReturn($addressFilteredData);
431+
->willReturn($addressExtractedData);
436432
$customerAddressFormMock->expects($this->once())
437433
->method('compactData')
438-
->with($addressDataToCompact)
439-
->willReturn($addressFilteredData);
434+
->with($addressExtractedData)
435+
->willReturn($addressCompactedData);
440436
$customerAddressFormMock->expects($this->once())
441437
->method('getAttributes')
442438
->willReturn($attributes);
@@ -606,8 +602,6 @@ public function testExecuteWithNewCustomer()
606602
'_template_' => '_template_',
607603
$addressId => [
608604
'entity_id' => $addressId,
609-
'default_billing' => 'false',
610-
'default_shipping' => 'false',
611605
'code' => 'value',
612606
'coolness' => false,
613607
'region' => 'region',
@@ -616,31 +610,12 @@ public function testExecuteWithNewCustomer()
616610
],
617611
'subscription' => $subscription,
618612
];
619-
$filteredData = [
613+
$extractedData = [
620614
'coolness' => false,
621615
'disable_auto_group_change' => 'false',
622616
];
623-
$dataToCompact = [
624-
'coolness' => false,
625-
'disable_auto_group_change' => 'false',
626-
CustomerInterface::DEFAULT_BILLING => false,
627-
CustomerInterface::DEFAULT_SHIPPING => false,
628-
'confirmation' => false,
629-
'sendemail_store_id' => false,
630-
];
631-
$addressFilteredData = [
617+
$addressExtractedData = [
632618
'entity_id' => $addressId,
633-
'default_billing' => 'false',
634-
'default_shipping' => 'false',
635-
'code' => 'value',
636-
'coolness' => false,
637-
'region' => 'region',
638-
'region_id' => 'region_id',
639-
];
640-
$addressDataToCompact = [
641-
'entity_id' => $addressId,
642-
'default_billing' => 'false',
643-
'default_shipping' => 'false',
644619
'code' => 'value',
645620
'coolness' => false,
646621
'region' => 'region',
@@ -720,11 +695,11 @@ public function testExecuteWithNewCustomer()
720695
$customerFormMock->expects($this->once())
721696
->method('extractData')
722697
->with($this->requestMock, 'customer')
723-
->willReturn($filteredData);
698+
->willReturn($extractedData);
724699
$customerFormMock->expects($this->once())
725700
->method('compactData')
726-
->with($dataToCompact)
727-
->willReturn($filteredData);
701+
->with($extractedData)
702+
->willReturn($extractedData);
728703
$customerFormMock->expects($this->once())
729704
->method('getAttributes')
730705
->willReturn($attributes);
@@ -735,11 +710,11 @@ public function testExecuteWithNewCustomer()
735710
$customerAddressFormMock->expects($this->once())
736711
->method('extractData')
737712
->with($this->requestMock, 'address/' . $addressId)
738-
->willReturn($addressFilteredData);
713+
->willReturn($addressExtractedData);
739714
$customerAddressFormMock->expects($this->once())
740715
->method('compactData')
741-
->with($addressDataToCompact)
742-
->willReturn($addressFilteredData);
716+
->with($addressExtractedData)
717+
->willReturn($addressExtractedData);
743718
$customerAddressFormMock->expects($this->once())
744719
->method('getAttributes')
745720
->willReturn($attributes);
@@ -893,18 +868,10 @@ public function testExecuteWithNewCustomerAndValidationException()
893868
],
894869
'subscription' => $subscription,
895870
];
896-
$filteredData = [
871+
$extractedData = [
897872
'coolness' => false,
898873
'disable_auto_group_change' => 'false',
899874
];
900-
$dataToCompact = [
901-
'coolness' => false,
902-
'disable_auto_group_change' => 'false',
903-
CustomerInterface::DEFAULT_BILLING => false,
904-
CustomerInterface::DEFAULT_SHIPPING => false,
905-
'confirmation' => false,
906-
'sendemail_store_id' => false,
907-
];
908875

909876
/** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $attributeMock */
910877
$attributeMock = $this->getMockBuilder('Magento\Customer\Api\Data\AttributeMetadataInterface')
@@ -954,11 +921,11 @@ public function testExecuteWithNewCustomerAndValidationException()
954921
$customerFormMock->expects($this->once())
955922
->method('extractData')
956923
->with($this->requestMock, 'customer')
957-
->willReturn($filteredData);
924+
->willReturn($extractedData);
958925
$customerFormMock->expects($this->once())
959926
->method('compactData')
960-
->with($dataToCompact)
961-
->willReturn($filteredData);
927+
->with($extractedData)
928+
->willReturn($extractedData);
962929
$customerFormMock->expects($this->once())
963930
->method('getAttributes')
964931
->willReturn($attributes);
@@ -1045,18 +1012,10 @@ public function testExecuteWithNewCustomerAndLocalizedException()
10451012
],
10461013
'subscription' => $subscription,
10471014
];
1048-
$filteredData = [
1015+
$extractedData = [
10491016
'coolness' => false,
10501017
'disable_auto_group_change' => 'false',
10511018
];
1052-
$dataToCompact = [
1053-
'coolness' => false,
1054-
'disable_auto_group_change' => 'false',
1055-
CustomerInterface::DEFAULT_BILLING => false,
1056-
CustomerInterface::DEFAULT_SHIPPING => false,
1057-
'confirmation' => false,
1058-
'sendemail_store_id' => false,
1059-
];
10601019

10611020
/** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $attributeMock */
10621021
$attributeMock = $this->getMockBuilder('Magento\Customer\Api\Data\AttributeMetadataInterface')
@@ -1106,11 +1065,11 @@ public function testExecuteWithNewCustomerAndLocalizedException()
11061065
$customerFormMock->expects($this->once())
11071066
->method('extractData')
11081067
->with($this->requestMock, 'customer')
1109-
->willReturn($filteredData);
1068+
->willReturn($extractedData);
11101069
$customerFormMock->expects($this->once())
11111070
->method('compactData')
1112-
->with($dataToCompact)
1113-
->willReturn($filteredData);
1071+
->with($extractedData)
1072+
->willReturn($extractedData);
11141073
$customerFormMock->expects($this->once())
11151074
->method('getAttributes')
11161075
->willReturn($attributes);
@@ -1197,17 +1156,9 @@ public function testExecuteWithNewCustomerAndException()
11971156
],
11981157
'subscription' => $subscription,
11991158
];
1200-
$filteredData = [
1201-
'coolness' => false,
1202-
'disable_auto_group_change' => 'false',
1203-
];
1204-
$dataToCompact = [
1159+
$extractedData = [
12051160
'coolness' => false,
12061161
'disable_auto_group_change' => 'false',
1207-
CustomerInterface::DEFAULT_BILLING => false,
1208-
CustomerInterface::DEFAULT_SHIPPING => false,
1209-
'confirmation' => false,
1210-
'sendemail_store_id' => false,
12111162
];
12121163

12131164
/** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $attributeMock */
@@ -1258,11 +1209,11 @@ public function testExecuteWithNewCustomerAndException()
12581209
$customerFormMock->expects($this->once())
12591210
->method('extractData')
12601211
->with($this->requestMock, 'customer')
1261-
->willReturn($filteredData);
1212+
->willReturn($extractedData);
12621213
$customerFormMock->expects($this->once())
12631214
->method('compactData')
1264-
->with($dataToCompact)
1265-
->willReturn($filteredData);
1215+
->with($extractedData)
1216+
->willReturn($extractedData);
12661217
$customerFormMock->expects($this->once())
12671218
->method('getAttributes')
12681219
->willReturn($attributes);

0 commit comments

Comments
 (0)