function it_connects_a_place_to_a_transition(FactoryInterface $factory, InputArcInterface $arc, TransitionInterface $transition, PlaceInterface $place)
 {
     $factory->createPlace()->willReturn($place);
     $factory->createTransition()->willReturn($transition);
     $factory->createInputArc()->willReturn($arc);
     $arc->setPlace($place)->shouldBeCalled();
     $arc->setTransition($transition)->shouldBeCalled();
     $arc->setWeight(2)->shouldBeCalled();
     $transition->addInputArc($arc)->shouldBeCalled();
     $place->addOutputArc($arc)->shouldBeCalled();
     $this->beConstructedWith($factory);
     $this->connect($place, $transition, 2)->shouldReturn($this);
 }
 /**
  * Connects a place to a transition or vice-versa by an arc of the specified weight.
  *
  * @param NodeInterface $source
  * @param NodeInterface $target
  * @param integer       $weight
  *
  * @return $this
  *
  * @throws \InvalidArgumentException
  */
 public function connect(NodeInterface $source, NodeInterface $target, $weight = 1)
 {
     if ($source instanceof PlaceInterface && $target instanceof TransitionInterface) {
         $arc = $this->factory->createInputArc();
         $arc->setPlace($source);
         $arc->setTransition($target);
     } elseif ($source instanceof TransitionInterface && $target instanceof PlaceInterface) {
         $arc = $this->factory->createOutputArc();
         $arc->setPlace($target);
         $arc->setTransition($source);
     } else {
         throw new \InvalidArgumentException('An arc must connect a place to a transition or vice-versa.');
     }
     $arc->setWeight($weight);
     $source->addOutputArc($arc);
     $target->addInputArc($arc);
     return $this;
 }