Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     $this->quoteProductFormatter = $this->getMockBuilder('OroB2B\\Bundle\\SaleBundle\\Formatter\\QuoteProductFormatter')->disableOriginalConstructor()->getMock();
     $this->quoteProductFormatter->expects($this->any())->method('formatTypeLabels')->will($this->returnCallback(function (array $types) {
         return $types;
     }));
     $this->quoteProductOfferFormatter = $this->getMockBuilder('OroB2B\\Bundle\\SaleBundle\\Formatter\\QuoteProductOfferFormatter')->disableOriginalConstructor()->getMock();
     $this->quoteProductOfferFormatter->expects($this->any())->method('formatPriceTypeLabels')->will($this->returnCallback(function (array $types) {
         return $types;
     }));
     parent::setUp();
 }
 /**
  * @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']);
 }
Exemplo n.º 3
0
 public function testFormatProductRequest()
 {
     $this->quoteProductFormatter->expects($this->once())->method('formatRequest')->with(new QuoteProductRequest());
     $this->extension->formatProductRequest(new QuoteProductRequest());
 }
Exemplo n.º 4
0
 /**
  * @param QuoteProductRequest $item
  * @return string
  */
 public function formatProductRequest(QuoteProductRequest $item)
 {
     return $this->quoteProductFormatter->formatRequest($item);
 }
Exemplo n.º 5
0
 /**
  * {@inheritdoc}
  */
 public function buildForm(FormBuilderInterface $builder, array $options)
 {
     $builder->add('product', ProductSelectType::NAME, ['required' => true, 'label' => 'orob2b.product.entity_label', 'create_enabled' => false])->add('productReplacement', ProductSelectType::NAME, ['required' => false, 'label' => 'orob2b.sale.quoteproduct.product_replacement.label', 'create_enabled' => false])->add('quoteProductRequests', QuoteProductRequestCollectionType::NAME, [])->add('quoteProductOffers', QuoteProductOfferCollectionType::NAME, ['add_label' => 'orob2b.sale.quoteproductoffer.add_label'])->add('type', 'choice', ['label' => 'orob2b.sale.quoteproduct.type.label', 'choices' => $this->formatter->formatTypeLabels(QuoteProduct::getTypes()), 'required' => true, 'expanded' => false])->add('commentCustomer', 'textarea', ['required' => false, 'read_only' => true, 'label' => 'orob2b.sale.quoteproduct.comment_customer.label'])->add('comment', 'textarea', ['required' => false, 'label' => 'orob2b.sale.quoteproduct.comment.label']);
     $builder->addEventListener(FormEvents::PRE_SET_DATA, [$this, 'preSetData']);
 }