Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/MAGETWO-60248' into 2.1-develop-pr1
Browse files Browse the repository at this point in the history
  • Loading branch information
ameysar committed Nov 10, 2016
2 parents e110bb5 + 093a625 commit 108714d
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 99 deletions.
10 changes: 2 additions & 8 deletions app/code/Magento/Customer/Controller/Adminhtml/Index/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,7 @@
use Magento\Customer\Model\Metadata\Form;
use Magento\Framework\Exception\LocalizedException;

/**
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/

class Save extends \Magento\Customer\Controller\Adminhtml\Index
{
/**
Expand Down Expand Up @@ -81,6 +79,7 @@ protected function _extractData(
) {
$metadataForm = $metadataForm ? $metadataForm : $this->getMetadataForm($entityType, $formCode, $scope);
$formData = $metadataForm->extractData($request, $scope);
$formData = $metadataForm->compactData($formData);

// Initialize additional attributes
/** @var \Magento\Framework\DataObject $object */
Expand All @@ -90,11 +89,6 @@ protected function _extractData(
$formData[$attributeCode] = isset($requestData[$attributeCode]) ? $requestData[$attributeCode] : false;
}

$result = $metadataForm->compactData($formData);

// Re-initialize additional attributes
$formData = array_replace($formData, $result);

// Unset unused attributes
$formAttributes = $metadataForm->getAttributes();
foreach ($formAttributes as $attribute) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,33 +302,28 @@ public function testExecuteWithExistentCustomer()
],
'subscription' => $subscription,
];
$filteredData = [
$extractedData = [
'entity_id' => $customerId,
'code' => 'value',
'coolness' => false,
'disable_auto_group_change' => 'false',
];
$dataToCompact = [
$compactedData = [
'entity_id' => $customerId,
'code' => 'value',
'coolness' => false,
'disable_auto_group_change' => 'false',
CustomerInterface::DEFAULT_BILLING => false,
CustomerInterface::DEFAULT_SHIPPING => false,
'confirmation' => false,
'sendemail_store_id' => false,
'extension_attributes' => false,
CustomerInterface::DEFAULT_BILLING => 2,
CustomerInterface::DEFAULT_SHIPPING => 2
];
$addressFilteredData = [
$addressExtractedData = [
'entity_id' => $addressId,
'default_billing' => 'true',
'default_shipping' => 'true',
'code' => 'value',
'coolness' => false,
'region' => 'region',
'region_id' => 'region_id',
];
$addressDataToCompact = [
$addressCompactedData = [
'entity_id' => $addressId,
'default_billing' => 'true',
'default_shipping' => 'true',
Expand Down Expand Up @@ -428,11 +423,11 @@ public function testExecuteWithExistentCustomer()
$customerFormMock->expects($this->once())
->method('extractData')
->with($this->requestMock, 'customer')
->willReturn($filteredData);
->willReturn($extractedData);
$customerFormMock->expects($this->once())
->method('compactData')
->with($dataToCompact)
->willReturn($filteredData);
->with($extractedData)
->willReturn($compactedData);
$customerFormMock->expects($this->once())
->method('getAttributes')
->willReturn($attributes);
Expand All @@ -443,11 +438,11 @@ public function testExecuteWithExistentCustomer()
$customerAddressFormMock->expects($this->once())
->method('extractData')
->with($this->requestMock, 'address/' . $addressId)
->willReturn($addressFilteredData);
->willReturn($addressExtractedData);
$customerAddressFormMock->expects($this->once())
->method('compactData')
->with($addressDataToCompact)
->willReturn($addressFilteredData);
->with($addressExtractedData)
->willReturn($addressCompactedData);
$customerAddressFormMock->expects($this->once())
->method('getAttributes')
->willReturn($attributes);
Expand Down Expand Up @@ -635,33 +630,13 @@ public function testExecuteWithNewCustomer()
],
'subscription' => $subscription,
];
$filteredData = [
$extractedData = [
'coolness' => false,
'disable_auto_group_change' => 'false',
];
$dataToCompact = [
'coolness' => false,
'disable_auto_group_change' => 'false',
CustomerInterface::DEFAULT_BILLING => false,
CustomerInterface::DEFAULT_SHIPPING => false,
'confirmation' => false,
'sendemail_store_id' => false,
'extension_attributes' => false,
];
$addressFilteredData = [
$addressExtractedData = [
'entity_id' => $addressId,
'default_billing' => 'false',
'default_shipping' => 'false',
'code' => 'value',
'coolness' => false,
'region' => 'region',
'region_id' => 'region_id',
];
$addressDataToCompact = [
'entity_id' => $addressId,
'default_billing' => 'false',
'default_shipping' => 'false',
'code' => 'value',
'code' => 'value',
'coolness' => false,
'region' => 'region',
'region_id' => 'region_id',
Expand Down Expand Up @@ -739,11 +714,11 @@ public function testExecuteWithNewCustomer()
$customerFormMock->expects($this->once())
->method('extractData')
->with($this->requestMock, 'customer')
->willReturn($filteredData);
->willReturn($extractedData);
$customerFormMock->expects($this->once())
->method('compactData')
->with($dataToCompact)
->willReturn($filteredData);
->with($extractedData)
->willReturn($extractedData);
$customerFormMock->expects($this->once())
->method('getAttributes')
->willReturn($attributes);
Expand All @@ -754,11 +729,11 @@ public function testExecuteWithNewCustomer()
$customerAddressFormMock->expects($this->once())
->method('extractData')
->with($this->requestMock, 'address/' . $addressId)
->willReturn($addressFilteredData);
->willReturn($addressExtractedData);
$customerAddressFormMock->expects($this->once())
->method('compactData')
->with($addressDataToCompact)
->willReturn($addressFilteredData);
->with($addressExtractedData)
->willReturn($addressExtractedData);
$customerAddressFormMock->expects($this->once())
->method('getAttributes')
->willReturn($attributes);
Expand Down Expand Up @@ -912,19 +887,10 @@ public function testExecuteWithNewCustomerAndValidationException()
],
'subscription' => $subscription,
];
$filteredData = [
$extractedData = [
'coolness' => false,
'disable_auto_group_change' => 'false',
];
$dataToCompact = [
'coolness' => false,
'disable_auto_group_change' => 'false',
CustomerInterface::DEFAULT_BILLING => false,
CustomerInterface::DEFAULT_SHIPPING => false,
'confirmation' => false,
'sendemail_store_id' => false,
'extension_attributes' => false,
];

/** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $customerFormMock */
$attributeMock = $this->getMockBuilder('Magento\Customer\Api\Data\AttributeMetadataInterface')
Expand Down Expand Up @@ -973,11 +939,11 @@ public function testExecuteWithNewCustomerAndValidationException()
$customerFormMock->expects($this->once())
->method('extractData')
->with($this->requestMock, 'customer')
->willReturn($filteredData);
->willReturn($extractedData);
$customerFormMock->expects($this->once())
->method('compactData')
->with($dataToCompact)
->willReturn($filteredData);
->with($extractedData)
->willReturn($extractedData);
$customerFormMock->expects($this->once())
->method('getAttributes')
->willReturn($attributes);
Expand Down Expand Up @@ -1064,18 +1030,9 @@ public function testExecuteWithNewCustomerAndLocalizedException()
],
'subscription' => $subscription,
];
$filteredData = [
'coolness' => false,
'disable_auto_group_change' => 'false',
];
$dataToCompact = [
$extractedData = [
'coolness' => false,
'disable_auto_group_change' => 'false',
CustomerInterface::DEFAULT_BILLING => false,
CustomerInterface::DEFAULT_SHIPPING => false,
'confirmation' => false,
'sendemail_store_id' => false,
'extension_attributes' => false,
];

/** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $customerFormMock */
Expand Down Expand Up @@ -1126,11 +1083,11 @@ public function testExecuteWithNewCustomerAndLocalizedException()
$customerFormMock->expects($this->once())
->method('extractData')
->with($this->requestMock, 'customer')
->willReturn($filteredData);
->willReturn($extractedData);
$customerFormMock->expects($this->once())
->method('compactData')
->with($dataToCompact)
->willReturn($filteredData);
->with($extractedData)
->willReturn($extractedData);
$customerFormMock->expects($this->once())
->method('getAttributes')
->willReturn($attributes);
Expand Down Expand Up @@ -1216,19 +1173,10 @@ public function testExecuteWithNewCustomerAndException()
],
'subscription' => $subscription,
];
$filteredData = [
$extractedData = [
'coolness' => false,
'disable_auto_group_change' => 'false',
];
$dataToCompact = [
'coolness' => false,
'disable_auto_group_change' => 'false',
CustomerInterface::DEFAULT_BILLING => false,
CustomerInterface::DEFAULT_SHIPPING => false,
'confirmation' => false,
'sendemail_store_id' => false,
'extension_attributes' => false,
];

/** @var AttributeMetadataInterface|\PHPUnit_Framework_MockObject_MockObject $customerFormMock */
$attributeMock = $this->getMockBuilder('Magento\Customer\Api\Data\AttributeMetadataInterface')
Expand Down Expand Up @@ -1277,11 +1225,11 @@ public function testExecuteWithNewCustomerAndException()
$customerFormMock->expects($this->once())
->method('extractData')
->with($this->requestMock, 'customer')
->willReturn($filteredData);
->willReturn($extractedData);
$customerFormMock->expects($this->once())
->method('compactData')
->with($dataToCompact)
->willReturn($filteredData);
->with($extractedData)
->willReturn($extractedData);
$customerFormMock->expects($this->once())
->method('getAttributes')
->willReturn($attributes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -567,12 +567,19 @@ public function clickBaseImage()
*/
public function closeFullImage()
{
$element = $this->browser->find($this->fullImageClose, Locator::SELECTOR_CSS);
if (!$element->isVisible()) {
$element->hover();
$this->waitForElementVisible($this->fullImageClose);
}
$element->click();
$this->_rootElement->waitUntil(
function () {
$this->browser->find($this->fullImage)->hover();

if ($this->browser->find($this->fullImageClose)->isVisible()) {
$this->browser->find($this->fullImageClose)->click();

return true;
}

return null;
}
);
}

/**
Expand Down

0 comments on commit 108714d

Please sign in to comment.