public function __construct(AbstractPromotion $promotion, DTOBuilderFactoryInterface $dtoBuilderFactory)
 {
     $this->entity = $promotion;
     $this->dtoBuilderFactory = $dtoBuilderFactory;
     $this->entityDTO = $this->getEntityDTO();
     $this->setId();
     $this->setTime();
     $this->setStartEndDate();
     $this->setRedemption();
     $this->entityDTO->name = $this->entity->getName();
     $this->entityDTO->value = $this->entity->getValue();
     $this->entityDTO->reducesTaxSubtotal = $this->entity->getReducesTaxSubtotal();
     $this->entityDTO->isRedemptionCountValid = $this->entity->isRedemptionCountValid();
     $this->entityDTO->type = $this->dtoBuilderFactory->getPromotionTypeDTOBuilder($this->entity->getType())->build();
 }
 public function testCreate()
 {
     $this->promotion->setName('20% Off in 2014');
     $this->promotion->setType(PromotionType::percent());
     $this->promotion->setValue(20);
     $this->promotion->setRedemptions(10);
     $this->promotion->setMaxRedemptions(100);
     $this->promotion->setReducesTaxSubtotal(true);
     $this->promotion->setStart(new DateTime());
     $this->promotion->setEnd(new DateTime());
     $this->assertEntityValid($this->promotion);
     $this->assertSame('20% Off in 2014', $this->promotion->getName());
     $this->assertSame(20, $this->promotion->getValue());
     $this->assertSame(10, $this->promotion->getRedemptions());
     $this->assertSame(100, $this->promotion->getMaxRedemptions());
     $this->assertSame(true, $this->promotion->getReducesTaxSubtotal());
     $this->assertTrue($this->promotion->getStart() instanceof DateTime);
     $this->assertTrue($this->promotion->getEnd() instanceof DateTime);
     $this->assertTrue($this->promotion->getType()->isPercent());
 }