/**
  * @param float $cost
  * @param Event $event
  * @param User $user
  * @param DateTime $now
  *
  * @return number
  */
 protected function getVariation($cost, Event $event, User $user, DateTime $now)
 {
     $variation = $cost * $event->getRegistrationInfo()->getCostVariation() / 100;
     if (!$this->talkManager->eventHasAnyApprovedTalk($event) || $event->isSpeakerPromotionalPeriod($now) && $this->talkManager->userHasAnyTalk($user, $event)) {
         return $variation * -1;
     }
     if ($event->isLateRegistrationPeriod($now)) {
         return $variation;
     }
 }
 /**
  * @test
  * @covers PHPSC\Conference\Domain\Service\RegistrationCostCalculator::__construct
  * @covers PHPSC\Conference\Domain\Service\RegistrationCostCalculator::getBaseCost
  * @covers PHPSC\Conference\Domain\Service\RegistrationCostCalculator::getVariation
  * @covers PHPSC\Conference\Domain\Service\RegistrationCostCalculator::getCost
  * @covers PHPSC\Conference\Domain\Service\RegistrationCostCalculator::getStudentDiscount
  */
 public function getCostShouldApplyDiscountWhenAttendeeHasACoupon()
 {
     $this->event->expects($this->any())->method('hasAttendeeRegistration')->willReturn(true);
     $discount = $this->getMock(DiscountCoupon::class);
     $discount->expects($this->any())->method('applyDiscountTo')->willReturn(50);
     $this->attendee->expects($this->any())->method('isStudentRegistration')->willReturn(false);
     $this->attendee->expects($this->any())->method('canAttendTalksDayOnly')->willReturn(false);
     $this->attendee->expects($this->any())->method('getDiscount')->willReturn($discount);
     $this->talkManager->expects($this->any())->method('eventHasAnyApprovedTalk')->willReturn(true);
     $this->event->expects($this->any())->method('isLateRegistrationPeriod')->willReturn(false);
     $this->assertEquals(50, $this->calculator->getCost($this->attendee, new DateTime()));
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function import()
 {
     if ($this->findById(1)) {
         return;
     }
     $event = new Event();
     $event->setId(1);
     $event->setLocation($this->findLocation());
     $event->setName('Evento de exemplo');
     $event->setStartDate(DateTime::createFromFormat('H:i:s', '00:00:00'));
     $event->setEndDate(DateTime::createFromFormat('H:i:s', '23:59:59'));
     $event->setSubmissionStart(DateTime::createFromFormat('H:i:s', '00:00:00'));
     $event->setSubmissionEnd(DateTime::createFromFormat('H:i:s', '23:59:59'));
     $event->getEndDate()->modify('+30 days');
     $event->getSubmissionEnd()->modify('+30 days');
     $this->forceAssignedIds($event);
     $this->manager->persist($event);
     $this->manager->flush();
 }
Example #4
0
 /**
  * @test
  * @covers PHPSC\Conference\Domain\Entity\Event::__construct
  * @covers PHPSC\Conference\Domain\Entity\Event::getSubmissionStart
  * @covers PHPSC\Conference\Domain\Entity\Event::setSubmissionStart
  * @covers PHPSC\Conference\Domain\Entity\Event::getSubmissionEnd
  * @covers PHPSC\Conference\Domain\Entity\Event::setSubmissionEnd
  * @covers PHPSC\Conference\Domain\Entity\Event::hasTalkSubmissions
  * @covers PHPSC\Conference\Domain\Entity\Event::getTalkEvaluationEnd
  * @covers PHPSC\Conference\Domain\Entity\Event::isSpeakerPromotionalPeriod
  */
 public function isSpeakerPromotionalPeriodShouldReturnTrueWhenGivenDateIsBetweenEvaluationEndAndAWeekAfterIt()
 {
     $event = new Event();
     $event->setSubmissionStart(new DateTime('2014-04-01 00:00:00'));
     $event->setSubmissionEnd(new DateTime('2014-05-31 23:59:59'));
     $this->assertTrue($event->isSpeakerPromotionalPeriod(new DateTime('2014-06-14 23:59:59')));
 }
Example #5
0
 /**
  * @param Event $event
  * @return boolean
  */
 public function hasManagementPrivilegesOn(Event $event)
 {
     if ($this->isAdmin()) {
         return true;
     }
     return $event->isEvaluator($this);
 }