/**
  * {@inheritdoc}
  */
 protected function setUp()
 {
     $this->translator = $this->getMockBuilder('Symfony\\Component\\Translation\\TranslatorInterface')->disableOriginalConstructor()->getMock();
     /* @var $productUnitLabelFormatter \PHPUnit_Framework_MockObject_MockObject|ProductUnitLabelFormatter */
     $productUnitLabelFormatter = $this->getMockBuilder('OroB2B\\Bundle\\ProductBundle\\Formatter\\ProductUnitLabelFormatter')->disableOriginalConstructor()->getMock();
     $productUnitLabelFormatter->expects($this->any())->method('format')->will($this->returnCallback(function ($unitCode, $isShort) {
         return $unitCode . '-formatted-' . ($isShort ? 'short' : 'full');
     }));
     parent::setUp();
     $this->formType = new QuoteProductType($this->translator, $productUnitLabelFormatter, $this->quoteProductFormatter);
     $this->formType->setDataClass('OroB2B\\Bundle\\SaleBundle\\Entity\\QuoteProduct');
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 protected function getExtensions()
 {
     /* @var $translator \PHPUnit_Framework_MockObject_MockObject|TranslatorInterface */
     $translator = $this->getMockBuilder('Symfony\\Component\\Translation\\TranslatorInterface')->disableOriginalConstructor()->getMock();
     /* @var $productUnitLabelFormatter \PHPUnit_Framework_MockObject_MockObject|ProductUnitLabelFormatter */
     $productUnitLabelFormatter = $this->getMockBuilder('OroB2B\\Bundle\\ProductBundle\\Formatter\\ProductUnitLabelFormatter')->disableOriginalConstructor()->getMock();
     $userSelectType = new StubEntityType([1 => $this->getEntity('Oro\\Bundle\\UserBundle\\Entity\\User', 1), 2 => $this->getEntity('Oro\\Bundle\\UserBundle\\Entity\\User', 2)], 'oro_user_select');
     $accountSelectType = new StubEntityType([1 => $this->getEntity('OroB2B\\Bundle\\AccountBundle\\Entity\\Account', 1), 2 => $this->getEntity('OroB2B\\Bundle\\AccountBundle\\Entity\\Account', 2)], AccountSelectType::NAME);
     $accountUserSelectType = new StubEntityType([1 => $this->getEntity('OroB2B\\Bundle\\AccountBundle\\Entity\\AccountUser', 1), 2 => $this->getEntity('OroB2B\\Bundle\\AccountBundle\\Entity\\AccountUser', 2)], AccountUserSelectType::NAME);
     $priceType = $this->preparePriceType();
     $entityType = $this->prepareProductEntityType();
     $productSelectType = new ProductSelectTypeStub();
     $currencySelectionType = new CurrencySelectionTypeStub();
     $productUnitSelectionType = $this->prepareProductUnitSelectionType();
     $quoteProductOfferType = $this->prepareQuoteProductOfferType();
     $quoteProductRequestType = $this->prepareQuoteProductRequestType();
     $quoteProductType = new QuoteProductType($translator, $productUnitLabelFormatter, $this->quoteProductFormatter);
     $quoteProductType->setDataClass('OroB2B\\Bundle\\SaleBundle\\Entity\\QuoteProduct');
     return [new PreloadedExtension([OroDateTimeType::NAME => new OroDateTimeType(), CollectionType::NAME => new CollectionType(), QuoteProductOfferType::NAME => new QuoteProductOfferType($this->quoteProductOfferFormatter), QuoteProductCollectionType::NAME => new QuoteProductCollectionType(), QuoteProductOfferCollectionType::NAME => new QuoteProductOfferCollectionType(), QuoteProductRequestCollectionType::NAME => new QuoteProductRequestCollectionType(), ProductRemovedSelectType::NAME => new StubProductRemovedSelectType(), ProductUnitRemovedSelectionType::NAME => new StubProductUnitRemovedSelectionType(), $priceType->getName() => $priceType, $entityType->getName() => $entityType, $userSelectType->getName() => $userSelectType, $quoteProductType->getName() => $quoteProductType, $productSelectType->getName() => $productSelectType, $currencySelectionType->getName() => $currencySelectionType, $quoteProductOfferType->getName() => $quoteProductOfferType, $quoteProductRequestType->getName() => $quoteProductRequestType, $productUnitSelectionType->getName() => $productUnitSelectionType, $accountSelectType->getName() => $accountSelectType, $accountUserSelectType->getName() => $accountUserSelectType], []), $this->getValidatorExtension(true)];
 }