/** * @expectedException \Magento\Framework\Exception\NoSuchEntityException * @expectedExceptionMessage There is no downloadable link with provided ID. */ public function testDeleteThrowsExceptionIfLinkIdIsNotValid() { $linkId = 1; $linkMock = $this->getMock('\\Magento\\Downloadable\\Model\\Link', array(), array(), '', false); $this->linkFactoryMock->expects($this->once())->method('create')->will($this->returnValue($linkMock)); $linkMock->expects($this->once())->method('load')->with($linkId)->will($this->returnSelf()); $linkMock->expects($this->once())->method('getId'); $linkMock->expects($this->never())->method('delete'); $this->service->delete($linkId); }
public function testDelete() { $cartId = 65; $this->quoteRepositoryMock->expects($this->once())->method('get')->with($cartId)->will($this->returnValue($this->quoteMock)); $this->quoteMock->expects($this->once())->method('getItemsCount')->will($this->returnValue(12)); $this->quoteMock->expects($this->once())->method('getShippingAddress')->will($this->returnValue($this->quoteAddressMock)); $this->quoteAddressMock->expects($this->once())->method('setCollectShippingRates')->with(true); $this->quoteMock->expects($this->once())->method('setCouponCode')->with(''); $this->quoteMock->expects($this->once())->method('collectTotals')->will($this->returnValue($this->quoteMock)); $this->quoteMock->expects($this->once())->method('collectTotals')->will($this->returnValue($this->quoteMock)); $this->quoteMock->expects($this->once())->method('save'); $this->quoteMock->expects($this->once())->method('getCouponCode')->will($this->returnValue('')); $this->assertTrue($this->service->delete($cartId)); }