Exemplo n.º 1
0
 function it_dumps_a_petrinet_with_marking(PetrinetInterface $petrinet, PlaceInterface $placeOne, PlaceInterface $placeTwo, PlaceInterface $placeThree, PlaceInterface $placeFour, TransitionInterface $transitionOne, TransitionInterface $transitionTwo, InputArcInterface $arcOne, OutputArcInterface $arcTwo, InputArcInterface $arcThree, OutputArcInterface $arcFour, OutputArcInterface $arcFive, InputArcInterface $arcSix, MarkingInterface $marking, PlaceMarkingInterface $placeOneMarking, PlaceMarkingInterface $placeThreeMarking, TokenInterface $token)
 {
     // Petrinet
     $petrinet->getPlaces()->willReturn(array($placeOne, $placeTwo, $placeThree, $placeFour));
     $petrinet->getTransitions()->willReturn(array($transitionOne, $transitionTwo));
     $petrinet->getId()->willReturn(1);
     $placeOne->getInputArcs()->willReturn(array());
     $placeOne->getOutputArcs()->willReturn(array($arcOne));
     $placeOne->getId()->willReturn(1);
     $arcOne->getPlace()->willReturn($placeOne);
     $arcOne->getTransition()->willReturn($transitionOne);
     $arcOne->getId()->willReturn(1);
     $arcOne->getWeight()->willReturn(1);
     $transitionOne->getInputArcs()->willReturn(array($arcOne));
     $transitionOne->getOutputArcs()->willReturn(array($arcTwo, $arcFive));
     $transitionOne->getId()->willReturn(1);
     $arcTwo->getTransition()->willReturn($transitionOne);
     $arcTwo->getPlace()->willReturn($placeTwo);
     $arcTwo->getId()->willReturn(2);
     $arcTwo->getWeight()->willReturn(1);
     $placeTwo->getInputArcs()->willReturn(array($arcTwo));
     $placeTwo->getOutputArcs()->willReturn(array($arcThree));
     $placeTwo->getId()->willReturn(2);
     $arcThree->getPlace()->willReturn($placeTwo);
     $arcThree->getTransition()->willReturn($transitionTwo);
     $arcThree->getId()->willReturn(3);
     $arcThree->getWeight()->willReturn(2);
     $transitionTwo->getInputArcs()->willReturn(array($arcThree));
     $transitionTwo->getOutputArcs()->willReturn(array($arcFour));
     $transitionTwo->getId()->willReturn(2);
     $arcFour->getTransition()->willReturn($transitionTwo);
     $arcFour->getPlace()->willReturn($placeThree);
     $arcFour->getId()->willReturn(4);
     $arcFour->getWeight()->willReturn(1);
     $placeThree->getInputArcs()->willReturn(array($arcFour));
     $placeThree->getOutputArcs()->willReturn(array());
     $placeThree->getId()->willReturn(3);
     $arcFive->getTransition()->willReturn($transitionOne);
     $arcFive->getPlace()->willReturn($placeFour);
     $arcFive->getId()->willReturn(5);
     $arcFive->getWeight()->willReturn(1);
     $placeFour->getInputArcs()->willReturn(array($arcFive));
     $placeFour->getOutputArcs()->willReturn(array($arcSix));
     $placeFour->getId()->willReturn(4);
     $arcSix->getPlace()->willReturn($placeFour);
     $arcSix->getTransition()->willReturn($transitionTwo);
     $arcSix->getId()->willReturn(6);
     $arcSix->getWeight()->willReturn(1);
     // Marking
     $placeOneMarking->getTokens()->willReturn(array($token));
     $placeThreeMarking->getTokens()->willReturn(array($token, $token));
     $marking->getPlaceMarking($placeOne)->willReturn($placeOneMarking);
     $marking->getPlaceMarking($placeTwo)->willReturn(null);
     $marking->getPlaceMarking($placeThree)->willReturn($placeThreeMarking);
     $marking->getPlaceMarking($placeFour)->willReturn(null);
     $this->dump($petrinet, $marking)->shouldReturn($this->getSecondExpectedDotContent());
 }
 function it_throws_an_exception_when_firing_a_disabled_transition(FactoryInterface $factory, MarkingInterface $marking, PlaceMarkingInterface $placeMarking, TransitionInterface $transition, PlaceInterface $place, InputArcInterface $arc)
 {
     $place->getOutputArcs()->willReturn(array($arc));
     $transition->getInputArcs()->willReturn(array($arc));
     $arc->getPlace()->willReturn($place);
     $arc->getTransition()->willReturn($transition);
     $arc->getWeight()->willReturn(1);
     $placeMarking->getTokens()->willReturn(array());
     $marking->getPlaceMarking($place)->willReturn($placeMarking);
     $this->beConstructedWith($factory);
     $this->shouldThrow(new TransitionNotEnabledException('Cannot fire a disabled transition.'))->duringFire($transition, $marking);
 }