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); }
function it_can_not_locate_ship_cause_all_ships_located(Map $map, Ship $ship, ShipRepository $shipRepository) { $countShips = 0; foreach (Ship::$ships as $shipType) { $countShips += $shipType['number']; } $shipRepository->findOneBy(['player' => 1])->willReturn($countShips); $this->itSatisfiedBy($map)->shouldReturn(false); }