Example #1
0
 /**
  * {@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);
     }
 }
Example #2
0
 public function testGetProductPriceHtml()
 {
     $id = 6;
     $expectedHtml = '
     <div class="price-box price-final_price">
         <span class="regular-price" id="product-price-' . $id . '">
             <span class="price">$0.00</span>
         </span>
     </div>';
     $type = 'widget-new-list';
     $productMock = $this->getMock('Magento\\Catalog\\Model\\Product', [], [], '', false, false);
     $productMock->expects($this->once())->method('getId')->will($this->returnValue($id));
     $arguments = ['price_id' => 'old-price-' . $id . '-' . $type, 'display_minimal_price' => true, 'include_container' => true, 'zone' => \Magento\Framework\Pricing\Render::ZONE_ITEM_LIST];
     $priceBoxMock = $this->getMock('Magento\\Framework\\Pricing\\Render', ['render'], [], '', false, false);
     $this->layout->expects($this->once())->method('getBlock')->with($this->equalTo('product.price.render.default'))->will($this->returnValue($priceBoxMock));
     $priceBoxMock->expects($this->once())->method('render')->with($this->equalTo('final_price'), $this->equalTo($productMock), $this->equalTo($arguments))->will($this->returnValue($expectedHtml));
     $result = $this->block->getProductPriceHtml($productMock, $type);
     $this->assertEquals($expectedHtml, $result);
 }
Example #3
0
 /**
  * @param string $displayType
  * @param bool $pagerEnable
  * @param int $productsCount
  * @param int $productsPerPage
  */
 protected function startTestGetProductCollection($displayType, $pagerEnable, $productsCount, $productsPerPage)
 {
     $productCollectionFactory = $this->getMock('Magento\\Catalog\\Model\\ResourceModel\\Product\\CollectionFactory', ['create'], [], '', false, false);
     $productCollectionFactory->expects($this->atLeastOnce())->method('create')->willReturn($this->productCollection);
     $this->block = $this->objectManager->getObject('Magento\\Catalog\\Block\\Product\\Widget\\NewWidget', ['context' => $this->context, 'productCollectionFactory' => $productCollectionFactory]);
     if (null === $productsPerPage) {
         $this->block->unsetData('products_per_page');
     } else {
         $this->block->setData('products_per_page', $productsPerPage);
     }
     $this->block->setData('show_pager', $pagerEnable);
     $this->block->setData('display_type', $displayType);
     $this->block->setProductsCount($productsCount);
     $this->block->toHtml();
 }
 /**
  * @param int $pageNumber
  * @param int $expectedResult
  * @dataProvider getCurrentPageDataProvider
  */
 public function testGetCurrentPage($pageNumber, $expectedResult)
 {
     $this->requestMock->expects($this->any())->method('getParam')->with(\Magento\Catalog\Block\Product\Widget\NewWidget::PAGE_VAR_NAME)->willReturn($pageNumber);
     $this->assertEquals($expectedResult, $this->block->getCurrentPage());
 }
Example #5
0
 /**
  * {@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);
     }
 }