Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use TheGame\Application\Component\BuildingConstruction\Domain\Entity\Building;
use TheGame\Application\Component\BuildingConstruction\Domain\Event\BuildingConstructionHasBeenCancelledEvent;
use TheGame\Application\SharedKernel\Domain\BuildingType;
use TheGame\Application\SharedKernel\Domain\PlanetId;
use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId;
use TheGame\Application\SharedKernel\Domain\ResourcesInterface;
use TheGame\Application\SharedKernel\EventBusInterface;
use TheGame\Application\SharedKernel\Exception\InconsistentModelException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use TheGame\Application\Component\BuildingConstruction\Domain\Entity\Building;
use TheGame\Application\Component\BuildingConstruction\Domain\Event\Factory\BuildingTypeEventFactoryInterface;
use TheGame\Application\Component\BuildingConstruction\Domain\Event\ResourceStorageConstructionHasBeenFinishedEvent;
use TheGame\Application\SharedKernel\Domain\PlanetId;
use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId;
use TheGame\Application\SharedKernel\EventBusInterface;
use TheGame\Application\SharedKernel\Exception\InconsistentModelException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
use TheGame\Application\Component\BuildingConstruction\Domain\Factory\BuildingFactoryInterface;
use TheGame\Application\Component\ResourceStorage\Bridge\ResourceAvailabilityCheckerInterface;
use TheGame\Application\SharedKernel\Domain\BuildingType;
use TheGame\Application\SharedKernel\Domain\PlanetId;
use TheGame\Application\SharedKernel\Domain\ResourceId;
use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId;
use TheGame\Application\SharedKernel\Domain\EntityId\ResourceId;
use TheGame\Application\SharedKernel\Domain\ResourcesInterface;
use TheGame\Application\SharedKernel\EventBusInterface;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
use TheGame\Application\Component\BuildingConstruction\Domain\Exception\InsufficientResourcesException;
use TheGame\Application\Component\ResourceStorage\Bridge\ResourceAvailabilityCheckerInterface;
use TheGame\Application\SharedKernel\Domain\BuildingType;
use TheGame\Application\SharedKernel\Domain\PlanetId;
use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId;
use TheGame\Application\SharedKernel\Domain\ResourcesInterface;
use TheGame\Application\SharedKernel\EventBusInterface;
use TheGame\Application\SharedKernel\Exception\InconsistentModelException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
use TheGame\Application\Component\BuildingConstruction\Domain\Exception\BuildingIsNotUpgradingYetException;
use TheGame\Application\Component\BuildingConstruction\Domain\Exception\BuildingTimeHasNotPassedException;
use TheGame\Application\SharedKernel\Domain\BuildingType;
use TheGame\Application\SharedKernel\Domain\PlanetId;
use TheGame\Application\SharedKernel\Domain\PlanetIdInterface;
use TheGame\Application\SharedKernel\Domain\ResourceId;
use TheGame\Application\SharedKernel\Domain\ResourceIdInterface;
use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId;
use TheGame\Application\SharedKernel\Domain\EntityId\PlanetIdInterface;
use TheGame\Application\SharedKernel\Domain\EntityId\ResourceId;
use TheGame\Application\SharedKernel\Domain\EntityId\ResourceIdInterface;

final class BuildingSpec extends ObjectBehavior
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
use TheGame\Application\Component\BuildingConstruction\Domain\Event\ResourceStorageConstructionHasBeenFinishedEvent;
use TheGame\Application\Component\BuildingConstruction\Domain\Event\ShipyardConstructionHasBeenFinishedEvent;
use TheGame\Application\SharedKernel\Domain\BuildingType;
use TheGame\Application\SharedKernel\Domain\PlanetId;
use TheGame\Application\SharedKernel\Domain\ResourceId;
use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId;
use TheGame\Application\SharedKernel\Domain\EntityId\ResourceId;

