Skip to content

Commit fa3cf5d

Browse files
committed
MAGETWO-34477: Backend Menu Accessibility improvements
1 parent dfd029c commit fa3cf5d

File tree

3 files changed

+102
-0
lines changed

3 files changed

+102
-0
lines changed
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Backend\Block;
7+
8+
use Magento\Framework\App\Bootstrap;
9+
use Magento\Framework\App\Filesystem\DirectoryList;
10+
use Magento\Framework\App\State;
11+
12+
/**
13+
* Test class for \Magento\Backend\Block\Menu
14+
*/
15+
class MenuTest extends \PHPUnit_Framework_TestCase
16+
{
17+
/**
18+
* @var \Magento\Backend\Block\Menu $blockMenu
19+
*/
20+
protected $blockMenu;
21+
22+
protected function setUp()
23+
{
24+
$this->blockMenu = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
25+
'Magento\Backend\Block\Menu'
26+
);
27+
}
28+
29+
public function testRenderNavigation()
30+
{
31+
$menuConfig = $this->prepareMenuConfig();
32+
33+
$this->assertStringEqualsFile(
34+
__DIR__ . '/_files/menu/expected.phtml',
35+
$this->blockMenu->renderNavigation($menuConfig->getMenu())
36+
);
37+
}
38+
39+
/**
40+
* @return \Magento\Backend\Model\Menu\Config
41+
*/
42+
protected function prepareMenuConfig()
43+
{
44+
$this->loginAdminUser();
45+
46+
\Magento\TestFramework\Helper\Bootstrap::getInstance()->reinitialize(
47+
[
48+
Bootstrap::INIT_PARAM_FILESYSTEM_DIR_PATHS => [
49+
DirectoryList::MODULES => ['path' => __DIR__ . '/_files/menu'],
50+
],
51+
]
52+
);
53+
54+
/* @var $validationState \Magento\Framework\App\Arguments\ValidationState */
55+
$validationState = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
56+
'Magento\Framework\App\Arguments\ValidationState',
57+
['appMode' => State::MODE_DEFAULT]
58+
);
59+
60+
/* @var $configReader \Magento\Backend\Model\Menu\Config\Reader */
61+
$configReader = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
62+
'Magento\Backend\Model\Menu\Config\Reader',
63+
['validationState' => $validationState]
64+
);
65+
66+
return \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(
67+
'Magento\Backend\Model\Menu\Config',
68+
['configReader' => $configReader]
69+
);
70+
}
71+
72+
/**
73+
* @return void
74+
*/
75+
protected function loginAdminUser()
76+
{
77+
\Magento\TestFramework\Helper\Bootstrap::getObjectManager()
78+
->get('Magento\Backend\Model\UrlInterface')
79+
->turnOffSecretKey();
80+
81+
$auth = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Backend\Model\Auth');
82+
$auth->login(\Magento\TestFramework\Bootstrap::ADMIN_NAME, \Magento\TestFramework\Bootstrap::ADMIN_PASSWORD);
83+
}
84+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0"?>
2+
<!--
3+
/**
4+
* Copyright © 2015 Magento. All rights reserved.
5+
* See COPYING.txt for license details.
6+
*/
7+
-->
8+
<config>
9+
<menu>
10+
<add id="Magento_Backend::system" title="System" module="Magento_Backend" sortOrder="30" resource="Magento_Backend::system"/>
11+
<add id="Magento_Backend::system_report" title="Report" module="Magento_Backend" sortOrder="10" parent="Magento_Backend::system" resource="Magento_Backend::report"/>
12+
13+
<add id="Magento_Backend::system_report_private_sales" title="Private Sales" module="Magento_Backend" sortOrder="10" parent="Magento_Backend::system_report" resource="Magento_Backend::report_private_sales" />
14+
<add id="Magento_Backend::system_report_magento_invitation_general" title="Invitations" module="Magento_Invitation" sortOrder="20" parent="Magento_Backend::system_report" resource="Magento_Backend::report_magento_invitation_general"/>
15+
<add id="Magento_Backend::system_report_magento_invitation_customer" title="Invited Customers" module="Magento_Invitation" sortOrder="30" parent="Magento_Backend::system_report" resource="Magento_Backend::report_magento_invitation_customer"/>
16+
</menu>
17+
</config>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<ul id="nav" ><li data-ui-id="magento-backend-system" class="item-system parent last level-0" id="magento-backend-system" aria-haspopup="true"><a href="#" onclick="return false;" class=""><span>System</span></a><div class="submenu" aria-labelledby="magento-backend-system"><ul ><li data-ui-id="magento-backend-system-report" class="item-system-report parent level-1"><strong class="submenu-group-title" role="presentation"><span>Report</span></strong><div class="submenu"><ul ><li data-ui-id="magento-backend-system-report-private-sales" class="item-system-report-private-sales level-2"><a href="#" onclick="return false;" class=""><span>Private Sales</span></a></li><li data-ui-id="magento-backend-system-report-magento-invitation-general" class="item-system-report-magento-invitation-general level-2"><a href="#" onclick="return false;" class=""><span>Invitations</span></a></li><li data-ui-id="magento-backend-system-report-magento-invitation-customer" class="item-system-report-magento-invitation-customer level-2"><a href="#" onclick="return false;" class=""><span>Invited Customers</span></a></li></ul></div></li></ul></div></li></ul>

0 commit comments

Comments
 (0)