/** * @param array $inputData * @param array $expectedData * * @dataProvider formatOfferProvider */ public function testFormatOffer(array $inputData, array $expectedData) { /* @var $item QuoteProductOffer */ $item = $inputData['item']; $item->setQuantity($inputData['quantity'])->setProductUnit($inputData['unit'])->setProductUnitCode($inputData['unitCode'])->setPrice($inputData['price']); $this->productUnitValueFormatter->expects($inputData['unit'] ? $this->once() : $this->never())->method('format')->with($inputData['quantity'], $inputData['unitCode'])->will($this->returnValue($expectedData['formattedUnits'])); $price = $inputData['price'] ?: new Price(); $this->numberFormatter->expects($price ? $this->once() : $this->never())->method('formatCurrency')->with($price->getValue(), $price->getCurrency())->will($this->returnValue($expectedData['formattedPrice'])); $this->productUnitLabelFormatter->expects($this->once())->method('format')->with($inputData['unitCode'])->will($this->returnValue($expectedData['formattedUnit'])); $this->translator->expects($this->once())->method('transChoice')->with($expectedData['transConstant'], $expectedData['transIndex'], ['{units}' => $expectedData['formattedUnits'], '{price}' => $expectedData['formattedPrice'], '{unit}' => $expectedData['formattedUnit']]); $this->formatter->formatOffer($inputData['item']); }
/** * @param QuoteProductOffer $item * @return string */ public function formatProductOffer(QuoteProductOffer $item) { return $this->quoteProductFormatter->formatOffer($item); }