diff --git a/app/code/Magento/Backend/etc/di.xml b/app/code/Magento/Backend/etc/di.xml index 7307bbe09f1b4..8b52d08da48fb 100644 --- a/app/code/Magento/Backend/etc/di.xml +++ b/app/code/Magento/Backend/etc/di.xml @@ -71,7 +71,6 @@ Magento\Backend\Helper\Data\Proxy - diff --git a/app/code/Magento/Catalog/Plugin/Block/Topmenu.php b/app/code/Magento/Catalog/Plugin/Block/Topmenu.php index 098b3282a1b10..72bf4468080e3 100644 --- a/app/code/Magento/Catalog/Plugin/Block/Topmenu.php +++ b/app/code/Magento/Catalog/Plugin/Block/Topmenu.php @@ -79,11 +79,18 @@ public function beforeGetHtml( $currentCategory = $this->getCurrentCategory(); $mapping = [$rootId => $subject->getMenu()]; // use nodes stack to avoid recursion foreach ($collection as $category) { - if (!isset($mapping[$category->getParentId()])) { - continue; + $categoryParentId = $category->getParentId(); + if (!isset($mapping[$categoryParentId])) { + $parentIds = $category->getParentIds(); + foreach ($parentIds as $parentId) { + if (isset($mapping[$parentId])) { + $categoryParentId = $parentId; + } + } } + /** @var Node $parentCategoryNode */ - $parentCategoryNode = $mapping[$category->getParentId()]; + $parentCategoryNode = $mapping[$categoryParentId]; $categoryNode = new Node( $this->getCategoryAsArray($category, $currentCategory), diff --git a/app/code/Magento/Catalog/Test/Unit/Plugin/Block/TopmenuTest.php b/app/code/Magento/Catalog/Test/Unit/Plugin/Block/TopmenuTest.php index 93e9a6f49e9a0..1f805016b7f51 100644 --- a/app/code/Magento/Catalog/Test/Unit/Plugin/Block/TopmenuTest.php +++ b/app/code/Magento/Catalog/Test/Unit/Plugin/Block/TopmenuTest.php @@ -4,12 +4,15 @@ * See COPYING.txt for license details. */ -// @codingStandardsIgnoreFile - namespace Magento\Catalog\Test\Unit\Plugin\Block; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; +/** + * Class TopmenuTest + * + * @SuppressWarnings(PHPMD.CouplingBetweenObjects) + */ class TopmenuTest extends \PHPUnit_Framework_TestCase { /** @@ -18,96 +21,109 @@ class TopmenuTest extends \PHPUnit_Framework_TestCase protected $block; /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Helper\Category + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Store\Model\StoreManagerInterface */ - protected $_catalogCategory; + protected $storeManagerMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Category + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Store\Model\Store */ - protected $_childrenCategory; + protected $storeMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Category + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Layer\Resolver + */ + protected $layerResolverMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Layer + */ + protected $catalogLayerMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\ResourceModel\Category\CollectionFactory */ - protected $_category; + protected $categoryCollectionFactoryMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\ResourceModel\Category\Collection */ - protected $menuCategoryData; + protected $categoryCollectionMock; /** - * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Indexer\Category\Flat\State + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Helper\Category + */ + protected $categoryHelperMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Category + */ + protected $childrenCategoryMock; + + /** + * @var \PHPUnit_Framework_MockObject_MockObject|\Magento\Catalog\Model\Category */ - protected $_categoryFlatState; + protected $categoryMock; + /** + * Set up + * + * @return void + */ protected function setUp() { - $this->_catalogCategory = $this->getMock( - \Magento\Catalog\Helper\Category::class, - ['getStoreCategories', 'getCategoryUrl'], - [], - '', - false + $rootCategoryId = 2; + $categoryParentId = 3; + $categoryParentIds = [1, 2, 3]; + + $this->childrenCategoryMock = $this->_getCleanMock(\Magento\Catalog\Model\Category::class); + $this->categoryHelperMock = $this->_getCleanMock(\Magento\Catalog\Helper\Category::class); + $this->catalogLayerMock = $this->_getCleanMock(\Magento\Catalog\Model\Layer::class); + $this->categoryMock = $this->_getCleanMock(\Magento\Catalog\Model\Category::class); + $this->layerResolverMock = $this->_getCleanMock(\Magento\Catalog\Model\Layer\Resolver::class); + $this->storeMock = $this->_getCleanMock(\Magento\Store\Model\Store::class); + $this->storeManagerMock = $this->_getCleanMock(\Magento\Store\Model\StoreManagerInterface::class); + $this->categoryCollectionMock = $this->_getCleanMock( + \Magento\Catalog\Model\ResourceModel\Category\Collection::class ); - - $this->menuCategoryData = $this->getMock( - \Magento\Catalog\Observer\MenuCategoryData::class, - ['getMenuCategoryData'], + $this->categoryCollectionFactoryMock = $this->getMock( + \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory::class, + ['create'], [], '', false ); - $this->store = $this->getMockBuilder(\Magento\Store\Model\Store::class) - ->setMethods(['getRootCategoryId', 'getFilters', '__wakeup']) - ->disableOriginalConstructor() - ->getMockForAbstractClass(); - - $this->storeManager = $this->getMockBuilder(\Magento\Store\Model\StoreManagerInterface::class) - ->setMethods(['getStore']) - ->disableOriginalConstructor() - ->getMockForAbstractClass(); - $this->storeManager->expects($this->any())->method('getStore') - ->will($this->returnValue($this->store)); - - $this->store->expects($this->any())->method('getRootCategoryId') - ->will($this->returnValue(1)); - - $collectionFactory = $this->getMockBuilder( - \Magento\Catalog\Model\ResourceModel\Category\CollectionFactory::class) - ->setMethods(['create']) - ->disableOriginalConstructor() - ->getMock(); - - $collection = $this->getMockBuilder(\Magento\Catalog\Model\ResourceModel\Category\Collection::class) - ->setMethods( - [ - 'addIsActiveFilter', - 'addAttributeToSelect', - 'addFieldToFilter', - 'addAttributeToFilter', - 'addUrlRewriteToResult', - 'getIterator', - 'setStoreId' - ] - )->disableOriginalConstructor() - ->getMock(); - $collection->expects($this->once())->method('addIsActiveFilter'); - $collectionFactory->expects($this->once())->method('create') - ->willReturn($collection); - - $collection->expects($this->once())->method('getIterator') - ->willReturn(new \ArrayIterator([])); + $this->catalogLayerMock->expects($this->once())->method('getCurrentCategory') + ->will($this->returnValue($this->childrenCategoryMock)); + + $this->storeManagerMock->expects($this->atLeastOnce())->method('getStore') + ->will($this->returnValue($this->storeMock)); + + $this->categoryMock->expects($this->atLeastOnce())->method('getParentId') + ->will($this->returnValue($categoryParentId)); + $this->categoryMock->expects($this->once())->method('getParentIds') + ->will($this->returnValue($categoryParentIds)); + + $this->layerResolverMock->expects($this->once())->method('get') + ->will($this->returnValue($this->catalogLayerMock)); + + $this->storeMock->expects($this->once())->method('getRootCategoryId') + ->will($this->returnValue($rootCategoryId)); + + $this->categoryCollectionMock->expects($this->once())->method('getIterator') + ->willReturn(new \ArrayIterator([$this->categoryMock])); + + $this->categoryCollectionFactoryMock->expects($this->once())->method('create') + ->willReturn($this->categoryCollectionMock); $this->block = (new ObjectManager($this))->getObject( \Magento\Catalog\Plugin\Block\Topmenu::class, [ - 'catalogCategory' => $this->_catalogCategory, - 'menuCategoryData' => $this->menuCategoryData, - 'storeManager' => $this->storeManager, - 'categoryCollectionFactory' => $collectionFactory, + 'catalogCategory' => $this->categoryHelperMock, + 'categoryCollectionFactory' => $this->categoryCollectionFactoryMock, + 'storeManager' => $this->storeManagerMock, + 'layerResolver' => $this->layerResolverMock, ] ); } @@ -123,31 +139,21 @@ protected function _getCleanMock($className) return $this->getMock($className, [], [], '', false); } - protected function _preparationData() + /** + * Test beforeGetHtml + * + */ + public function testBeforeGetHtml() { - $this->_childrenCategory = $this->getMock( - \Magento\Catalog\Model\Category::class, - ['getIsActive', '__wakeup'], - [], - '', - false - ); - + $treeMock = $this->getMock(\Magento\Framework\Data\Tree::class); - $this->_category = $this->getMock( - \Magento\Catalog\Model\Category::class, - ['getIsActive', '__wakeup', 'getName', 'getChildren', 'getUseFlatResource', 'getChildrenNodes'], - [], - '', - false - ); + $parentCategoryNodeMock = $this->_getCleanMock(\Magento\Framework\Data\Tree\Node::class); + $parentCategoryNodeMock->expects($this->once())->method('getTree')->will($this->returnValue($treeMock)); + $parentCategoryNodeMock->expects($this->once())->method('addChild'); $blockMock = $this->_getCleanMock(\Magento\Theme\Block\Html\Topmenu::class); - return $blockMock; - } + $blockMock->expects($this->once())->method('getMenu')->will($this->returnValue($parentCategoryNodeMock)); - public function testAddCatalogToTopMenuItems() - { - $this->block->beforeGetHtml($this->_preparationData()); + $this->block->beforeGetHtml($blockMock); } } diff --git a/app/code/Magento/Sales/view/frontend/templates/order/history.phtml b/app/code/Magento/Sales/view/frontend/templates/order/history.phtml index a57c68d17258f..47ea803530f14 100644 --- a/app/code/Magento/Sales/view/frontend/templates/order/history.phtml +++ b/app/code/Magento/Sales/view/frontend/templates/order/history.phtml @@ -21,7 +21,7 @@ -   + diff --git a/app/code/Magento/Ui/view/base/web/js/lib/step-wizard.js b/app/code/Magento/Ui/view/base/web/js/lib/step-wizard.js index ad4d680771c07..e598b5f567a84 100644 --- a/app/code/Magento/Ui/view/base/web/js/lib/step-wizard.js +++ b/app/code/Magento/Ui/view/base/web/js/lib/step-wizard.js @@ -213,7 +213,7 @@ define([ modal.closeModal(); } }, - showSpecificStep: function () { + showSpecificStep: function (data, event) { var index = _.indexOf(this.stepsNames, event.target.hash.substr(1)), stepName = this.wizard.move(index); diff --git a/app/code/Magento/Ui/view/base/web/templates/grid/controls/columns.html b/app/code/Magento/Ui/view/base/web/templates/grid/controls/columns.html index c14044de44eb2..113806471bc9b 100644 --- a/app/code/Magento/Ui/view/base/web/templates/grid/controls/columns.html +++ b/app/code/Magento/Ui/view/base/web/templates/grid/controls/columns.html @@ -16,7 +16,9 @@ disable="isDisabled($col())" ko-checked="$col().visible" attr="id: ++ko.uid"/> -