예제 #1
0
 /**
  * @param State\Booking $booking
  * @return bool
  */
 public function pay(State\Booking $booking)
 {
     // ...
     // Do the necessary to pay
     // ...
     $booking->setState(new Reserved());
     return true;
 }
예제 #2
0
 /**
  * The reservation can always be canceled
  * @param State\Booking $booking
  * @return bool
  */
 public function cancel(State\Booking $booking)
 {
     // ...
     // Cancel the reservation
     // ...
     $booking->setState(new Cancelled());
     return true;
 }
예제 #3
0
 public function testCancelledStateMechanism()
 {
     $this->booking->setState(new BookingState\Cancelled());
     $this->setExpectedException('Exception', 'Already cancelled');
     $this->booking->cancel();
     $this->setExpectedException('Exception', 'Order cancelled');
     $this->booking->pay();
     $this->setExpectedException('Exception', 'Order cancelled');
     $this->booking->reserve();
 }