Ejemplo n.º 1
0
 public function testDelete()
 {
     $entityId = 3;
     $optionMock = $this->getMockBuilder(Attribute::class)->disableOriginalConstructor()->getMock();
     $this->configurableTypeResource->expects(self::once())->method('getEntityIdByAttribute')->with($optionMock)->willReturn($entityId);
     $this->productRepositoryMock->expects(self::once())->method('getById')->with($entityId)->willReturn($this->productMock);
     $this->productMock->expects(self::once())->method('getTypeId')->willReturn(Configurable::TYPE_CODE);
     $this->configurableTypeResource->expects(self::once())->method('saveProducts')->with($this->productMock);
     $this->optionResource->expects(self::once())->method('delete')->with($optionMock)->willReturn(true);
     $result = $this->model->delete($optionMock);
     $this->assertTrue($result);
 }
 public function testDelete()
 {
     $productId = 3;
     $optionId = 33;
     $option = $this->getMockBuilder('Magento\\ConfigurableProduct\\Model\\Product\\Type\\Configurable\\Attribute')->disableOriginalConstructor()->setMethods(['getProductId', 'getId'])->getMockForAbstractClass();
     $option->expects($this->any())->method('getProductId')->willReturn($productId);
     $option->expects($this->any())->method('getId')->willReturn($optionId);
     $this->productRepositoryMock->expects($this->once())->method('getById')->with($productId)->willReturn($this->productMock);
     $this->productMock->expects($this->once())->method('getTypeId')->willReturn(Configurable::TYPE_CODE);
     $this->configurableTypeResource->expects($this->once())->method('saveProducts')->with($this->productMock);
     $this->optionResource->expects($this->once())->method('delete')->with($option);
     $result = $this->model->delete($option);
     $this->assertTrue($result);
 }