function it_creates_the_output_places_marking_if_not_existing_when_firing_a_transition(FactoryInterface $factory, PlaceMarkingInterface $placeOneMarking, PlaceMarkingInterface $placeTwoMarking, MarkingInterface $marking, PlaceInterface $placeOne, PlaceInterface $placeTwo, TransitionInterface $transition, InputArcInterface $arcOne, OutputArcInterface $arcTwo, TokenInterface $token) { $placeOne->getOutputArcs()->willReturn(array($arcOne)); $arcOne->getPlace()->willReturn($placeOne); $arcOne->getTransition()->willReturn($transition); $arcOne->getWeight()->willReturn(1); $transition->getInputArcs()->willReturn(array($arcOne)); $transition->getOutputArcs()->willReturn(array($arcTwo)); $arcTwo->getTransition()->willReturn($transition); $arcTwo->getPlace()->willReturn($placeTwo); $arcTwo->getWeight()->willReturn(1); $factory->createToken()->willReturn($token)->shouldBeCalled(); $factory->createPlaceMarking()->willReturn($placeTwoMarking)->shouldBeCalled(); $placeOneMarking->getTokens()->willReturn(array($token)); $marking->getPlaceMarking($placeOne->getWrappedObject())->willReturn($placeOneMarking); $marking->getPlaceMarking($placeTwo->getWrappedObject())->willReturn(null); $placeOneMarking->removeToken($token)->shouldBeCalled(); $placeTwoMarking->setPlace($placeTwo)->shouldBeCalled(); $placeTwoMarking->setTokens(array($token))->shouldBeCalled(); $marking->addPlaceMarking($placeTwoMarking)->shouldBeCalled(); $this->beConstructedWith($factory); $this->fire($transition, $marking); }
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()); }