Exemplo n.º 1
0
 public function testGetItemData()
 {
     $urlModel = $this->getMockBuilder(\Magento\Catalog\Model\Product\Url::class)->disableOriginalConstructor()->getMock();
     $product = $this->getMockBuilder(\Magento\Catalog\Model\Product::class)->setMethods(['getUrlModel', 'isVisibleInSiteVisibility', 'getSku'])->disableOriginalConstructor()->getMock();
     $product->expects($this->any())->method('getUrlModel')->willReturn($urlModel);
     $product->expects($this->any())->method('isVisibleInSiteVisibility')->willReturn(true);
     $product->expects($this->any())->method('getSku')->willReturn('simple');
     /** @var \Magento\Quote\Model\Quote\Item $item */
     $item = $this->getMockBuilder(\Magento\Quote\Model\Quote\Item::class)->setMethods(['getProductType', 'getProduct', 'getCalculationPrice'])->disableOriginalConstructor()->getMock();
     $item->expects($this->any())->method('getProduct')->willReturn($product);
     $item->expects($this->any())->method('getProductType')->willReturn('simple');
     $item->expects($this->any())->method('getCalculationPrice')->willReturn(5);
     $this->imageHelper->expects($this->any())->method('init')->with($product)->willReturnSelf();
     $this->imageHelper->expects($this->any())->method('getUrl')->willReturn('url');
     $this->imageHelper->expects($this->any())->method('getLabel')->willReturn('label');
     $this->imageHelper->expects($this->any())->method('getWidth')->willReturn(100);
     $this->imageHelper->expects($this->any())->method('getHeight')->willReturn(100);
     $this->configurationPool->expects($this->any())->method('getByProductType')->willReturn($product);
     $itemData = $this->model->getItemData($item);
     $this->assertArrayHasKey('options', $itemData);
     $this->assertArrayHasKey('qty', $itemData);
     $this->assertArrayHasKey('item_id', $itemData);
     $this->assertArrayHasKey('configure_url', $itemData);
     $this->assertArrayHasKey('is_visible_in_site_visibility', $itemData);
     $this->assertArrayHasKey('product_type', $itemData);
     $this->assertArrayHasKey('product_name', $itemData);
     $this->assertArrayHasKey('product_sku', $itemData);
     $this->assertArrayHasKey('product_url', $itemData);
     $this->assertArrayHasKey('product_has_url', $itemData);
     $this->assertArrayHasKey('product_price', $itemData);
     $this->assertArrayHasKey('product_price_value', $itemData);
     $this->assertArrayHasKey('product_image', $itemData);
     $this->assertArrayHasKey('canApplyMsrp', $itemData);
 }
Exemplo n.º 2
0
 /**
  * @param \Magento\Catalog\Helper\Image $imageHelper
  * @param \Magento\Msrp\Helper\Data $msrpHelper
  * @param \Magento\Framework\UrlInterface $urlBuilder
  * @param \Magento\Catalog\Helper\Product\ConfigurationPool $configurationPool
  * @param \Magento\Checkout\Helper\Data $checkoutHelper
  * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig
  */
 public function __construct(\Magento\Catalog\Helper\Image $imageHelper, \Magento\Msrp\Helper\Data $msrpHelper, \Magento\Framework\UrlInterface $urlBuilder, \Magento\Catalog\Helper\Product\ConfigurationPool $configurationPool, \Magento\Checkout\Helper\Data $checkoutHelper, \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig)
 {
     parent::__construct($imageHelper, $msrpHelper, $urlBuilder, $configurationPool, $checkoutHelper);
     $this->_scopeConfig = $scopeConfig;
 }