Skip to content

Commit d2d0db2

Browse files
committed
Merge pull request #163 from magento-tango/MAGETWO-35150-PR
[Tango] Bug Fixing
2 parents c04232b + 67bd7c6 commit d2d0db2

File tree

19 files changed

+479
-97
lines changed

19 files changed

+479
-97
lines changed

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

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -210,16 +210,24 @@ protected function _renderItemCssClass($menuItem, $level)
210210
*/
211211
protected function _renderAnchor($menuItem, $level)
212212
{
213-
return '<a href="' . $menuItem->getUrl() . '" ' . $this->_renderItemAnchorTitle(
214-
$menuItem
215-
) . $this->_renderItemOnclickFunction(
216-
$menuItem
217-
) . ' class="' . $this->_renderAnchorCssClass(
218-
$menuItem,
219-
$level
220-
) . '">' . '<span>' . $this->_getAnchorLabel(
221-
$menuItem
222-
) . '</span>' . '</a>';
213+
if ($level == 1 && $menuItem->getUrl() == '#') {
214+
$output = '<strong class="submenu-group-title" role="presentation">'
215+
. '<span>' . $this->_getAnchorLabel($menuItem) . '</span>'
216+
. '</strong>';
217+
} else {
218+
$output = '<a href="' . $menuItem->getUrl() . '" ' . $this->_renderItemAnchorTitle(
219+
$menuItem
220+
) . $this->_renderItemOnclickFunction(
221+
$menuItem
222+
) . ' class="' . $this->_renderAnchorCssClass(
223+
$menuItem,
224+
$level
225+
) . '">' . '<span>' . $this->_getAnchorLabel(
226+
$menuItem
227+
) . '</span>' . '</a>';
228+
}
229+
230+
return $output;
223231
}
224232

