/**
  * Create document from Process
  *
  * @param Process $process
  *
  * @return Document
  */
 public static function fromProcess(Process $process) : Document
 {
     $document = new Document($process->name());
     foreach ($process->states() as $state) {
         $document->addNode(new Node($state->name()));
         foreach ($state->events() as $event) {
             $transitions = array_filter(['target' => $event->targetState(), 'error' => $event->errorState()]);
             foreach ($transitions as $type => $target) {
                 switch ($type) {
                     case 'target':
                         $document->addEdge(Edge::targetTransition($state->name(), $target, $event->name()));
                         break;
                     case 'error':
                         $document->addEdge(Edge::errorTransition($state->name(), $target, $event->name()));
                         break;
                     default:
                         $document->addEdge(new Edge($state->name(), $target, $event->name()));
                 }
             }
         }
     }
     return $document;
 }
 public function testCreateForErrorTransition()
 {
     $result = (string) Edge::errorTransition('fromNode', 'toNode', 'eventName');
     $this->assertEquals('edge[label=" eventName",color="#FF2200"] node_fromNode -> node_toNode;', $result);
 }