function it_can_locate(ShipRepository $shipRepository, MapRepository $mapRepository, ShipCanBeLocated $shipCanBeLocated, Ship $ship, Map $map) { $shipCanBeLocated->itSatisfiedBy($map)->willReturn(true); $shipRepository->save($ship)->shouldBeCalled(); $mapRepository->save($map)->shouldBeCalled(); $this->locate($map, $ship); }
public function locate(Map $map, Ship $ship) { if (!$this->shipCanBeLocated->itSatisfiedBy($map)) { throw new RuntimeException(); } $this->mapRepository->save($map); $this->shipRepository->save($ship); }