Skip to content

Commit e745a69

Browse files
author
Sergey Shvets
committed
MAGETWO-55814: East team cadenece 3 PR
fixed static tests
1 parent 1163d1e commit e745a69

File tree

2 files changed

+20
-7
lines changed
  • app/code/Magento

2 files changed

+20
-7
lines changed

app/code/Magento/Catalog/Controller/Adminhtml/Product/Attribute/Validate.php

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,13 +90,8 @@ public function execute()
9090
}
9191
}
9292

93-
$options = $this->getRequest()->getParam("option");
94-
if (is_array($options)) {
95-
if (!$this->isUniqueAdminValues($options['value'], $options['delete'])) {
96-
$this->setMessageToResponse($response, [__("The value of Admin must be unique.")]);
97-
$response->setError(true);
98-
};
99-
}
93+
$this->checkUniqueOption($response);
94+
10095
return $this->resultJsonFactory->create()->setJsonData($response->toJson());
10196
}
10297

@@ -133,4 +128,18 @@ private function setMessageToResponse($response, $messages)
133128
}
134129
return $response->setData($messageKey, $messages);
135130
}
131+
132+
/**
133+
* @param DataObject $response
134+
* @param array|null $options
135+
* @return $this
136+
*/
137+
private function checkUniqueOption(DataObject $response, array $options = null)
138+
{
139+
if (is_array($options) and !$this->isUniqueAdminValues($options['value'], $options['delete'])) {
140+
$this->setMessageToResponse($response, [__("The value of Admin must be unique.")]);
141+
$response->setError(true);
142+
}
143+
return $this;
144+
}
136145
}

app/code/Magento/Swatches/Test/Unit/Controller/Adminhtml/Product/Attribute/Plugin/ValidateTest.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@ public function testAfterExecute(array $dataRequest, $isError)
5353
$controller->afterExecute($subject, $response);
5454
}
5555

56+
/**
57+
* @SuppressWarnings(PHPMD.ExcessiveMethodLength)
58+
* @return array
59+
*/
5660
public function providerData()
5761
{
5862
return [

0 commit comments

Comments
 (0)