Пример #1
0
 public function testGetChildrenCreatesSubmenuOnFirstCall()
 {
     $menuMock = $this->getMock('Magento\\Backend\\Model\\Menu', [], [$this->getMock('Psr\\Log\\LoggerInterface')]);
     $this->_menuFactoryMock->expects($this->once())->method('create')->will($this->returnValue($menuMock));
     $this->_model->getChildren();
     $this->_model->getChildren();
 }
Пример #2
0
 /**
  * Gives able to display titles in menu slider which differ from titles in menu panel
  * @param \Magento\Backend\Model\Menu\Item $subject
  * @param string $result
  * @return string
  */
 public function afterGetTitle($subject, $result)
 {
     $ebayKey = 'Ess_M2ePro::ebay';
     $amazonKey = 'Ess_M2ePro::amazon';
     $isEbayWizardCompleted = $this->wizardHelper->isCompleted(\Ess\M2ePro\Helper\View\Ebay::WIZARD_INSTALLATION_NICK);
     if ($isEbayWizardCompleted && $subject->getId() == $ebayKey && !isset($this->menuTitlesUsing[$ebayKey])) {
         $this->menuTitlesUsing[$ebayKey] = true;
         return 'eBay Integration (Beta)';
     }
     $isAmazonWizardCompleted = $this->wizardHelper->isCompleted(\Ess\M2ePro\Helper\View\Amazon::WIZARD_INSTALLATION_NICK);
     if ($isAmazonWizardCompleted && $subject->getId() == $amazonKey && !isset($this->menuTitlesUsing[$amazonKey])) {
         $this->menuTitlesUsing[$amazonKey] = true;
         return 'Amazon Integration (Beta)';
     }
     return $result;
 }
Пример #3
0
 /**
  * Add sub menu HTML code for current menu item
  *
  * @param \Magento\Backend\Model\Menu\Item $menuItem
  * @param int $level
  * @param int $limit
  * @param $id int
  * @return string HTML code
  */
 protected function _addSubMenu($menuItem, $level, $limit, $id = null)
 {
     $output = '';
     if (!$menuItem->hasChildren()) {
         return $output;
     }
     $output .= '<div class="submenu"' . ($level == 0 && isset($id) ? ' aria-labelledby="' . $id . '"' : '') . '>';
     $colStops = null;
     if ($level == 0 && $limit) {
         $colStops = $this->_columnBrake($menuItem->getChildren(), $limit);
         $output .= '<strong class="submenu-title">' . $this->_getAnchorLabel($menuItem) . '</strong>';
         $output .= '<a href="#" class="action-close _close" data-role="close-submenu"></a>';
     }
     $output .= $this->renderNavigation($menuItem->getChildren(), $level + 1, $limit, $colStops);
     $output .= '</div>';
     return $output;
 }
Пример #4
0
 /**
  * Check whether provided item is last in list
  *
  * @param \Magento\Backend\Model\Menu\Item $item
  * @return bool
  */
 public function isLast(\Magento\Backend\Model\Menu\Item $item)
 {
     return $this->offsetGet(max(array_keys($this->getArrayCopy())))->getId() == $item->getId();
 }
Пример #5
0
 /**
  *  test execute method
  */
 public function testExecute()
 {
     $this->requestMock->expects($this->exactly(4))->method('getParam')->will($this->returnValueMap([['order_id', null, 'order_id'], ['creditmemo_id', null, 'creditmemo_id'], ['creditmemo', null, 'creditmemo'], ['invoice_id', null, 'invoice_id']]));
     $this->creditmemoLoaderMock->expects($this->once())->method('setOrderId')->with($this->equalTo('order_id'));
     $this->creditmemoLoaderMock->expects($this->once())->method('setCreditmemoId')->with($this->equalTo('creditmemo_id'));
     $this->creditmemoLoaderMock->expects($this->once())->method('setCreditmemo')->with($this->equalTo('creditmemo'));
     $this->creditmemoLoaderMock->expects($this->once())->method('setInvoiceId')->with($this->equalTo('invoice_id'));
     $this->creditmemoLoaderMock->expects($this->once())->method('load')->will($this->returnValue($this->creditmemoMock));
     $this->creditmemoMock->expects($this->exactly(2))->method('getInvoice')->will($this->returnValue($this->invoiceMock));
     $this->invoiceMock->expects($this->once())->method('getIncrementId')->will($this->returnValue('invoice-increment-id'));
     $this->titleMock->expects($this->exactly(3))->method('add')->will($this->returnValueMap([['Credit Memos', null], ['New Memo for #invoice-increment-id', null], ['item-title', null]]));
     $this->objectManagerMock->expects($this->once())->method('get')->with($this->equalTo('Magento\\Backend\\Model\\Session'))->will($this->returnValue($this->backendSessionMock));
     $this->backendSessionMock->expects($this->once())->method('getCommentText')->with($this->equalTo(true))->will($this->returnValue('comment'));
     $this->creditmemoMock->expects($this->once())->method('setCommentText')->with($this->equalTo('comment'));
     $this->viewMock->expects($this->once())->method('loadLayout');
     $this->viewMock->expects($this->once())->method('renderLayout');
     $this->viewMock->expects($this->once())->method('getLayout')->will($this->returnValue($this->layoutMock));
     $this->layoutMock->expects($this->once())->method('getBlock')->with($this->equalTo('menu'))->will($this->returnValue($this->blockMenuMock));
     $this->blockMenuMock->expects($this->once())->method('setActive')->with($this->equalTo('Magento_Sales::sales_order'));
     $this->blockMenuMock->expects($this->once())->method('getMenuModel')->will($this->returnValue($this->modelMenuMock));
     $this->modelMenuMock->expects($this->once())->method('getParentItems')->will($this->returnValue([$this->modelMenuItem]));
     $this->modelMenuItem->expects($this->once())->method('getTitle')->will($this->returnValue('item-title'));
     $this->assertNull($this->controller->execute());
 }
Пример #6
0
 /**
  * Add sub menu HTML code for current menu item
  *
  * @param \Magento\Backend\Model\Menu\Item $menuItem
  * @param int $level
  * @param int $limit
  * @return string HTML code
  */
 protected function _addSubMenu($menuItem, $level, $limit)
 {
     $output = '';
     if (!$menuItem->hasChildren()) {
         return $output;
     }
     $output .= '<div class="submenu">';
     $colStops = null;
     if ($level == 0 && $limit) {
         $colStops = $this->_columnBrake($menuItem->getChildren(), $limit);
     }
     $output .= $this->renderNavigation($menuItem->getChildren(), $level + 1, $limit, $colStops);
     $output .= '</div>';
     return $output;
 }