Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/2.3-develop' into ENGCOM-1816-ma…
Browse files Browse the repository at this point in the history
…gento-magento2-15624
  • Loading branch information
VasylShvorak committed Jul 4, 2018
2 parents 77bb78e + d7aafe9 commit c071076
Show file tree
Hide file tree
Showing 680 changed files with 3,980 additions and 96 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ public function testGetIdentity($expectedSum, $cacheTypes)
$this->assertEquals($expectedSum, $this->_messageModel->getIdentity());
}

/**
* @return array
*/
public function getIdentityDataProvider()
{
$cacheTypeMock1 = $this->createPartialMock(\stdClass::class, ['getCacheType']);
Expand Down Expand Up @@ -95,6 +98,9 @@ public function testIsDisplayed($expected, $allowed, $cacheTypes)
$this->assertEquals($expected, $this->_messageModel->isDisplayed());
}

/**
* @return array
*/
public function isDisplayedDataProvider()
{
$cacheTypesMock = $this->createPartialMock(\stdClass::class, ['getCacheType']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,9 @@ public function testIsDisplayed($expectedFirstRun, $data)
$this->assertEquals($expectedFirstRun, $model->isDisplayed());
}

/**
* @return array
*/
public function isDisplayedDataProvider()
{
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ public function testIsDisplayed($expectedResult, $cached, $response)
$this->assertEquals($expectedResult, $this->_messageModel->isDisplayed());
}

/**
* @return array
*/
public function isDisplayedDataProvider()
{
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,9 @@ public function testIsValidAddMessagesCall($value, $hasEmptyColumns, $customerGr
$this->tierPrice->isValid($value);
}

/**
* @return array
*/
public function isValidResultFalseDataProvider()
{
return [
Expand Down Expand Up @@ -286,6 +289,9 @@ public function isValidResultFalseDataProvider()
];
}

/**
* @return array
*/
public function isValidAddMessagesCallDataProvider()
{
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ public function testGetAllWebsitesValue()
$this->assertEquals($expectedResult, $result);
}

/**
* @return array
*/
public function isValidReturnDataProvider()
{
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ public function testInit()
$this->validator->init(null);
}

/**
* @return array
*/
public function isValidDataProvider()
{
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -768,6 +768,9 @@ public function testSaveProductPrices($priceData, $oldSkus, $priceIn, $callNum)
$this->invokeMethod($this->advancedPricing, 'saveProductPrices', [$priceData, 'table']);
}

/**
* @return array
*/
public function saveProductPricesDataProvider()
{
return [
Expand Down Expand Up @@ -839,6 +842,9 @@ public function testDeleteProductTierPrices(
);
}

/**
* @return array
*/
public function deleteProductTierPricesDataProvider()
{
return [
Expand Down Expand Up @@ -921,6 +927,9 @@ public function testProcessCountExistingPrices(
$this->invokeMethod($this->advancedPricing, 'processCountExistingPrices', [$prices, 'table']);
}

/**
* @return array
*/
public function processCountExistingPricesDataProvider()
{
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ public function testValidateNoOptions()
$this->assertEquals($expectedResult, $this->model->validate($options, $this->deploymentConfigMock));
}

/**
* @return array
*/
public function getCreateConfigDataProvider()
{
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public function testConvertBody($unserializedResult, $expected)
$this->assertEquals($expected, $this->converter->fromBody('body'));
}

/**
* @return array
*/
public function convertBodyDataProvider()
{
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,9 @@ public function testGetOperationsCountByBulkIdAndStatus()
$this->assertEquals($size, $this->model->getOperationsCountByBulkIdAndStatus($bulkUuid, $status));
}

/**
* @return array
*/
public function getFailedOperationsByBulkIdDataProvider()
{
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ public function testEntityToDatabase($identifier, $result)
$this->assertEquals($result, $this->model->entityToDatabase($entityType, $data));
}

/**
* @return array
*/
public function entityToDatabaseDataProvider()
{
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ public function testAfterTo($operationDetails)
$this->assertEquals(2, $result2['totalRecords']);
}

/**
* @return array
*/
public function afterToDataProvider()
{
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ public function testGetAllowedResourcesByUser()
);
}

/**
* @return AclRetriever
*/
protected function createAclRetriever()
{
$this->roleMock = $this->createPartialMock(\Magento\Authorization\Model\Role::class, ['getId', '__wakeup']);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ public function testGenerateHash($merchantMd5, $merchantApiLogin, $amount, $amou
);
}

/**
* @return array
*/
public function generateHashDataProvider()
{
return [
Expand All @@ -57,6 +60,13 @@ public function generateHashDataProvider()
];
}

/**
* @param $merchantMd5
* @param $merchantApiLogin
* @param $amount
* @param $transactionId
* @return string
*/
protected function generateHash($merchantMd5, $merchantApiLogin, $amount, $transactionId)
{
return strtoupper(md5($merchantMd5 . $merchantApiLogin . $transactionId . $amount));
Expand Down
113 changes: 94 additions & 19 deletions app/code/Magento/Backend/Block/Widget/Tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public function addTab($tabId, $tab)
if (empty($tabId)) {
throw new \Exception(__('Please correct the tab configuration and try again. Tab Id should be not empty'));
}

if (is_array($tab)) {
$this->_tabs[$tabId] = new \Magento\Framework\DataObject($tab);
} elseif ($tab instanceof \Magento\Framework\DataObject) {
Expand All @@ -126,13 +127,15 @@ public function addTab($tabId, $tab)
}
} elseif (is_string($tab)) {
$this->_addTabByName($tab, $tabId);

if (!$this->_tabs[$tabId] instanceof TabInterface) {
unset($this->_tabs[$tabId]);
return $this;
}
} else {
throw new \Exception(__('Please correct the tab configuration and try again.'));
}

if ($this->_tabs[$tabId]->getUrl() === null) {
$this->_tabs[$tabId]->setUrl('#');
}
Expand All @@ -143,10 +146,7 @@ public function addTab($tabId, $tab)

$this->_tabs[$tabId]->setId($tabId);
$this->_tabs[$tabId]->setTabId($tabId);

if ($this->_activeTab === null) {
$this->_activeTab = $tabId;
}

if (true === $this->_tabs[$tabId]->getActive()) {
$this->setActiveTab($tabId);
}
Expand Down Expand Up @@ -235,33 +235,108 @@ protected function _setActiveTab($tabId)
*/
protected function _beforeToHtml()
{
$this->_tabs = $this->reorderTabs();

if ($activeTab = $this->getRequest()->getParam('active_tab')) {
$this->setActiveTab($activeTab);
} elseif ($activeTabId = $this->_authSession->getActiveTabId()) {
$this->_setActiveTab($activeTabId);
}

$_new = [];
if ($this->_activeTab === null && !empty($this->_tabs)) {
/** @var TabInterface $tab */
$this->_activeTab = (reset($this->_tabs))->getId();
}

$this->assign('tabs', $this->_tabs);
return parent::_beforeToHtml();
}

/**
* Reorder the tabs.
*
* @return array
*/
private function reorderTabs()
{
$orderByIdentity = [];
$orderByPosition = [];
$position = 100;

/**
* Set the initial positions for each tab.
*
* @var string $key
* @var TabInterface $tab
*/
foreach ($this->_tabs as $key => $tab) {
foreach ($this->_tabs as $k => $t) {
if ($t->getAfter() == $key) {
$_new[$key] = $tab;
$_new[$k] = $t;
} else {
if (!$tab->getAfter() || !in_array($tab->getAfter(), array_keys($this->_tabs))) {
$_new[$key] = $tab;
}
}
}
$tab->setPosition($position);

$orderByIdentity[$key] = $tab;
$orderByPosition[$position] = $tab;

$position += 100;
}

$this->_tabs = $_new;
unset($_new);
return $this->applyTabsCorrectOrder($orderByPosition, $orderByIdentity);
}

$this->assign('tabs', $this->_tabs);
return parent::_beforeToHtml();
/**
* @param array $orderByPosition
* @param array $orderByIdentity
*
* @return array
*/
private function applyTabsCorrectOrder(array $orderByPosition, array $orderByIdentity)
{
$positionFactor = 1;

/**
* Rearrange the positions by using the after tag for each tab.
*
* @var integer $position
* @var TabInterface $tab
*/
foreach ($orderByPosition as $position => $tab) {
if (!$tab->getAfter() || !in_array($tab->getAfter(), array_keys($orderByIdentity))) {
$positionFactor = 1;
continue;
}

$grandPosition = $orderByIdentity[$tab->getAfter()]->getPosition();
$newPosition = $grandPosition + $positionFactor;

unset($orderByPosition[$position]);
$orderByPosition[$newPosition] = $tab;
$tab->setPosition($newPosition);

$positionFactor++;
}

return $this->finalTabsSortOrder($orderByPosition);
}

/**
* Apply the last sort order to tabs.
*
* @param array $orderByPosition
*
* @return array
*/
private function finalTabsSortOrder(array $orderByPosition)
{
ksort($orderByPosition);

$ordered = [];

/** @var TabInterface $tab */
foreach ($orderByPosition as $tab) {
$ordered[$tab->getId()] = $tab;
}

return $ordered;
}

/**
* @return string
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ public function testProcessNotLoggedInUser($isIFrameParam, $isAjaxParam, $isForw
$this->assertEquals($expectedResult, $this->plugin->aroundDispatch($subject, $proceed, $request));
}

/**
* @return array
*/
public function processNotLoggedInUserDataProvider()
{
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ public function testBeforeDispatchWhenMassactionPrepareKeyRequestExists($postDat
$this->plugin->beforeDispatch($this->subjectMock, $this->requestMock);
}

/**
* @return array
*/
public function beforeDispatchDataProvider()
{
return [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@

class ActionStub extends \Magento\Backend\App\Action
{
/**
* @return \Magento\Framework\App\ResponseInterface|\Magento\Framework\Controller\ResultInterface|void
*/
public function execute()
{
// Empty method stub for test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ public function testIsHostBackend($url, $host, $useCustomAdminUrl, $customAdminU
$this->assertEquals($this->model->isHostBackend(), $expectedValue);
}

/**
* @return array
*/
public function hostsDataProvider()
{
return [
Expand Down
Loading

0 comments on commit c071076

Please sign in to comment.