225233
/**
@@ -397,15 +405,16 @@ protected function _columnBrake($items, $limit)
397405
* @param \Magento\Backend\Model\Menu\Item $menuItem
398406
* @param int $level
399407
* @param int $limit
408+
* @param $id int
400409
* @return string HTML code
401410
*/
402-
protected function _addSubMenu($menuItem, $level, $limit)
411+
protected function _addSubMenu($menuItem, $level, $limit, $id = null)
403412
{
404413
$output = '';
405414
if (!$menuItem->hasChildren()) {
406415
return $output;
407416
}
408-
$output .= '<div class="submenu">';
417+
$output .= '<div class="submenu"' . ($level == 0 && isset($id) ? ' aria-labelledby="' . $id . '"' : '') . '>';
409418
$colStops = null;
410419
if ($level == 0 && $limit) {
411420
$colStops = $this->_columnBrake($menuItem->getChildren(), $limit);
@@ -426,6 +435,7 @@ protected function _addSubMenu($menuItem, $level, $limit)
426435
* @param int $limit
427436
* @param array $colBrakes
428437
* @return string HTML
438+
* @SuppressWarnings(PHPMD.NPathComplexity)
429439
*/
430440
public function renderNavigation($menu, $level = 0, $limit = 0, $colBrakes = [])
431441
{
@@ -443,18 +453,21 @@ public function renderNavigation($menu, $level = 0, $limit = 0, $colBrakes = [])
443453
$output .= '</ul></li><li class="column"><ul role="menu">';
444454
}
445455

456+
$id = $this->getJsId($menuItem->getId());
446457
$output .= '<li ' . $this->getUiId(
447458
$menuItem->getId()
448459
) . ' class="item-' . $itemClass . ' ' . $this->_renderItemCssClass(
449460
$menuItem,
450461
$level
451-
) . '" role="menu-item">' . $this->_renderAnchor(
462+
) . ($level == 0 ? '" id="' . $id . '" aria-haspopup="true' : '')
463+
. '" role="menu-item">' . $this->_renderAnchor(
452464
$menuItem,
453465
$level
454466
) . $this->_addSubMenu(
455467
$menuItem,
456468
$level,
457-
$limit
469+
$limit,
470+
$id
458471
) . '</li>';
459472
$itemPosition++;
460473
}

app/code/Magento/Cms/Ui/DataProvider/Block/Row/Actions.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,18 @@ public function __construct(UrlInterface $urlBuilder)
3434
/**
3535
* Get data
3636
*
37-
* @param array $dataRow
38-
* @return mixed
37+
* @param array $rowData
38+
* @param array $rowActionConfig
39+
* @return array
3940
*/
40-
public function getData(array $dataRow)
41+
public function getData(array $rowData, array $rowActionConfig = [])
4142
{
4243
return [
4344
'edit' => [
44-
'href' => $this->urlBuilder->getUrl(static::URL_PATH, ['block_id' => $dataRow['block_id']]),
45+
'href' => $this->urlBuilder->getUrl(
46+
isset($rowActionConfig['url_path']) ? $rowActionConfig['url_path'] : static::URL_PATH,
47+
['block_id' => $rowData['block_id']]
48+
),
4549
'label' => __('Edit'),
4650
]
4751
];

app/code/Magento/Cms/Ui/DataProvider/Page/Row/Actions.php

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,23 +44,27 @@ public function __construct(UrlBuilder $actionUrlBuilder, UrlInterface $urlBuild
4444
/**
4545
* Get data
4646
*
47-
* @param array $dataRow
48-
* @return mixed
47+
* @param array $rowData
48+
* @param array $rowActionConfig
49+
* @return array
4950
*/
50-
public function getData(array $dataRow)
51+
public function getData(array $rowData, array $rowActionConfig = [])
5152
{
5253
return [
5354
'edit' => [
54-
'href' => $this->urlBuilder->getUrl(static::URL_PATH, ['page_id' => $dataRow['page_id']]),
55+
'href' => $this->urlBuilder->getUrl(
56+
isset($rowActionConfig['url_path']) ? $rowActionConfig['url_path'] : static::URL_PATH,
57+
['page_id' => $rowData['page_id']]
58+
),
5559
'label' => __('Edit'),
5660
'hidden' => true,
5761

5862
],
5963
'preview' => [
6064
'href' => $this->actionUrlBuilder->getUrl(
61-
$dataRow['identifier'],
62-
isset($dataRow['_first_store_id']) ? $dataRow['_first_store_id'] : null,
63-
isset($dataRow['store_code']) ? $dataRow['store_code'] : null
65+
$rowData['identifier'],
66+
isset($rowData['_first_store_id']) ? $rowData['_first_store_id'] : null,
67+
isset($rowData['store_code']) ? $rowData['store_code'] : null
6468
),
6569
'label' => __('Preview'),
6670
]
Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,54 @@
11
<?php
22
/**
3-
*
43
* Copyright © 2015 Magento. All rights reserved.
54
* See COPYING.txt for license details.
65
*/
76
namespace Magento\Sales\Controller\Guest;
87

98
use Magento\Framework\App\Action;
9+
use Magento\Sales\Helper\Guest as GuestHelper;
10+
use Magento\Framework\View\Result\PageFactory;
11+
use Magento\Framework\Controller\ResultInterface;
1012

11-
class View extends \Magento\Sales\Controller\AbstractController\View
13+
class View extends Action\Action
1214
{
1315
/**
14-
* {@inheritdoc}
16+
* @var \Magento\Sales\Helper\Guest
17+
*/
18+
protected $guestHelper;
19+
20+
/**
21+
* @var \Magento\Framework\View\Result\PageFactory
22+
*/
23+
protected $resultPageFactory;
24+
25+
/**
26+
* @param \Magento\Framework\App\Action\Context $context
27+
* @param \Magento\Sales\Helper\Guest $guestHelper
28+
* @param \Magento\Framework\View\Result\PageFactory $resultPageFactory
29+
*/
30+
public function __construct(
31+
Action\Context $context,
32+
GuestHelper $guestHelper,
33+
PageFactory $resultPageFactory
34+
) {
35+
$this->guestHelper = $guestHelper;
36+
$this->resultPageFactory = $resultPageFactory;
37+
parent::__construct($context);
38+
}
39+
40+
/**
41+
* @return \Magento\Framework\Controller\ResultInterface
1542
*/
1643
public function execute()
1744
{
18-
$result = $this->orderLoader->load($this->_request);
19-
if ($result instanceof \Magento\Framework\Controller\ResultInterface) {
45+
$result = $this->guestHelper->loadValidOrder($this->getRequest());
46+
if ($result instanceof ResultInterface) {
2047
return $result;
2148
}
22-
49+
/** @var \Magento\Framework\View\Result\Page $resultPage */
2350
$resultPage = $this->resultPageFactory->create();
24-
$this->_objectManager->get('Magento\Sales\Helper\Guest')->getBreadcrumbs($resultPage);
51+
$this->guestHelper->getBreadcrumbs($resultPage);
2552
return $resultPage;
2653
}
2754
}
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
<?php
2+
/**
3+
* Copyright © 2015 Magento. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
namespace Magento\Sales\Test\Unit\Controller\Guest;
7+
8+
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
9+
10+
class ViewTest extends \PHPUnit_Framework_TestCase
11+
{
12+
/**
13+
* @var \Magento\Sales\Controller\Guest\View
14+
*/
15+
protected $viewController;
16+
17+
/**
18+
* @var \Magento\TestFramework\Helper\ObjectManager
19+
*/
20+
protected $objectManagerHelper;
21+
22+
/**
23+
* @var \Magento\Framework\App\Action\Context
24+
*/
25+
protected $context;
26+
27+
/**
28+
* @var \Magento\Framework\App\RequestInterface|\PHPUnit_Framework_MockObject_MockObject
29+
*/
30+
protected $requestMock;
31+
32+
/**
33+
* @var \Magento\Sales\Helper\Guest|\PHPUnit_Framework_MockObject_MockObject
34+
*/
35+
protected $guestHelperMock;
36+
37+
/**
38+
* @var \Magento\Framework\Controller\Result\Redirect|\PHPUnit_Framework_MockObject_MockObject
39+
*/
40+
protected $resultRedirectMock;
41+
42+
/**
43+
* @var \Magento\Framework\View\Result\PageFactory|\PHPUnit_Framework_MockObject_MockObject
44+
*/
45+
protected $resultPageFactoryMock;
46+
47+
/**
48+
* @var \Magento\Framework\View\Result\Page|\PHPUnit_Framework_MockObject_MockObject
49+
*/
50+
protected $resultPageMock;
51+
52+
/**
53+
* @return void
54+
*/
55+
protected function setUp()
56+
{
57+
$this->requestMock = $this->getMockBuilder('Magento\Framework\App\RequestInterface')
58+
->getMock();
59+
$this->guestHelperMock = $this->getMockBuilder('Magento\Sales\Helper\Guest')
60+
->disableOriginalConstructor()
61+
->getMock();
62+
$this->resultRedirectMock = $this->getMockBuilder('Magento\Framework\Controller\Result\Redirect')
63+
->disableOriginalConstructor()
64+
->getMock();
65+
$this->resultPageFactoryMock = $this->getMockBuilder('Magento\Framework\View\Result\PageFactory')
66+
->disableOriginalConstructor()
67+
->setMethods(['create'])
68+
->getMock();
69+
$this->resultPageMock = $this->getMockBuilder('Magento\Framework\View\Result\Page')
70+
->disableOriginalConstructor()
71+
->getMock();
72+
73+
$this->objectManagerHelper = new ObjectManagerHelper($this);
74+
$this->context = $this->objectManagerHelper->getObject(
75+
'Magento\Framework\App\Action\Context',
76+
[
77+
'request' => $this->requestMock
78+
]
79+
);
80+
$this->viewController = $this->objectManagerHelper->getObject(
81+
'Magento\Sales\Controller\Guest\View',
82+
[
83+
'context' => $this->context,
84+
'guestHelper' => $this->guestHelperMock,
85+
'resultPageFactory' => $this->resultPageFactoryMock
86+
]
87+
);
88+
}
89+
90+
/**
91+
* @return void
92+
*/
93+
public function testExecuteOrderLoaded()
94+
{
95+
$this->guestHelperMock->expects($this->once())
96+
->method('loadValidOrder')
97+
->with($this->requestMock)
98+
->willReturn(true);
99+
$this->resultPageFactoryMock->expects($this->once())
100+
->method('create')
101+
->willReturn($this->resultPageMock);
102+
$this->guestHelperMock->expects($this->once())
103+
->method('getBreadcrumbs')
104+
->with($this->resultPageMock);
105+
106+
$this->assertSame($this->resultPageMock, $this->viewController->execute());
107+
}
108+
109+
/**
110+
* @return void
111+
*/
112+
public function testExecuteOrderNotFound()
113+
{
114+
$this->guestHelperMock->expects($this->once())
115+
->method('loadValidOrder')
116+
->with($this->requestMock)
117+
->willReturn($this->resultRedirectMock);
118+
119+
$this->assertSame($this->resultRedirectMock, $this->viewController->execute());
120+
}
121+
}

app/code/Magento/Store/Ui/DataProvider/Row.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ public function __construct(SystemStore $systemStore, Escaper $escaper)
4444
* Get data
4545
*
4646
* @param array $dataRow
47+
* @param array $data
4748
* @return mixed
4849
*/
49-
public function getData(array $dataRow)
50+
public function getData(array $dataRow, array $data = [])
5051
{
5152
$content = '';
5253
$origStores = $dataRow['store_id'];

app/code/Magento/Ui/Component/Listing.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ protected function getDataFromDataProvider(array $dataRow)
173173
{
174174
if ($this->hasData(static::ROW_DATA_PROVIDER_KEY)) {
175175
foreach ($this->getData(static::ROW_DATA_PROVIDER_KEY) as $field => $data) {
176-
$dataRow[$field] = $this->dataProviderRowPool->get($data['class'])->getData($dataRow);
176+
$dataRow[$field] = $this->dataProviderRowPool->get($data['class'])->getData($dataRow, $data);
177177
}
178178
}
179179

app/code/Magento/Ui/Component/Listing/RowInterface.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ interface RowInterface
1414
* Get data
1515
*
1616
* @param array $dataRow
17+
* @param array $data
1718
* @return mixed
1819
*/
19-
public function getData(array $dataRow);
20+
public function getData(array $dataRow, array $data = []);
2021
}

app/code/Magento/Wishlist/view/frontend/layout/wishlist_email_items.xml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
-->
88
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../lib/internal/Magento/Framework/View/Layout/etc/page_configuration.xsd">
99
<body>
10-
<referenceContainer name="root">
11-
<block class="Magento\Wishlist\Block\Share\Email\Items" name="wishlist.email.items" cacheable="false"/>
12-
</referenceContainer>
10+
<block class="Magento\Wishlist\Block\Share\Email\Items" name="wishlist.email.items" cacheable="false"/>
1311
</body>
1412
</page>

0 commit comments

Comments
 (0)