public function testDotFormatWithEvent() { $attributes = $this->getMock('\\StateMachine\\AttributeCollectionInterface'); $event = $this->getMockBuilder('\\StateMachine\\EventInterface')->disableOriginalConstructor()->getMock(); $event->expects($this->any())->method('getName')->willReturn('eventName'); $event->expects($this->any())->method('getStates')->willReturn(['target' => 'targetState', 'error' => 'errorState']); $event->expects($this->any())->method('getAttributes')->willReturn($attributes); $this->state->expects($this->any())->method('getName')->willReturn('name'); $this->state->expects($this->any())->method('getFlags')->willReturn([]); $this->state->expects($this->any())->method('getEvents')->willReturn([$event]); $this->state->expects($this->any())->method('getAttributes')->willReturn($attributes); $this->process->expects($this->any())->method('getName')->willReturn('processName'); $renderer = new DocumentBuilder(new Stylist()); $document = $renderer->build($this->adapter); $this->assertEquals('digraph processName {dpi="75";pad="1";fontname="Courier";nodesep="1";rankdir="TD";ranksep="0.5";node[label=<name>,tooltip="",height="0.6",shape="ellipse",style="filled",color="transparent",fillcolor="#ebebeb",fontcolor="#444444"]{ state_name };edge[label=" eventName",tooltip="",dir="forward",style="solid",color="#99BB11",fontcolor="#999999"] state_name -> state_targetState;edge[label=" eventName",tooltip="",dir="forward",style="solid",color="#ee1155",fontcolor="#999999"] state_name -> state_errorState;}', (string) $document); }
/** * Update payload with new state data * * @param StateInterface $state * @param PayloadInterface $payload */ private function updatePayload(StateInterface $state, PayloadInterface $payload) { $payload->setState($state->getName()); foreach ((array) $state->getFlags() as $flag) { $payload->setFlag($flag); } }
/** * Create edge for dot notation * * @param StateInterface $state * @param EventInterface $event * @param string $nextState * @param Style $style * * @return Edge */ private function createEdge(StateInterface $state, EventInterface $event, $nextState, Style $style) { return new Edge($state->getName(), $nextState, $event->getName(), $style, $event->getAttributes()->get('comment'), $event->getTimeout()); }