public function testSetProductUnit()
 {
     $item = new QuoteProductOffer();
     $this->assertNull($item->getProductUnitCode());
     $item->setProductUnit((new ProductUnit())->setCode('kg'));
     $this->assertEquals('kg', $item->getProductUnitCode());
 }
 /**
  * @param QuoteProductOffer|null $offer
  * @return array
  */
 protected function createResponseData(QuoteProductOffer $offer = null)
 {
     if (!$offer) {
         return [];
     }
     $price = $offer->getPrice();
     if (!$price) {
         return [];
     }
     $formatter = $this->get('oro_locale.formatter.number');
     return ['id' => $offer->getId(), 'unit' => $offer->getProductUnitCode(), 'qty' => $offer->getQuantity(), 'price' => $formatter->formatCurrency($price->getValue(), $price->getCurrency())];
 }
 /**
  * @param QuoteProductOffer $inputData
  * @param array $expectedData
  *
  * @dataProvider preSetDataProvider
  */
 public function testPreSetData(QuoteProductOffer $inputData = null, array $expectedData = [])
 {
     $this->translator->expects($expectedData['empty_value'] ? $this->once() : $this->never())->method('trans')->with($expectedData['empty_value'], ['{title}' => $inputData ? $inputData->getProductUnitCode() : ''])->will($this->returnValue($expectedData['empty_value']));
     $form = $this->factory->create($this->formType);
     $this->formType->preSetData(new FormEvent($form, $inputData));
     $this->assertTrue($form->has('productUnit'));
     $config = $form->get('productUnit')->getConfig();
     $this->assertEquals(ProductUnitSelectionType::NAME, $config->getType()->getName());
     $options = $form->get('productUnit')->getConfig()->getOptions();
     foreach ($expectedData as $key => $value) {
         $this->assertEquals($value, $options[$key], $key);
     }
 }