Skip to content

Commit f30d10b

Browse files
MTA-3483: Create pull request and deliver extended functional tests to mainline
2 parents d88098a + bcdd65f commit f30d10b

File tree

9 files changed

+110
-95
lines changed

9 files changed

+110
-95
lines changed

app/code/Magento/Backend/etc/di.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@
7171
<argument name="backendHelper" xsi:type="object">Magento\Backend\Helper\Data\Proxy</argument>
7272
</arguments>
7373
</type>
74-
<preference for="Magento\Framework\Authorization\RoleLocatorInterface" type="Magento\Backend\Model\Authorization\RoleLocator" />
7574
<preference for="Magento\Framework\Authorization\PolicyInterface" type="Magento\Framework\Authorization\Policy\Acl"/>
7675
<preference for="Magento\Framework\Acl\AclResource\ProviderInterface" type="Magento\Framework\Acl\AclResource\Provider"/>
7776
<type name="Magento\Framework\Acl\AclResource\Config\Reader\Filesystem">

app/code/Magento/Catalog/Plugin/Block/Topmenu.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,18 @@ public function beforeGetHtml(
7979
$currentCategory = $this->getCurrentCategory();
8080
$mapping = [$rootId => $subject->getMenu()]; // use nodes stack to avoid recursion
8181
foreach ($collection as $category) {
82-
if (!isset($mapping[$category->getParentId()])) {
83-
continue;
82+
$categoryParentId = $category->getParentId();
83+
if (!isset($mapping[$categoryParentId])) {
84+
$parentIds = $category->getParentIds();
85+
foreach ($parentIds as $parentId) {
86+
if (isset($mapping[$parentId])) {
87+
$categoryParentId = $parentId;
88+
}
89+
}
8490
}
91+
8592
/** @var Node $parentCategoryNode */
86-
$parentCategoryNode = $mapping[$category->getParentId()];
93+
$parentCategoryNode = $mapping[$categoryParentId];
8794

8895
$categoryNode = new Node(
8996
$this->getCategoryAsArray($category, $currentCategory),

app/code/Magento/Catalog/Test/Unit/Plugin/Block/TopmenuTest.php

Lines changed: 93 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@
44
* See COPYING.txt for license details.
55
*/
66

7-
// @codingStandardsIgnoreFile
8-
97
namespace Magento\Catalog\Test\Unit\Plugin\Block;
108

119
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1210

11+
/**
12+
* Class TopmenuTest
13+
*
14+
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
15+
*/
1316
class TopmenuTest extends \PHPUnit_Framework_TestCase
1417
{
1518
/**
@@ -18,96 +21,109 @@ class TopmenuTest extends \PHPUnit_Framework_TestCase
1821
protected $block;
1922

2023
/**
21-
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Helper\Category
24+
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Store\Model\StoreManagerInterface
2225
*/
23-
protected $_catalogCategory;
26+
protected $storeManagerMock;
2427

2528
/**
26-
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Category
29+
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Store\Model\Store
2730
*/
28-
protected $_childrenCategory;
31+
protected $storeMock;
2932

3033
/**
31-
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Category
34+
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Layer\Resolver
35+
*/
36+
protected $layerResolverMock;
37+
38+
/**
39+
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Layer
40+
*/
41+
protected $catalogLayerMock;
42+
43+
/**
44+
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\ResourceModel\Category\CollectionFactory
3245
*/
33-
protected $_category;
46+
protected $categoryCollectionFactoryMock;
3447

3548
/**
36-
* @var \PHPUnit_Framework_MockObject_MockObject
49+
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\ResourceModel\Category\Collection
3750
*/
38-
protected $menuCategoryData;
51+
protected $categoryCollectionMock;
3952

4053
/**
41-
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Indexer\Category\Flat\State
54+
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Helper\Category
55+
*/
56+
protected $categoryHelperMock;
57+
58+
/**
59+
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Category
60+
*/
61+
protected $childrenCategoryMock;
62+
63+
/**
64+
* @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Category
4265
*/
43-
protected $_categoryFlatState;
66+
protected $categoryMock;
4467

68+
/**
69+
* Set up
70+
*
71+
* @return void
72+
*/
4573
protected function setUp()
4674
{
47-
$this->_catalogCategory = $this->getMock(
48-
\Magento\Catalog\Helper\Category::class,
49-
['getStoreCategories', 'getCategoryUrl'],
50-
[],
51-
'',
52-
false
75+
$rootCategoryId = 2;
76+
$categoryParentId = 3;
77+
$categoryParentIds = [1, 2, 3];
78+
79+
$this->childrenCategoryMock = $this->_getCleanMock(\Magento\Catalog\Model\Category::class);
80+
$this->categoryHelperMock = $this->_getCleanMock(\Magento\Catalog\Helper\Category::class);
81+
$this->catalogLayerMock = $this->_getCleanMock(\Magento\Catalog\Model\Layer::class);
82+
$this->categoryMock = $this->_getCleanMock(\Magento\Catalog\Model\Category::class);
83+
$this->layerResolverMock = $this->_getCleanMock(\Magento\Catalog\Model\Layer\Resolver::class);
84+
$this->storeMock = $this->_getCleanMock(\Magento\Store\Model\Store::class);
85+
$this->storeManagerMock = $this->_getCleanMock(\Magento\Store\Model\StoreManagerInterface::class);
86+
$this->categoryCollectionMock = $this->_getCleanMock(
87+
\Magento\Catalog\Model\ResourceModel\Category\Collection::class
5388
);
54-
55-
$this->menuCategoryData = $this->getMock(
56-
\Magento\Catalog\Observer\MenuCategoryData::class,
57-
['getMenuCategoryData'],
89+
$this->categoryCollectionFactoryMock = $this->getMock(
90+
\Magento\Catalog\Model\ResourceModel\Category\CollectionFactory::class,
91+
['create'],
5892
[],
5993
'',
6094
false
6195
);
6296

63-
$this->store = $this->getMockBuilder(\Magento\Store\Model\Store::class)
64-
->setMethods(['getRootCategoryId', 'getFilters', '__wakeup'])
65-
->disableOriginalConstructor()
66-
->getMockForAbstractClass();
67-
68-
$this->storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class)
69-
->setMethods(['getStore'])
70-
->disableOriginalConstructor()
71-
->getMockForAbstractClass();
72-
$this->storeManager->expects($this->any())->method('getStore')
73-
->will($this->returnValue($this->store));
74-
75-
$this->store->expects($this->any())->method('getRootCategoryId')
76-
->will($this->returnValue(1));
77-
78-
$collectionFactory = $this->getMockBuilder(
79-
\Magento\Catalog\Model\ResourceModel\Category\CollectionFactory::class)
80-
->setMethods(['create'])
81-
->disableOriginalConstructor()
82-
->getMock();
83-
84-
$collection = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Category\Collection::class)
85-
->setMethods(
86-
[
87-
'addIsActiveFilter',
88-
'addAttributeToSelect',
89-
'addFieldToFilter',
90-
'addAttributeToFilter',
91-
'addUrlRewriteToResult',
92-
'getIterator',
93-
'setStoreId'
94-
]
95-
)->disableOriginalConstructor()
96-
->getMock();
97-
$collection->expects($this->once())->method('addIsActiveFilter');
98-
$collectionFactory->expects($this->once())->method('create')
99-
->willReturn($collection);
100-
101-
$collection->expects($this->once())->method('getIterator')
102-
->willReturn(new \ArrayIterator([]));
97+
$this->catalogLayerMock->expects($this->once())->method('getCurrentCategory')
98+
->will($this->returnValue($this->childrenCategoryMock));
99+
100+
$this->storeManagerMock->expects($this->atLeastOnce())->method('getStore')
101+
->will($this->returnValue($this->storeMock));
102+
103+
$this->categoryMock->expects($this->atLeastOnce())->method('getParentId')
104+
->will($this->returnValue($categoryParentId));
105+
$this->categoryMock->expects($this->once())->method('getParentIds')
106+
->will($this->returnValue($categoryParentIds));
107+
108+
$this->layerResolverMock->expects($this->once())->method('get')
109+
->will($this->returnValue($this->catalogLayerMock));
110+
111+
$this->storeMock->expects($this->once())->method('getRootCategoryId')
112+
->will($this->returnValue($rootCategoryId));
113+
114+
$this->categoryCollectionMock->expects($this->once())->method('getIterator')
115+
->willReturn(new \ArrayIterator([$this->categoryMock]));
116+
117+
$this->categoryCollectionFactoryMock->expects($this->once())->method('create')
118+
->willReturn($this->categoryCollectionMock);
103119

104120
$this->block = (new ObjectManager($this))->getObject(
105121
\Magento\Catalog\Plugin\Block\Topmenu::class,
106122
[
107-
'catalogCategory' => $this->_catalogCategory,
108-
'menuCategoryData' => $this->menuCategoryData,
109-
'storeManager' => $this->storeManager,
110-
'categoryCollectionFactory' => $collectionFactory,
123+
'catalogCategory' => $this->categoryHelperMock,
124+
'categoryCollectionFactory' => $this->categoryCollectionFactoryMock,
125+
'storeManager' => $this->storeManagerMock,
126+
'layerResolver' => $this->layerResolverMock,
111127
]
112128
);
113129
}
@@ -123,31 +139,21 @@ protected function _getCleanMock($className)
123139
return $this->getMock($className, [], [], '', false);
124140
}
125141

126-
protected function _preparationData()
142+
/**
143+
* Test beforeGetHtml
144+
*
145+
*/
146+
public function testBeforeGetHtml()
127147
{
128-
$this->_childrenCategory = $this->getMock(
129-
\Magento\Catalog\Model\Category::class,
130-
['getIsActive', '__wakeup'],
131-
[],
132-
'',
133-
false
134-
);
135-
148+
$treeMock = $this->getMock(\Magento\Framework\Data\Tree::class);
136149

137-
$this->_category = $this->getMock(
138-
\Magento\Catalog\Model\Category::class,
139-
['getIsActive', '__wakeup', 'getName', 'getChildren', 'getUseFlatResource', 'getChildrenNodes'],
140-
[],
141-
'',
142-
false
143-
);
150+
$parentCategoryNodeMock = $this->_getCleanMock(\Magento\Framework\Data\Tree\Node::class);
151+
$parentCategoryNodeMock->expects($this->once())->method('getTree')->will($this->returnValue($treeMock));
152+
$parentCategoryNodeMock->expects($this->once())->method('addChild');
144153

145154
$blockMock = $this->_getCleanMock(\Magento\Theme\Block\Html\Topmenu::class);
146-
return $blockMock;
147-
}
155+
$blockMock->expects($this->once())->method('getMenu')->will($this->returnValue($parentCategoryNodeMock));
148156

149-
public function testAddCatalogToTopMenuItems()
150-
{
151-
$this->block->beforeGetHtml($this->_preparationData());
157+
$this->block->beforeGetHtml($blockMock);
152158
}
153159
}

app/code/Magento/Sales/view/frontend/templates/order/history.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<th scope="col" class="col shipping"><?php /* @escapeNotVerified */ echo __('Ship To') ?></th>
2222
<th scope="col" class="col total"><?php /* @escapeNotVerified */ echo __('Order Total') ?></th>
2323
<th scope="col" class="col status"><?php /* @escapeNotVerified */ echo __('Status') ?></th>
24-
<th scope="col" class="col actions">&nbsp;</th>
24+
<th scope="col" class="col actions"><?php /* @escapeNotVerified */ echo __('Action') ?></th>
2525
</tr>
2626
</thead>
2727
<tbody>

app/code/Magento/Ui/view/base/web/js/lib/step-wizard.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ define([
213213
modal.closeModal();
214214
}
215215
},
216-
showSpecificStep: function () {
216+
showSpecificStep: function (data, event) {
217217
var index = _.indexOf(this.stepsNames, event.target.hash.substr(1)),
218218
stepName = this.wizard.move(index);
219219

app/code/Magento/Ui/view/base/web/templates/grid/controls/columns.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
disable="isDisabled($col())"
1717
ko-checked="$col().visible"
1818
attr="id: ++ko.uid"/>
19-
<label class="admin__field-label" text="$col().label" attr="for: ko.uid"/>
19+
<label class="admin__field-label"
20+
text="$col().label"
21+
attr="for: ko.uid, title: $col().label"/>
2022
</div>
2123
</div>
2224
<div class="admin__action-dropdown-menu-footer">

dev/tests/integration/testsuite/Magento/Backend/Block/MenuTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
/**
1212
* Test class for \Magento\Backend\Block\Menu
13-
*
13+
* @magentoAppArea adminhtml
1414
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1515
*/
1616
class MenuTest extends \PHPUnit_Framework_TestCase

dev/tests/integration/testsuite/Magento/Backend/Controller/Adminhtml/Dashboard/ProductsViewedTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
class ProductsViewedTest extends \Magento\TestFramework\TestCase\AbstractBackendController
1010
{
1111
/**
12+
* @magentoAppArea adminhtml
1213
* @magentoDataFixture Magento/Reports/_files/viewed_products.php
1314
*/
1415
public function testExecute()

0 commit comments

Comments
 (0)