Esempio n. 1
0
 public function testSetImageFromChildProduct()
 {
     $productMock = $this->getMockBuilder('\\Magento\\Catalog\\Model\\Product')->setMethods(['__wakeup', 'hasData', 'getData', 'setImage'])->disableOriginalConstructor()->getMock();
     $childProductMock = $this->getMockBuilder('\\Magento\\Catalog\\Model\\Product')->setMethods(['__wakeup', 'getData'])->disableOriginalConstructor()->getMock();
     $productMock->expects($this->at(0))->method('getData')->with('image')->willReturn('no_selection');
     $productMock->expects($this->at(1))->method('getData')->with('image')->willReturn('no_selection');
     $productMock->expects($this->once())->method('hasData')->with('_cache_instance_products')->willReturn(true);
     $productMock->expects($this->at(3))->method('getData')->with('_cache_instance_products')->willReturn([$childProductMock]);
     $childProductMock->expects($this->any())->method('getData')->with('image')->willReturn('image_data');
     $productMock->expects($this->once())->method('setImage')->with('image_data')->willReturnSelf();
     $this->_model->setImageFromChildProduct($productMock);
 }