Beispiel #1
0
 public function testGetProductPriceHtmlCreateBlock()
 {
     $priceType = 'wishlist_configured_price';
     $expected = 'block content';
     $productMock = $this->getMockBuilder('Magento\\Catalog\\Model\\Product')->disableOriginalConstructor()->getMock();
     $renderMock = $this->getMockBuilder('\\Magento\\Framework\\Pricing\\Render')->disableOriginalConstructor()->getMock();
     $renderMock->expects($this->once())->method('render')->with($priceType, $productMock, ['zone' => Render::ZONE_ITEM_LIST])->willReturn($expected);
     $this->layout->expects($this->once())->method('getBlock')->with('product.price.render.default')->willReturn(false);
     $this->layout->expects($this->once())->method('createBlock')->with('Magento\\Framework\\Pricing\\Render', 'product.price.render.default', ['data' => ['price_render_handle' => 'catalog_product_prices']])->willReturn($renderMock);
     $result = $this->block->getProductPriceHtml($productMock, $priceType, Render::ZONE_ITEM_LIST);
     $this->assertEquals($expected, $result);
 }
 /**
  * {@inheritdoc}
  */
 public function getImage($product, $imageId, $attributes = array())
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'getImage');
     if (!$pluginInfo) {
         return parent::getImage($product, $imageId, $attributes);
     } else {
         return $this->___callPlugins('getImage', func_get_args(), $pluginInfo);
     }
 }
Beispiel #3
0
 /**
  * Get wishlist items
  *
  * @return array
  */
 protected function getItems()
 {
     $this->view->loadLayout();
     $collection = $this->wishlistHelper->getWishlistItemCollection();
     $collection->clear()->setPageSize(self::SIDEBAR_ITEMS_NUMBER)->setInStockFilter(true)->setOrder('added_at');
     $items = [];
     foreach ($collection as $wishlistItem) {
         /** @var \Magento\Catalog\Model\Product $product */
         $product = $wishlistItem->getProduct();
         $this->productImageView->init($product, 'wishlist_sidebar_block', 'Magento_Catalog');
         $items[] = ['image' => ['src' => $this->productImageView->getUrl(), 'alt' => $this->productImageView->getLabel(), 'width' => $this->productImageView->getWidth(), 'height' => $this->productImageView->getHeight()], 'product_url' => $this->wishlistHelper->getProductUrl($wishlistItem), 'product_name' => $product->getName(), 'product_price' => $this->block->getProductPriceHtml($product, \Magento\Catalog\Pricing\Price\ConfiguredPriceInterface::CONFIGURED_PRICE_CODE, \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST, ['item' => $wishlistItem]), 'product_is_saleable_and_visible' => $product->isSaleable() && $product->isVisibleInSiteVisibility(), 'product_has_required_options' => $product->getTypeInstance()->hasRequiredOptions($product), 'add_to_cart_params' => $this->wishlistHelper->getAddToCartParams($wishlistItem), 'delete_item_params' => $this->wishlistHelper->getRemoveParams($wishlistItem)];
     }
     return $items;
 }
 public function testGetSectionDataWithoutItems()
 {
     $items = [];
     $result = ['counter' => null, 'items' => []];
     $this->wishlistHelperMock->expects($this->once())->method('getItemCount')->willReturn(count($items));
     $this->viewMock->expects($this->never())->method('loadLayout');
     $this->wishlistHelperMock->expects($this->never())->method('getWishlistItemCollection');
     $this->catalogImageHelperMock->expects($this->never())->method('init');
     $this->catalogImageHelperMock->expects($this->never())->method('getUrl');
     $this->catalogImageHelperMock->expects($this->never())->method('getLabel');
     $this->catalogImageHelperMock->expects($this->never())->method('getWidth');
     $this->catalogImageHelperMock->expects($this->never())->method('getHeight');
     $this->wishlistHelperMock->expects($this->never())->method('getProductUrl');
     $this->sidebarMock->expects($this->never())->method('getProductPriceHtml');
     $this->wishlistHelperMock->expects($this->never())->method('getAddToCartParams');
     $this->wishlistHelperMock->expects($this->never())->method('getRemoveParams');
     $this->assertEquals($result, $this->model->getSectionData());
 }
 public function testGetIdentitiesNoItems()
 {
     $productTags = [];
     $this->wishlistHelper->expects($this->once())->method('getItemCount')->will($this->returnValue(0));
     $this->assertEquals($productTags, $this->block->getIdentities());
 }
 /**
  * Retrieve wishlist item data
  *
  * @param \Magento\Wishlist\Model\Item $wishlistItem
  * @return array
  */
 protected function getItemData(\Magento\Wishlist\Model\Item $wishlistItem)
 {
     $product = $wishlistItem->getProduct();
     return ['image' => $this->getImageData($product), 'product_url' => $this->wishlistHelper->getProductUrl($wishlistItem), 'product_name' => $product->getName(), 'product_price' => $this->block->getProductPriceHtml($product, \Magento\Catalog\Pricing\Price\ConfiguredPriceInterface::CONFIGURED_PRICE_CODE, \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST, ['item' => $wishlistItem]), 'product_is_saleable_and_visible' => $product->isSaleable() && $product->isVisibleInSiteVisibility(), 'product_has_required_options' => $product->getTypeInstance()->hasRequiredOptions($product), 'add_to_cart_params' => $this->wishlistHelper->getAddToCartParams($wishlistItem, true), 'delete_item_params' => $this->wishlistHelper->getRemoveParams($wishlistItem, true)];
 }
 /**
  * {@inheritdoc}
  */
 public function offsetGet($offset)
 {
     $pluginInfo = $this->pluginList->getNext($this->subjectType, 'offsetGet');
     if (!$pluginInfo) {
         return parent::offsetGet($offset);
     } else {
         return $this->___callPlugins('offsetGet', func_get_args(), $pluginInfo);
     }
 }