/** * {@inheritdoc} */ public function reverseTransform($value) { $offer = null; $offerQuantity = null; if ($value) { if (!is_array($value)) { throw new UnexpectedTypeException($value, 'array'); } $offerQuantity = $this->getOption($value, QuoteProductToOrderType::FIELD_QUANTITY); $offerUnit = $this->getOption($value, QuoteProductToOrderType::FIELD_UNIT); if ($offerQuantity && $offerUnit) { $offerQuantity = $this->roundQuantity($offerQuantity, $offerUnit); $offer = $this->matcher->match($this->quoteProduct, $offerUnit, $offerQuantity); } } return [QuoteProductToOrderType::FIELD_QUANTITY => $offerQuantity, QuoteProductToOrderType::FIELD_OFFER => $offer]; }
/** * @dataProvider matchDataProvider * * @param $quoteProduct * @param $unitCode * @param $quantity * @param $expectedResult */ public function testMatch($quoteProduct, $unitCode, $quantity, $expectedResult) { $this->assertEquals($expectedResult, $this->matcher->match($quoteProduct, $unitCode, $quantity)); }