public function testGetAmount() { $resultPrice = rand(1, 9); $this->price->expects($this->once())->method('getValue')->willReturn($resultPrice); $this->priceInfo->expects($this->once())->method('getPrice')->with(BasePrice::PRICE_CODE)->willReturn($this->price); $this->calculator->expects($this->once())->method('getAmount')->with($resultPrice, $this->saleableItem)->willReturn($resultPrice); $this->assertEquals($resultPrice, $this->model->getAmount()); }
public function testGetAmount() { $this->setupSelectionPrice(); $price = 10.0; $amount = 20.0; $this->priceInfoMock->expects($this->once())->method('getPrice')->with(\Magento\Bundle\Pricing\Price\FinalPrice::PRICE_CODE)->willReturn($this->finalPriceMock); $this->finalPriceMock->expects($this->once())->method('getValue')->willReturn($price); $this->discountCalculatorMock->expects($this->once())->method('calculateDiscount')->with($this->bundleMock, $price)->willReturn($price); $this->priceCurrencyMock->expects($this->once())->method('round')->with($price)->willReturn($price); $this->bundleMock->expects($this->any())->method('getPriceType')->willReturn(\Magento\Bundle\Model\Product\Price::PRICE_TYPE_DYNAMIC); $this->calculatorMock->expects($this->once())->method('getAmount')->with($price, $this->productMock, null)->willReturn($amount); $this->assertEquals($amount, $this->selectionPrice->getAmount()); }