getState() public method

public getState ( $name )
コード例 #1
0
 /**
  *
  */
 public function testFiltersStatesThatHaveNoOutgoingTransitions()
 {
     $eventName = 'event';
     $stateCollection = new StateCollection();
     $helper = new SetupHelper($stateCollection);
     $helper->findOrCreateTransition('foo', 'bar', $eventName);
     $filter = new FilterStateByFinalState($stateCollection->getStates());
     $filteredStates = iterator_to_array($filter);
     $this->assertContains($stateCollection->getState('bar'), $filteredStates);
     $this->assertNotContains($stateCollection->getState('foo'), $filteredStates);
 }
コード例 #2
0
 /**
  *
  */
 public function testFiltersStatesThatHaveTransitionsWithoutAnEvent()
 {
     $eventName = 'event';
     $stateCollection = new StateCollection();
     $helper = new SetupHelper($stateCollection);
     $helper->findOrCreateTransition('foo', 'bar', $eventName);
     $helper->findOrCreateTransition('bar', 'baz', null, new Tautology('condition'));
     $filter = new FilterStateByTransition($stateCollection->getStates());
     $filteredStates = iterator_to_array($filter);
     $this->assertNotContains($stateCollection->getState('foo'), $filteredStates);
     $this->assertContains($stateCollection->getState('bar'), $filteredStates);
     $this->assertNotContains($stateCollection->getState('baz'), $filteredStates);
 }
コード例 #3
0
ファイル: Process.php プロジェクト: jiangyu7408/Statemachine
 /**
  * @param string $name
  */
 public function getState($name)
 {
     return $this->states->getState($name);
 }
コード例 #4
0
 public function testCopiesAllFlags()
 {
     $targetCollection = new StateCollection();
     $merger = new StateCollectionMerger($targetCollection);
     $sourceCollection = $this->createSourceCollection();
     $merger->merge($sourceCollection);
     $state = $targetCollection->getState('new');
     $this->assertArrayHasKey(self::FLAG_FOR_TEST, $state);
     $this->assertEquals(self::FLAG_FOR_TEST_VALUE, $state[self::FLAG_FOR_TEST]);
     $event = $state->getEvent('start');
     $this->assertArrayHasKey(self::FLAG_FOR_TEST, $event);
     $this->assertEquals(self::FLAG_FOR_TEST_VALUE, $event[self::FLAG_FOR_TEST]);
 }