예제 #1
0
파일: StateTest.php 프로젝트: arcturial/fsm
 public function testType()
 {
     $state = new State('test', StateInterface::TYPE_FINAL);
     $this->assertSame('test', $state->getName());
     $this->assertSame(StateInterface::TYPE_FINAL, $state->getType());
 }
예제 #2
0
파일: Graph.php 프로젝트: arcturial/fsm
 protected function configureMachine()
 {
     $created = new State('created', StateInterface::TYPE_INITIAL);
     $auth = new State('auth', StateInterface::TYPE_INTERMEDIATE);
     $pending = new State('pending', StateInterface::TYPE_INTERMEDIATE);
     $pending->addAction(new PendingAction($this->payment));
     $committed = new State('committed', StateInterface::TYPE_FINAL);
     $reversed = new State('reversed', StateInterface::TYPE_FINAL);
     $authPayment = new Transition($created, $auth);
     $commitPayment = new Transition($auth, $committed);
     $commitPayment->addCondition(new FraudAcceptPayment());
     $commitPaymentReview = new Transition($auth, $pending);
     $commitPaymentReview->addCondition(new FraudReviewCondition());
     $approvePayment = new Transition($pending, $committed);
     $approvePayment->addCondition(new FinancePermissions());
     $reversePayment = new Transition($committed, $reversed);
     $this->addTransition($authPayment);
     $this->addTransition($commitPayment);
     $this->addTransition($approvePayment);
     $this->addTransition($commitPaymentReview);
     $this->addTransition($reversePayment);
     $this->addTrigger('authorize', array($authPayment));
     $this->addTrigger('commit', array($commitPayment, $commitPaymentReview, $approvePayment));
     $this->addTrigger('approve', array($approvePayment));
     // Set the current state of the object
     $this->setCurrentState($this->payment->state);
 }