public function testHandlingReservationCreationDelegatesToServicesForValidationAndPersistenceAndNotification()
 {
     $builder = new ExistingReservationSeriesBuilder();
     $series = $builder->Build();
     $instance = new Reservation($series, NullDateRange::Instance());
     $series->WithCurrentInstance($instance);
     $this->handler->expects($this->once())->method('Handle')->with($this->equalTo($series), $this->equalTo($this->page))->will($this->returnValue(true));
     $this->presenter->HandleReservation($series);
 }
 public function PageLoad()
 {
     $referenceNumber = $this->page->GetReferenceNumber();
     Log::Debug('User: %s, Approving reservation with reference number %s', $this->userSession->UserId, $referenceNumber);
     $series = $this->persistenceService->LoadByReferenceNumber($referenceNumber);
     if ($this->authorization->CanApprove(new ReservationViewAdapter($series), $this->userSession)) {
         $series->Approve($this->userSession);
         $this->handler->Handle($series, $this->page);
     }
 }
 public function testLoadAndApprovesReservationSendingNotifications()
 {
     $referenceNumber = 'rn';
     $builder = new ExistingReservationSeriesBuilder();
     $reservation = $builder->Build();
     $this->page->expects($this->once())->method('GetReferenceNumber')->will($this->returnValue($referenceNumber));
     $this->persistence->expects($this->once())->method('LoadByReferenceNumber')->with($this->equalTo($referenceNumber))->will($this->returnValue($reservation));
     $this->handler->expects($this->once())->method('Handle')->with($this->equalTo($reservation), $this->equalTo($this->page))->will($this->returnValue(true));
     $this->auth->expects($this->once())->method('CanApprove')->with($this->equalTo(new ReservationViewAdapter($reservation)), $this->equalTo($this->fakeUser))->will($this->returnValue(true));
     $this->presenter->PageLoad();
     $this->assertTrue(in_array(new SeriesApprovedEvent($reservation), $reservation->GetEvents()));
 }
 public function testUpdatesReservationAttributeIfTheUserCanEdit()
 {
     $referenceNumber = 'rn';
     $id = 111;
     $value = 'new attribute value';
     $user = $this->fakeUser;
     $resultCollector = new ManageReservationsUpdateAttributeResultCollector();
     $reservation = new ExistingReservationSeries();
     $reservation->UpdateBookedBy($user);
     $reservation->AddAttributeValue(new AttributeValue($id, $value));
     $this->persistenceService->expects($this->once())->method('LoadByReferenceNumber')->with($this->equalTo($referenceNumber))->will($this->returnValue($reservation));
     $this->reservationHandler->expects($this->once())->method('Handle')->with($this->equalTo($reservation), $this->equalTo($resultCollector));
     $result = $this->service->UpdateAttribute($referenceNumber, $id, $value, $user);
 }
 /**
  * @param ReservationSeries $reservationSeries
  */
 public function HandleReservation($reservationSeries)
 {
     $successfullySaved = $this->_handler->Handle($reservationSeries, $this->_page);
     if ($successfullySaved) {
         $this->_page->SetRequiresApproval($reservationSeries->RequiresApproval());
         $this->_page->SetReferenceNumber($reservationSeries->CurrentInstance()->ReferenceNumber());
     }
 }
 public function testHandlingReservationCreationDelegatesToHandler()
 {
     $series = new TestReservationSeries();
     $instance = new Reservation($series, NullDateRange::Instance());
     $series->WithCurrentInstance($instance);
     $this->handler->expects($this->once())->method('Handle')->with($this->equalTo($series), $this->isInstanceOf('FakeReservationSavePage'))->will($this->returnValue(true));
     $this->presenter->HandleReservation($series);
     $this->assertEquals($instance->ReferenceNumber(), $this->page->referenceNumber);
     $this->assertEquals($series->RequiresApproval(), $this->page->requiresApproval);
 }
 /**
  * @param string $referenceNumber
  * @param int $attributeId
  * @param string $attributeValue
  * @param UserSession $userSession
  * @return string[] Any errors that were returned during reservation update
  */
 public function UpdateAttribute($referenceNumber, $attributeId, $attributeValue, $userSession)
 {
     $reservation = $this->persistenceService->LoadByReferenceNumber($referenceNumber);
     $reservation->UpdateBookedBy($userSession);
     $attributeValues = $reservation->AttributeValues();
     $attributeValues[$attributeId] = $attributeValue;
     $reservation->ChangeAttribute(new AttributeValue($attributeId, $attributeValue));
     $collector = new ManageReservationsUpdateAttributeResultCollector();
     $this->reservationHandler->Handle($reservation, $collector);
     return $collector->errors;
 }
 public function testHandlingReservationCreationDelegatesToServicesForValidationAndPersistenceAndNotification()
 {
     $builder = new ExistingReservationSeriesBuilder();
     $series = $builder->Build();
     $series->SetStatusId(ReservationStatus::Pending);
     $instance = new Reservation($series, NullDateRange::Instance());
     $series->WithCurrentInstance($instance);
     $this->handler->expects($this->once())->method('Handle')->with($this->equalTo($series), $this->isInstanceOf('FakeReservationUpdatePage'))->will($this->returnValue(true));
     $this->presenter->HandleReservation($series);
     $this->assertEquals($instance->ReferenceNumber(), $this->page->referenceNumber);
     $this->assertEquals($series->RequiresApproval(), $this->page->requiresApproval);
 }
 /**
  * @param ExistingReservationSeries $reservationSeries
  */
 public function HandleReservation($reservationSeries)
 {
     Log::Debug("Deleting reservation %s", $reservationSeries->CurrentInstance()->ReferenceNumber());
     $this->handler->Handle($reservationSeries, $this->page);
 }