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_fires_an_enabled_transition_with_three_input_places_and_two_output_places(FactoryInterface $factory, MarkingInterface $marking, PlaceInterface $placeOne, PlaceInterface $placeTwo, PlaceInterface $placeThree, PlaceInterface $placeFour, PlaceInterface $placeFive, InputArcInterface $arcOne, InputArcInterface $arcTwo, InputArcInterface $arcThree, OutputArcInterface $arcFour, OutputArcInterface $arcFive, TransitionInterface $transition, TokenInterface $token, TokenInterface $tokenOne, TokenInterface $tokenTwo, TokenInterface $tokenThree, TokenInterface $tokenFour, TokenInterface $tokenFive, TokenInterface $tokenSix, PlaceMarkingInterface $placeOneMarking, PlaceMarkingInterface $placeTwoMarking, PlaceMarkingInterface $placeThreeMarking, PlaceMarkingInterface $placeFourMarking, PlaceMarkingInterface $placeFiveMarking)
 {
     $placeOne->getOutputArcs()->willReturn(array($arcOne));
     $placeTwo->getOutputArcs()->willReturn(array($arcTwo));
     $placeThree->getOutputArcs()->willReturn(array($arcThree));
     $placeFour->getInputArcs()->willReturn(array($arcFour));
     $placeFive->getInputArcs()->willReturn(array($arcFive));
     $arcOne->getPlace()->willReturn($placeOne);
     $arcOne->getTransition()->willReturn($transition);
     $arcOne->getWeight()->willReturn(3);
     $arcTwo->getPlace()->willReturn($placeTwo);
     $arcTwo->getTransition()->willReturn($transition);
     $arcTwo->getWeight()->willReturn(2);
     $arcThree->getPlace()->willReturn($placeThree);
     $arcThree->getTransition()->willReturn($transition);
     $arcThree->getWeight()->willReturn(1);
     $arcFour->getTransition()->willReturn($transition);
     $arcFour->getPlace()->willReturn($placeFour);
     $arcFour->getWeight()->willReturn(2);
     $arcFive->getTransition()->willReturn($transition);
     $arcFive->getPlace()->willReturn($placeFive);
     $arcFive->getWeight()->willReturn(1);
     $placeOneMarking->getTokens()->willReturn(array($tokenOne, $tokenTwo, $tokenThree));
     $placeTwoMarking->getTokens()->willReturn(array($tokenFour, $tokenFive));
     $placeThreeMarking->getTokens()->willReturn(array($tokenSix));
     $marking->getPlaceMarking($placeOne->getWrappedObject())->willReturn($placeOneMarking);
     $marking->getPlaceMarking($placeTwo->getWrappedObject())->willReturn($placeTwoMarking);
     $marking->getPlaceMarking($placeThree->getWrappedObject())->willReturn($placeThreeMarking);
     $marking->getPlaceMarking($placeFour->getWrappedObject())->willReturn($placeFourMarking);
     $marking->getPlaceMarking($placeFive->getWrappedObject())->willReturn($placeFiveMarking);
     $transition->getInputArcs()->willReturn(array($arcOne, $arcTwo, $arcThree));
     $transition->getOutputArcs()->willReturn(array($arcFour, $arcFive));
     $factory->createToken()->willReturn($token);
     // Expects tokens to be removed from the input places
     $placeOneMarking->removeToken($tokenOne)->shouldBeCalled();
     $placeOneMarking->removeToken($tokenTwo)->shouldBeCalled();
     $placeOneMarking->removeToken($tokenThree)->shouldBeCalled();
     $placeTwoMarking->removeToken($tokenFour)->shouldBeCalled();
     $placeTwoMarking->removeToken($tokenFive)->shouldBeCalled();
     $placeThreeMarking->removeToken($tokenSix)->shouldBeCalled();
     // Expects tokens to be added to the output places
     $placeFourMarking->setTokens(array($token, $token))->shouldBeCalled();
     $placeFiveMarking->setTokens(array($token))->shouldBeCalled();
     $this->beConstructedWith($factory);
     $this->fire($transition, $marking);
 }