/**
  * @param Attendee $attendee
  * @param string $redirectTo
  * @return array
  */
 public function createPayment(Attendee $attendee, $redirectTo)
 {
     $payment = $this->paymentManager->create($this->costCalculator->getCost($attendee, new DateTime()), $this->getItemDescription($attendee->getEvent()));
     $this->attendeeManager->appendPayment($attendee, $payment);
     if ($attendee->getEvent()->isLateRegistrationPeriod($payment->getCreationTime())) {
         return array('data' => array('id' => $attendee->getId(), 'redirectTo' => $redirectTo));
     }
     $paymentResponse = $this->paymentManager->requestPayment($payment, $attendee->getUser()->getEmail(), $redirectTo);
     //TODO Refactor this!
     return array('data' => array('id' => $attendee->getId(), 'redirectTo' => $paymentResponse->getRedirectionUrl()));
 }
 /**
  * @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()));
 }