final class BuildingTypeEventFactorySpec extends ObjectBehavior
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
use PhpSpec\ObjectBehavior;
use TheGame\Application\Component\BuildingConstruction\Domain\BuildingIdInterface;
use TheGame\Application\SharedKernel\Domain\BuildingType;
use TheGame\Application\SharedKernel\Domain\PlanetIdInterface;
use TheGame\Application\SharedKernel\Domain\ResourceIdInterface;
use TheGame\Application\SharedKernel\Domain\EntityId\PlanetIdInterface;
use TheGame\Application\SharedKernel\Domain\EntityId\ResourceIdInterface;
use TheGame\Application\SharedKernel\UuidGeneratorInterface;

final class BuildingFactorySpec extends ObjectBehavior
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ final class ReturnJourneysCommandSpec extends ObjectBehavior
{
public function let(): void
{
$userId = "0cfe1c65-2cac-4138-92bd-fac68027c39b";
$this->beConstructedWith($userId);
$playerId = "0cfe1c65-2cac-4138-92bd-fac68027c39b";
$this->beConstructedWith($playerId);
}

public function it_has_user_id(): void
public function it_has_player_id(): void
{
$this->getUserId()->shouldReturn("0cfe1c65-2cac-4138-92bd-fac68027c39b");
$this->getPlayerId()->shouldReturn("0cfe1c65-2cac-4138-92bd-fac68027c39b");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ final class TargetJourneysCommandSpec extends ObjectBehavior
{
public function let(): void
{
$userId = "c20f9c5c-09eb-4eba-bf7a-899507264f6a";
$this->beConstructedWith($userId);
$playerId = "c20f9c5c-09eb-4eba-bf7a-899507264f6a";
$this->beConstructedWith($playerId);
}

public function it_has_user_id(): void
public function it_has_player_id(): void
{
$this->getUserId()->shouldReturn("c20f9c5c-09eb-4eba-bf7a-899507264f6a");
$this->getPlayerId()->shouldReturn("c20f9c5c-09eb-4eba-bf7a-899507264f6a");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
use TheGame\Application\Component\FleetJourney\Domain\Event\FleetHasReachedJourneyReturnPointEvent;
use TheGame\Application\Component\FleetJourney\Domain\FleetId;
use TheGame\Application\Component\FleetJourney\FleetRepositoryInterface;
use TheGame\Application\SharedKernel\Domain\EntityId\PlayerId;
use TheGame\Application\SharedKernel\Domain\GalaxyPoint;
use TheGame\Application\SharedKernel\Domain\UserId;
use TheGame\Application\SharedKernel\EventBusInterface;

final class ReturnJourneysCommandHandlerSpec extends ObjectBehavior
Expand All @@ -30,9 +30,9 @@ public function it_returns_journey_of_two_fleets(
Fleet $fleet1,
Fleet $fleet2,
): void {
$userId = "8e807726-4a48-489e-9706-16061705bb6a";
$playerId = "8e807726-4a48-489e-9706-16061705bb6a";

$fleetRepository->findFlyingBackFromJourneyForUser(new UserId($userId))
$fleetRepository->findFlyingBackFromJourneyForPlayer(new PlayerId($playerId))
->willReturn([
$fleet1->getWrappedObject(),
$fleet2->getWrappedObject(),
Expand Down Expand Up @@ -60,7 +60,7 @@ public function it_returns_journey_of_two_fleets(
$eventBus->dispatch(Argument::type(FleetHasReachedJourneyReturnPointEvent::class))
->shouldBeCalledTimes(2);

$this->__invoke(new ReturnJourneysCommand($userId));
$this->__invoke(new ReturnJourneysCommand($playerId));
}

public function it_skips_fleet_when_it_has_not_returned_from_journey(
Expand All @@ -69,9 +69,9 @@ public function it_skips_fleet_when_it_has_not_returned_from_journey(
Fleet $fleet1,
Fleet $fleet2,
): void {
$userId = "8e807726-4a48-489e-9706-16061705bb6a";
$playerId = "8e807726-4a48-489e-9706-16061705bb6a";

$fleetRepository->findFlyingBackFromJourneyForUser(new UserId($userId))
$fleetRepository->findFlyingBackFromJourneyForPlayer(new PlayerId($playerId))
->willReturn([
$fleet1->getWrappedObject(),
$fleet2->getWrappedObject(),
Expand All @@ -91,21 +91,21 @@ public function it_skips_fleet_when_it_has_not_returned_from_journey(
$eventBus->dispatch(Argument::type(FleetHasReachedJourneyReturnPointEvent::class))
->shouldBeCalledTimes(1);

$this->__invoke(new ReturnJourneysCommand($userId));
$this->__invoke(new ReturnJourneysCommand($playerId));
}

public function it_does_nothing_when_no_returning_fleet_found(
FleetRepositoryInterface $fleetRepository,
EventBusInterface $eventBus,
): void {
$userId = "8e807726-4a48-489e-9706-16061705bb6a";
$playerId = "8e807726-4a48-489e-9706-16061705bb6a";

$fleetRepository->findFlyingBackFromJourneyForUser(new UserId($userId))
$fleetRepository->findFlyingBackFromJourneyForPlayer(new PlayerId($playerId))
->willReturn([]);

$eventBus->dispatch(Argument::type(FleetHasReachedJourneyReturnPointEvent::class))
->shouldNotBeCalled();

$this->__invoke(new ReturnJourneysCommand($userId));
$this->__invoke(new ReturnJourneysCommand($playerId));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
use TheGame\Application\Component\FleetJourney\Domain\Exception\JourneyMissionIsNotEligibleException;
use TheGame\Application\Component\FleetJourney\Domain\Factory\JourneyFactoryInterface;
use TheGame\Application\Component\FleetJourney\Domain\FleetIdInterface;
use TheGame\Application\Component\FleetJourney\Domain\MissionType;
use TheGame\Application\Component\FleetJourney\FleetResolverInterface;
use TheGame\Application\Component\Galaxy\Bridge\NavigatorInterface;
use TheGame\Application\SharedKernel\Domain\EntityId\PlanetId;
use TheGame\Application\SharedKernel\Domain\GalaxyPointInterface;
use TheGame\Application\SharedKernel\Domain\PlanetId;
use TheGame\Application\SharedKernel\Domain\FleetMissionType;
use TheGame\Application\SharedKernel\Domain\ResourcesInterface;
use TheGame\Application\SharedKernel\EventBusInterface;

Expand Down Expand Up @@ -91,7 +91,7 @@ public function it_starts_journey(

$journeyFactory->createJourney(
$fleetId,
MissionType::Transport,
FleetMissionType::Transport,
$startGalaxyPoint,
$targetGalaxyPointStub,
$journeyDuration,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
use TheGame\Application\Component\FleetJourney\Domain\Entity\Fleet;
use TheGame\Application\Component\FleetJourney\Domain\Event\FleetHasReachedJourneyTargetPointEvent;
use TheGame\Application\Component\FleetJourney\Domain\FleetId;
use TheGame\Application\Component\FleetJourney\Domain\MissionType;
use TheGame\Application\Component\FleetJourney\FleetRepositoryInterface;
use TheGame\Application\SharedKernel\Domain\EntityId\PlayerId;
use TheGame\Application\SharedKernel\Domain\GalaxyPoint;
use TheGame\Application\SharedKernel\Domain\UserId;
use TheGame\Application\SharedKernel\Domain\FleetMissionType;
use TheGame\Application\SharedKernel\EventBusInterface;

final class TargetJourneysCommandHandlerSpec extends ObjectBehavior
Expand All @@ -31,9 +31,9 @@ public function it_reaches_journey_target_for_two_fleets(
Fleet $fleet1,
Fleet $fleet2,
): void {
$userId = "f313d56d-1a27-46fb-a1a5-1fb4b8a1e88b";
$playerId = "f313d56d-1a27-46fb-a1a5-1fb4b8a1e88b";

$fleetRepository->findInJourneyForUser(new UserId($userId))
$fleetRepository->findInJourneyForPlayer(new PlayerId($playerId))
->willReturn([
$fleet1->getWrappedObject(),
$fleet2->getWrappedObject(),
Expand All @@ -42,7 +42,7 @@ public function it_reaches_journey_target_for_two_fleets(
$fleet1->tryToReachJourneyTargetPoint()->shouldBeCalledOnce();
$fleet1->didReachJourneyTargetPoint()->willReturn(true);
$fleet1->getId()->willReturn(new FleetId("dfdd04c6-9243-4775-834c-ad702003ef6b"));
$fleet1->getJourneyMissionType()->willReturn(MissionType::Transport);
$fleet1->getJourneyMissionType()->willReturn(FleetMissionType::Transport);
$fleet1->getJourneyTargetPoint()->willReturn(new GalaxyPoint(1, 2, 3));
$fleet1->getResourcesLoad()->willReturn([
"8de65203-ad4c-4ce7-bced-cfeda9107b5d" => 300,
Expand All @@ -52,14 +52,14 @@ public function it_reaches_journey_target_for_two_fleets(
$fleet2->tryToReachJourneyTargetPoint()->shouldBeCalledOnce();
$fleet2->didReachJourneyTargetPoint()->willReturn(true);
$fleet2->getId()->willReturn(new FleetId("6da596f9-f66a-4912-9603-06f538621695"));
$fleet2->getJourneyMissionType()->willReturn(MissionType::Stationing);
$fleet2->getJourneyMissionType()->willReturn(FleetMissionType::Stationing);
$fleet2->getJourneyTargetPoint()->willReturn(new GalaxyPoint(2, 3, 4));
$fleet2->getResourcesLoad()->willReturn([]);

$eventBus->dispatch(Argument::type(FleetHasReachedJourneyTargetPointEvent::class))
->shouldBeCalledTimes(2);

$command = new TargetJourneysCommand($userId);
$command = new TargetJourneysCommand($playerId);
$this->__invoke($command);
}

Expand All @@ -69,9 +69,9 @@ public function it_skips_one_fleet_which_didnt_reach_target_point(
Fleet $fleet1,
Fleet $fleet2,
): void {
$userId = "f313d56d-1a27-46fb-a1a5-1fb4b8a1e88b";
$playerId = "f313d56d-1a27-46fb-a1a5-1fb4b8a1e88b";

$fleetRepository->findInJourneyForUser(new UserId($userId))
$fleetRepository->findInJourneyForPlayer(new PlayerId($playerId))
->willReturn([
$fleet1->getWrappedObject(),
$fleet2->getWrappedObject(),
Expand All @@ -80,7 +80,7 @@ public function it_skips_one_fleet_which_didnt_reach_target_point(
$fleet1->tryToReachJourneyTargetPoint()->shouldBeCalledOnce();
$fleet1->didReachJourneyTargetPoint()->willReturn(true);
$fleet1->getId()->willReturn(new FleetId("dfdd04c6-9243-4775-834c-ad702003ef6b"));
$fleet1->getJourneyMissionType()->willReturn(MissionType::Transport);
$fleet1->getJourneyMissionType()->willReturn(FleetMissionType::Transport);
$fleet1->getJourneyTargetPoint()->willReturn(new GalaxyPoint(1, 2, 3));
$fleet1->getResourcesLoad()->willReturn([
"8de65203-ad4c-4ce7-bced-cfeda9107b5d" => 300,
Expand All @@ -93,23 +93,23 @@ public function it_skips_one_fleet_which_didnt_reach_target_point(
$eventBus->dispatch(Argument::type(FleetHasReachedJourneyTargetPointEvent::class))
->shouldBeCalledOnce();

$command = new TargetJourneysCommand($userId);
$command = new TargetJourneysCommand($playerId);
$this->__invoke($command);
}

public function it_does_nothing_when_no_fleet_reaching_target_found(
FleetRepositoryInterface $fleetRepository,
EventBusInterface $eventBus,
): void {
$userId = "f313d56d-1a27-46fb-a1a5-1fb4b8a1e88b";
$playerId = "f313d56d-1a27-46fb-a1a5-1fb4b8a1e88b";

$fleetRepository->findInJourneyForUser(new UserId($userId))
$fleetRepository->findInJourneyForPlayer(new PlayerId($playerId))
->willReturn([]);

$eventBus->dispatch(Argument::type(FleetHasReachedJourneyTargetPointEvent::class))
->shouldNotBeCalled();

$command = new TargetJourneysCommand($userId);
$command = new TargetJourneysCommand($playerId);
$this->__invoke($command);
}
}
Loading