Skip to content

Commit 0d5274c

Browse files
author
Joan He
committed
Merge remote-tracking branch 'owls/MAGETWO-95048-sidebar-nav' into BugFixPR
2 parents 840a7aa + 0b02984 commit 0d5274c

File tree

3 files changed

+62
-9
lines changed

3 files changed

+62
-9
lines changed

app/code/Magento/Backend/Block/Menu.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@
99
/**
1010
* Backend menu block
1111
*
12-
* @api
13-
* @method \Magento\Backend\Block\Menu setAdditionalCacheKeyInfo(array $cacheKeyInfo)
12+
* @method $this setAdditionalCacheKeyInfo(array $cacheKeyInfo)
1413
* @method array getAdditionalCacheKeyInfo()
15-
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1614
* @api
1715
* @since 100.0.2
16+
*
17+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1818
*/
1919
class Menu extends \Magento\Backend\Block\Template
2020
{
@@ -75,21 +75,22 @@ class Menu extends \Magento\Backend\Block\Template
7575
private $anchorRenderer;
7676

7777
/**
78-
* @var ConfigInterface
78+
* @var \Magento\Framework\App\Route\ConfigInterface
7979
*/
8080
private $routeConfig;
8181

8282
/**
83-
* @param Template\Context $context
83+
* @param \Magento\Backend\Block\Template\Context $context
8484
* @param \Magento\Backend\Model\UrlInterface $url
8585
* @param \Magento\Backend\Model\Menu\Filter\IteratorFactory $iteratorFactory
8686
* @param \Magento\Backend\Model\Auth\Session $authSession
8787
* @param \Magento\Backend\Model\Menu\Config $menuConfig
8888
* @param \Magento\Framework\Locale\ResolverInterface $localeResolver
89-
* @param \Magento\Framework\App\Route\ConfigInterface $routeConfig
9089
* @param array $data
9190
* @param MenuItemChecker|null $menuItemChecker
9291
* @param AnchorRenderer|null $anchorRenderer
92+
* @param \Magento\Framework\App\Route\ConfigInterface|null $routeConfig
93+
*
9394
* @SuppressWarnings(PHPMD.ExcessiveParameterList)
9495
*/
9596
public function __construct(
@@ -141,6 +142,7 @@ protected function _getAnchorLabel($menuItem)
141142

142143
/**
143144
* Render menu item mouse events
145+
*
144146
* @param \Magento\Backend\Model\Menu\Item $menuItem
145147
* @return string
146148
*/
@@ -216,7 +218,7 @@ protected function _callbackSecretKey($match)
216218
{
217219
$routeId = $this->routeConfig->getRouteByFrontName($match[1]);
218220
return \Magento\Backend\Model\UrlInterface::SECRET_KEY_PARAM_NAME . '/' . $this->_url->getSecretKey(
219-
$routeId,
221+
$routeId ?: $match[1],
220222
$match[2],
221223
$match[3]
222224
);
@@ -354,7 +356,7 @@ protected function _columnBrake($items, $limit)
354356
* @param \Magento\Backend\Model\Menu\Item $menuItem
355357
* @param int $level
356358
* @param int $limit
357-
* @param $id int
359+
* @param int|null $id
358360
* @return string HTML code
359361
*/
360362
protected function _addSubMenu($menuItem, $level, $limit, $id = null)

app/code/Magento/Backend/Test/Mftf/Section/AdminMenuSection.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
-->
88

99
<sections xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10-
xsi:noNamespaceSchemaLocation="../../../../../../../dev/tests/acceptance/vendor/magento/magento2-functional-testing-framework/src/Magento/FunctionalTestingFramework/Page/etc/SectionObject.xsd">
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Page/etc/SectionObject.xsd">
1111
<section name="AdminMenuSection">
1212
<element name="catalog" type="button" selector="#menu-magento-catalog-catalog"/>
13+
<element name="catalogProducts" type="button" selector="#nav li[data-ui-id='menu-magento-catalog-catalog-products']"/>
1314
<element name="customers" type="button" selector="#menu-magento-customer-customer"/>
1415
<element name="content" type="button" selector="#menu-magento-backend-content"/>
1516
<element name="widgets" type="button" selector="#nav li[data-ui-id='menu-magento-widget-cms-widget-instance']"/>
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
/**
4+
* Copyright © Magento, Inc. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
9+
<tests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
10+
xsi:noNamespaceSchemaLocation="urn:magento:mftf:Test/etc/testSchema.xsd">
11+
<test name="AdminMenuNavigationWithSecretKeysTest">
12+
<annotations>
13+
<features value="Backend"/>
14+
<stories value="Menu Navigation"/>
15+
<title value="Admin should be able to navigate between menu options with secret url keys enabled"/>
16+
<description value="Admin should be able to navigate between menu options with secret url keys enabled"/>
17+
<severity value="CRITICAL"/>
18+
<testCaseId value="MAGETWO-95349"/>
19+
<group value="menu"/>
20+
</annotations>
21+
<before>
22+
<magentoCLI command="config:set admin/security/use_form_key 1" stepKey="enableUrlSecretKeys"/>
23+
<magentoCLI command="cache:clean config full_page" stepKey="cleanInvalidatedCaches1"/>
24+
<actionGroup ref="LoginAsAdmin" stepKey="loginAsAdmin"/>
25+
</before>
26+
<after>
27+
<magentoCLI command="config:set admin/security/use_form_key 0" stepKey="disableUrlSecretKeys"/>
28+
<magentoCLI command="cache:clean config full_page" stepKey="cleanInvalidatedCaches2"/>
29+
<actionGroup ref="logout" stepKey="logout"/>
30+
</after>
31+
32+
<click selector="{{AdminMenuSection.stores}}" stepKey="clickStoresMenuOption1"/>
33+
<waitForLoadingMaskToDisappear stepKey="waitForStoresMenu1" />
34+
<click selector="{{AdminMenuSection.configuration}}" stepKey="clickStoresConfigurationMenuOption1"/>
35+
<waitForPageLoad stepKey="waitForConfigurationPageLoad1"/>
36+
<seeCurrentUrlMatches regex="~\/admin\/system_config\/~" stepKey="seeCurrentUrlMatchesConfigPath1"/>
37+
38+
<click selector="{{AdminMenuSection.catalog}}" stepKey="clickCatalogMenuOption"/>
39+
<waitForLoadingMaskToDisappear stepKey="waitForCatalogMenu1" />
40+
<click selector="{{AdminMenuSection.catalogProducts}}" stepKey="clickCatalogProductsMenuOption"/>
41+
<waitForPageLoad stepKey="waitForProductsPageLoad"/>
42+
<seeCurrentUrlMatches regex="~\/catalog\/product\/~" stepKey="seeCurrentUrlMatchesProductsPath"/>
43+
44+
<click selector="{{AdminMenuSection.stores}}" stepKey="clickStoresMenuOption2"/>
45+
<waitForLoadingMaskToDisappear stepKey="waitForStoresMenu2" />
46+
<click selector="{{AdminMenuSection.configuration}}" stepKey="clickStoresConfigurationMenuOption2"/>
47+
<waitForPageLoad stepKey="waitForConfigurationPageLoad2"/>
48+
<seeCurrentUrlMatches regex="~\/admin\/system_config\/~" stepKey="seeCurrentUrlMatchesConfigPath2"/>
49+
</test>
50+
</tests>

0 commit comments

Comments
 (0)