/**
  * @param Attendee $attendee
  */
 public function registerPayment(Attendee $attendee)
 {
     $attendee->setStatus(Attendee::WAITING_PAYMENT);
     $this->registrationService->createPayment($attendee, '');
     $this->paymentService->approvePayment($attendee->getLastPayment(), false);
     $this->confirm($attendee);
 }
 /**
  * @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()));
 }
 /**
  * @param float $cost
  * @param Attendee $attendee
  *
  * @return number
  */
 protected function getStudentDiscount($cost, Attendee $attendee)
 {
     if ($attendee->isStudentRegistration()) {
         return $cost * $attendee->getEvent()->getRegistrationInfo()->getStudentDiscount() / 100;
     }
 }
Esempio n. 4
0
 /**
  * @param Event $event
  * @param User $user
  * @param boolean $isStudent
  * @param string $registrationType
  * @return Attendee
  */
 public function create(Event $event, User $user, $isStudent, $registrationType)
 {
     $attendee = new Attendee();
     $attendee->setEvent($event);
     $attendee->setUser($user);
     $attendee->setStatus(Attendee::WAITING_PAYMENT);
     $attendee->setArrived(false);
     $attendee->setStudentRegistration($isStudent);
     $attendee->setRegistrationType($registrationType);
     $attendee->setCreationTime(new DateTime());
     if ($this->talkService->userHasAnyApprovedTalk($user, $event)) {
         $attendee->setStatus(Attendee::PAYMENT_NOT_NECESSARY);
         $attendee->setRegistrationType(Attendee::WORKSHOPS_AND_TALKS);
     }
     return $attendee;
 }
 /**
  * @param Attendee $attendee
  */
 public function appendPayment(Attendee $attendee, Payment $payment)
 {
     $attendee->addPayment($payment);
     $this->repository->update($attendee);
 }