public function testGetTypeId()
 {
     $productType = $this->getMockBuilder('Magento\\Catalog\\Model\\Product\\Type\\Virtual')->disableOriginalConstructor()->getMockForAbstractClass();
     $this->productTypeInstanceMock->expects($this->exactly(2))->method('factory')->will($this->returnValue($productType));
     $this->model->getTypeInstance();
     $this->model->setTypeId('typeId');
     $this->model->getTypeInstance();
 }
Пример #2
0
 /**
  * Configure environment for `testSave` and `testSaveAndDuplicate` methods
  * @return array
  */
 protected function configureSaveTest()
 {
     $productTypeMock = $this->getMockBuilder('Magento\\Catalog\\Model\\Product\\Type\\Simple')->disableOriginalConstructor()->setMethods(['beforeSave', 'save'])->getMock();
     $productTypeMock->expects($this->once())->method('beforeSave')->will($this->returnSelf());
     $productTypeMock->expects($this->once())->method('save')->will($this->returnSelf());
     $this->productTypeInstanceMock->expects($this->once())->method('factory')->with($this->model)->will($this->returnValue($productTypeMock));
     $this->model->getResource()->expects($this->any())->method('addCommitCallback')->will($this->returnSelf());
     $this->model->getResource()->expects($this->any())->method('commit')->will($this->returnSelf());
 }
Пример #3
0
 public function testGetFinalPricePreset()
 {
     $finalPrice = 9.99;
     $qty = 1;
     $this->model->setQty($qty);
     $this->model->setFinalPrice($finalPrice);
     $this->productTypeInstanceMock->expects($this->never())->method('priceFactory');
     $this->assertEquals($finalPrice, $this->model->getFinalPrice($qty));
 }
Пример #4
0
 public function testGetGalleryAttributeBackend()
 {
     $productType = $this->getMockBuilder('Magento\\Catalog\\Model\\Product\\Type\\AbstractType')->setMethods(['getEditableAttributes'])->disableOriginalConstructor()->getMockForAbstractClass();
     $this->productTypeInstanceMock->expects($this->any())->method('factory')->will($this->returnValue($productType));
     $attributeMediaGallery = $this->getMockBuilder('\\Magento\\Eav\\Model\\Entity\\Attribute\\AbstractAttribute')->setMethods(['__wakeup', 'getAttributeCode', 'getBackend'])->disableOriginalConstructor()->getMockForAbstractClass();
     $attributeMediaGallery->expects($this->any())->method('getAttributeCode')->willReturn('media_gallery');
     $expectedValue = 'expected';
     $attributeMediaGallery->expects($this->once())->method('getBackend')->willReturn($expectedValue);
     $productType->expects($this->once())->method('getEditableAttributes')->willReturn(['media_gallery' => $attributeMediaGallery]);
     $this->assertEquals($expectedValue, $this->model->getGalleryAttributeBackend());
 }