예제 #1
0
 public function testGetLinkAmount()
 {
     $amount = 100;
     $convertedAmount = 50;
     $this->linkMock->expects($this->once())->method('getPrice')->will($this->returnValue($amount));
     $this->linkMock->expects($this->once())->method('getProduct')->will($this->returnValue($this->saleableItemMock));
     $this->priceCurrencyMock->expects($this->once())->method('convertAndRound')->with($amount)->will($this->returnValue($convertedAmount));
     $this->calculatorMock->expects($this->once())->method('getAmount')->with($convertedAmount, $this->equalTo($this->saleableItemMock))->will($this->returnValue($convertedAmount));
     $result = $this->linkPrice->getLinkAmount($this->linkMock);
     $this->assertEquals($convertedAmount, $result);
 }
예제 #2
0
 public function testDelete()
 {
     $linkId = 1;
     $linkMock = $this->getMock('\\Magento\\Downloadable\\Model\\Link', [], [], '', false);
     $this->linkFactoryMock->expects($this->once())->method('create')->willReturn($linkMock);
     $linkMock->expects($this->once())->method('load')->with($linkId)->willReturnSelf();
     $linkMock->expects($this->any())->method('getId')->willReturn($linkId);
     $this->linkResourceMock->expects($this->once())->method('delete')->willReturn(true);
     $this->assertTrue($this->service->delete($linkId));
 }
예제 #3
0
 /**
  * @param \Magento\Catalog\Model\Product|\PHPUnit_Framework_MockObject_MockObject $product
  * @param array $data
  * @param array $expectedItems
  * @dataProvider deleteDataProvider
  */
 public function testDelete($product, array $data, array $expectedItems)
 {
     $this->sampleResource->expects($this->once())->method('deleteItems')->with($this->equalTo($expectedItems));
     $this->target->save($product, $data);
 }