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 testHandlingReservationCreationDelegatesToServicesForValidationAndPersistenceAndNotification() { $persistenceService = $this->getMock('IReservationPersistenceService'); $validationService = $this->getMock('IReservationValidationService'); $notificationService = $this->getMock('IReservationNotificationService'); $page = $this->getMock('IReservationSaveResultsView'); $builder = new ExistingReservationSeriesBuilder(); $series = $builder->Build(); $instance = new Reservation($series, NullDateRange::Instance()); $series->WithCurrentInstance($instance); $validationResult = new ReservationValidationResult(); $validationService->expects($this->once())->method('Validate')->with($this->equalTo($series))->will($this->returnValue($validationResult)); $persistenceService->expects($this->once())->method('Persist')->with($this->equalTo($series)); $notificationService->expects($this->once())->method('Notify')->with($this->equalTo($series)); $page->expects($this->once())->method('SetSaveSuccessfulMessage')->with($this->equalTo(true)); $page->expects($this->once())->method('SetWarnings')->with($this->equalTo($validationResult->GetWarnings())); $handler = new ReservationHandler($persistenceService, $validationService, $notificationService); $handler->Handle($series, $page); }
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); }
/** * @return NullDateRange */ public static function Instance() { if (self::$instance == null) { self::$instance = new NullDateRange(); } return self::$instance; }
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); }