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())); }