protected function mockContext()
 {
     $this->context = $this->getMockBuilder('Magento\\Catalog\\Block\\Product\\Context')->disableOriginalConstructor()->getMock();
     $this->imageHelper = $this->getMockBuilder('Magento\\Catalog\\Helper\\Image')->disableOriginalConstructor()->getMock();
     $this->context->expects($this->any())->method('getImageHelper')->willReturn($this->imageHelper);
     $this->registry = $this->getMockBuilder('Magento\\Framework\\Registry')->disableOriginalConstructor()->getMock();
     $this->context->expects($this->any())->method('getRegistry')->willReturn($this->registry);
 }
Beispiel #2
0
 /**
  * Set up mocks and tested class
  * Child class is used as the tested class is declared abstract
  */
 public function setUp()
 {
     $this->productContextMock = $this->getMock('Magento\\Catalog\\Block\\Product\\Context', ['getLayout'], [], '', false);
     $arrayUtilsMock = $this->getMock('Magento\\Framework\\Stdlib\\ArrayUtils', [], [], '', false);
     $this->layoutMock = $this->getMock('Magento\\Framework\\View\\Layout', ['getBlock'], [], '', false);
     $this->productContextMock->expects($this->once())->method('getLayout')->will($this->returnValue($this->layoutMock));
     $this->block = new \Magento\Catalog\Block\Product\View\Type\Simple($this->productContextMock, $arrayUtilsMock);
 }
Beispiel #3
0
 protected function setUp()
 {
     $this->layout = $this->getMockBuilder('Magento\\Framework\\View\\LayoutInterface')->getMockForAbstractClass();
     $this->productContext = $this->getMockBuilder('Magento\\Catalog\\Block\\Product\\Context')->disableOriginalConstructor()->getMock();
     $this->productContext->expects($this->any())->method('getLayout')->willReturn($this->layout);
     $this->httpContext = $this->getMockBuilder('Magento\\Framework\\App\\Http\\Context')->disableOriginalConstructor()->getMock();
     $this->block = new Sidebar($this->productContext, $this->httpContext);
 }
Beispiel #4
0
 /**
  * Set up mocks and tested class
  * Child class is used as the tested class is declared abstract
  */
 public function setUp()
 {
     $this->productContextMock = $this->getMock('Magento\\Catalog\\Block\\Product\\Context', ['getLayout', 'getStockRegistry'], [], '', false);
     $arrayUtilsMock = $this->getMock('Magento\\Framework\\Stdlib\\ArrayUtils', [], [], '', false);
     $this->layoutMock = $this->getMock('Magento\\Framework\\View\\Layout', ['getBlock'], [], '', false);
     $this->stockRegistryMock = $this->getMockForAbstractClass('Magento\\CatalogInventory\\Api\\StockRegistryInterface', [], '', false, true, true, ['getStockItem']);
     $this->productContextMock->expects($this->once())->method('getStockRegistry')->will($this->returnValue($this->stockRegistryMock));
     $this->productContextMock->expects($this->once())->method('getLayout')->will($this->returnValue($this->layoutMock));
     $this->block = new \Magento\Catalog\Block\Product\View\Type\Simple($this->productContextMock, $arrayUtilsMock);
 }
Beispiel #5
0
 /**
  * Set up
  */
 protected function setUp()
 {
     $this->contextMock = $this->getMock('\\Magento\\Catalog\\Block\\Product\\Context', [], [], '', false);
     $this->arrayUtilsMock = $this->getMock('\\Magento\\Framework\\Stdlib\\ArrayUtils', [], [], '', false);
     $this->mediaHelperMock = $this->getMock('\\Magento\\ProductVideo\\Helper\\Media', [], [], '', false);
     $this->jsonEncoderMock = $this->getMock('\\Magento\\Framework\\Json\\EncoderInterface', [], [], '', false);
     $this->coreRegistry = $this->getMock('\\Magento\\Framework\\Registry', [], [], '', false);
     $this->contextMock->expects($this->once())->method('getRegistry')->willReturn($this->coreRegistry);
     $this->productModelMock = $this->getMock('\\Magento\\Catalog\\Model\\Product', [], [], '', false);
     $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->gallery = $objectManager->getObject('\\Magento\\ProductVideo\\Block\\Product\\View\\Gallery', ['context' => $this->contextMock, 'arrayUtils' => $this->arrayUtilsMock, 'mediaHelper' => $this->mediaHelperMock, 'jsonEncoder' => $this->jsonEncoderMock]);
 }
 public function setUp()
 {
     $this->context = $this->getMock('\\Magento\\Catalog\\Block\\Product\\Context', [], [], '', false);
     $this->arrayUtils = $this->getMock('\\Magento\\Framework\\Stdlib\\ArrayUtils', [], [], '', false);
     $this->jsonEncoder = $this->getMock('\\Magento\\Framework\\Json\\EncoderInterface', [], [], '', false);
     $this->helper = $this->getMock('\\Magento\\ConfigurableProduct\\Helper\\Data', [], [], '', false);
     $this->swatchHelper = $this->getMock('\\Magento\\Swatches\\Helper\\Data', [], [], '', false);
     $this->swatchMediaHelper = $this->getMock('\\Magento\\Swatches\\Helper\\Media', [], [], '', false);
     $this->catalogProduct = $this->getMock('\\Magento\\Catalog\\Helper\\Product', [], [], '', false);
     $this->currentCustomer = $this->getMock('\\Magento\\Customer\\Helper\\Session\\CurrentCustomer', [], [], '', false);
     $this->priceCurrency = $this->getMock('\\Magento\\Framework\\Pricing\\PriceCurrencyInterface', [], [], '', false);
     $this->product = $this->getMock('\\Magento\\Catalog\\Model\\Product', [], [], '', false);
     $this->typeInstance = $this->getMock('\\Magento\\Catalog\\Model\\Product\\Type\\AbstractType', [], [], '', false);
     $this->scopeConfig = $this->getMock('\\Magento\\Framework\\App\\Config\\ScopeConfigInterface', [], [], '', false);
     $this->imageHelper = $this->getMock('\\Magento\\Catalog\\Helper\\Image', [], [], '', false);
     $this->urlBuilder = $this->getMock('\\Magento\\Framework\\UrlInterface');
     $this->context->expects($this->any())->method('getScopeConfig')->willReturn($this->scopeConfig);
     $this->context->expects($this->any())->method('getImageHelper')->willReturn($this->imageHelper);
     $this->context->expects($this->any())->method('getUrlBuilder')->willReturn($this->urlBuilder);
     $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
     $this->configurable = $objectManager->getObject('\\Magento\\Swatches\\Block\\Product\\Renderer\\Configurable', ['context' => $this->context, 'arrayUtils' => $this->arrayUtils, 'jsonEncoder' => $this->jsonEncoder, 'helper' => $this->helper, 'swatchHelper' => $this->swatchHelper, 'swatchMediaHelper' => $this->swatchMediaHelper, 'catalogProduct' => $this->catalogProduct, 'currentCustomer' => $this->currentCustomer, 'priceCurrency' => $this->priceCurrency, 'data' => []]);
 }