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 PageLoad()
 {
     try {
         $reservationAction = ReservationAction::Approve;
         $factory = new ReservationPersistenceFactory();
         $persistenceService = $factory->Create($reservationAction);
         $handler = ReservationHandler::Create($reservationAction, $persistenceService, ServiceLocator::GetServer()->GetUserSession());
         $auth = new ReservationAuthorization(PluginManager::Instance()->LoadAuthorization());
         $presenter = new ReservationApprovalPresenter($this, $persistenceService, $handler, $auth, ServiceLocator::GetServer()->GetUserSession());
         $presenter->PageLoad();
     } catch (Exception $ex) {
         Log::Error('ReservationApprovalPage - Critical error saving reservation: %s', $ex);
         $this->Display('Ajax/reservation/reservation_error.tpl');
     }
 }