/** * */ 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); }
/** * */ 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); }
/** * @param string $name */ public function getState($name) { return $this->states->getState($name); }
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]); }