Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TASK: Unify command and event dispatching in Behat tests #5361

Merged
merged 7 commits into from
Nov 12, 2024
Original file line number Diff line number Diff line change
Expand Up @@ -202,14 +202,14 @@ Feature: Create node aggregate with node
| nodeAggregateId | "lady-eleonode-rootford" |
| nodeTypeName | "Neos.ContentRepository:Root" |

Given the command CreateNodeAggregateWithNodeAndSerializedProperties is executed with payload:
Given the command CreateNodeAggregateWithNode is executed with payload:
| Key | Value |
| nodeAggregateId | "sir-david-nodenborough" |
| nodeTypeName | "Neos.ContentRepository.Testing:NodeWithoutTetheredChildNodes" |
| originDimensionSpacePoint | {} |
| parentNodeAggregateId | "lady-eleonode-rootford" |
| nodeName | "node" |
And the command CreateNodeAggregateWithNodeAndSerializedProperties is executed with payload:
And the command CreateNodeAggregateWithNode is executed with payload:
| Key | Value |
| nodeAggregateId | "sir-nodeward-nodington-iii" |
| nodeTypeName | "Neos.ContentRepository.Testing:NodeWithoutTetheredChildNodes" |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
namespace Neos\ContentRepository\Core\CommandHandler;

/**
* Common (marker) interface for all commands of the Content Repository
* Common interface for all commands of the Content Repository
*
* @internal because extra commands are no extension point
*/
interface CommandInterface
{
/**
* @param array<string,mixed> $array
*/
public static function fromArray(array $array): self;
bwaidelich marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,4 @@ interface RebasableToOtherWorkspaceInterface extends CommandInterface
public function createCopyForWorkspace(
WorkspaceName $targetWorkspaceName,
): self;

/**
* called during deserialization from metadata
* @param array<string,mixed> $array
*/
public static function fromArray(array $array): self;
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ public static function create(
return new self($workspaceName, $source, $target);
}

/**
* @param array<string,mixed> $array
*/
public static function fromArray(array $array): self
{
return new self(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint;
use Neos\ContentRepository\Core\Feature\NodeCreation\Dto\NodeAggregateIdsByNodePaths;
use Neos\ContentRepository\Core\Feature\NodeModification\Dto\PropertyValuesToWrite;
use Neos\ContentRepository\Core\Feature\NodeModification\Dto\SerializedPropertyValues;
use Neos\ContentRepository\Core\Feature\NodeReferencing\Dto\NodeReferencesToWrite;
use Neos\ContentRepository\Core\Feature\NodeReferencing\Dto\SerializedNodeReferences;
use Neos\ContentRepository\Core\NodeType\NodeTypeName;
use Neos\ContentRepository\Core\Projection\ContentGraph\ContentSubgraphInterface;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
Expand Down Expand Up @@ -76,6 +78,32 @@ public static function create(WorkspaceName $workspaceName, NodeAggregateId $nod
return new self($workspaceName, $nodeAggregateId, $nodeTypeName, $originDimensionSpacePoint, $parentNodeAggregateId, $initialPropertyValues ?: PropertyValuesToWrite::createEmpty(), $succeedingSiblingNodeAggregateId, null, NodeAggregateIdsByNodePaths::createEmpty(), $references ?: NodeReferencesToWrite::createEmpty());
}

public static function fromArray(array $array): self
{
return new self(
WorkspaceName::fromString($array['workspaceName']),
NodeAggregateId::fromString($array['nodeAggregateId']),
NodeTypeName::fromString($array['nodeTypeName']),
isset($array['originDimensionSpacePoint'])
? OriginDimensionSpacePoint::fromArray($array['originDimensionSpacePoint'])
: OriginDimensionSpacePoint::createWithoutDimensions(),
NodeAggregateId::fromString($array['parentNodeAggregateId']),
isset($array['initialPropertyValues'])
? PropertyValuesToWrite::fromArray($array['initialPropertyValues'])
: PropertyValuesToWrite::createEmpty(),
isset($array['succeedingSiblingNodeAggregateId'])
? NodeAggregateId::fromString($array['succeedingSiblingNodeAggregateId'])
: null,
isset($array['nodeName'])
? NodeName::fromString($array['nodeName'])
: null,
isset($array['tetheredDescendantNodeAggregateIds'])
? NodeAggregateIdsByNodePaths::fromArray($array['tetheredDescendantNodeAggregateIds'])
: NodeAggregateIdsByNodePaths::createEmpty(),
isset($array['references']) ? NodeReferencesToWrite::fromArray($array['references']) : NodeReferencesToWrite::createEmpty(),
);
}

public function withInitialPropertyValues(PropertyValuesToWrite $newInitialPropertyValues): self
{
return new self(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,6 @@ public static function create(WorkspaceName $workspaceName, NodeAggregateId $nod
return new self($workspaceName, $nodeAggregateId, $nodeTypeName, $originDimensionSpacePoint, $parentNodeAggregateId, $initialPropertyValues ?? SerializedPropertyValues::createEmpty(), $succeedingSiblingNodeAggregateId, null, NodeAggregateIdsByNodePaths::createEmpty(), $references ?: SerializedNodeReferences::createEmpty());
}

/**
* @param array<string,mixed> $array
*/
public static function fromArray(array $array): self
{
return new self(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ public static function create(WorkspaceName $workspaceName, NodeAggregateId $nod
return new self($workspaceName, $nodeAggregateId, $coveredDimensionSpacePoint, $nodeVariantSelectionStrategy);
}

/**
* @param array<string,mixed> $array
*/
public static function fromArray(array $array): self
{
return new self(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ public static function create(WorkspaceName $workspaceName, NodeAggregateId $nod
return new self($workspaceName, $nodeAggregateId, $coveredDimensionSpacePoint, $nodeVariantSelectionStrategy);
}

/**
* @param array<string,mixed> $array
*/
public static function fromArray(array $array): self
{
return new self(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,6 @@ public static function createFromSubgraphAndStartNode(
);
}

/**
* @param array<string,mixed> $array
*/
public static function fromArray(array $array): self
{
return new self(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,14 @@ public static function create(WorkspaceName $workspaceName, NodeAggregateId $nod
{
return new self($workspaceName, $nodeAggregateId, $originDimensionSpacePoint, $propertyValues);
}

public static function fromArray(array $array): self
{
return new self(
WorkspaceName::fromString($array['workspaceName']),
NodeAggregateId::fromString($array['nodeAggregateId']),
OriginDimensionSpacePoint::fromArray($array['originDimensionSpacePoint']),
PropertyValuesToWrite::fromArray($array['propertyValues']),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,6 @@ public static function create(
);
}

/**
* @param array<string,mixed> $array
*/
public static function fromArray(array $array): self
{
return new self(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,15 @@ public static function create(WorkspaceName $workspaceName, DimensionSpacePoint
return new self($workspaceName, $dimensionSpacePoint, $nodeAggregateId, $relationDistributionStrategy, $newParentNodeAggregateId, $newPrecedingSiblingNodeAggregateId, $newSucceedingSiblingNodeAggregateId);
}

/**
* @param array<string,mixed> $array
*/
public static function fromArray(array $array): self
{
return new self(
WorkspaceName::fromString($array['workspaceName']),
DimensionSpacePoint::fromArray($array['dimensionSpacePoint']),
NodeAggregateId::fromString($array['nodeAggregateId']),
RelationDistributionStrategy::fromString($array['relationDistributionStrategy']),
isset($array['relationDistributionStrategy'])
? RelationDistributionStrategy::from($array['relationDistributionStrategy'])
: RelationDistributionStrategy::default(),
isset($array['newParentNodeAggregateId'])
? NodeAggregateId::fromString($array['newParentNodeAggregateId'])
: null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@ enum RelationDistributionStrategy: string implements \JsonSerializable
case STRATEGY_GATHER_ALL = 'gatherAll';
case STRATEGY_GATHER_SPECIALIZATIONS = 'gatherSpecializations';

public static function fromString(?string $serialization): self
public static function default(): self
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is just temporary as we think of making this nullable or introducing and actual Default here. https://github.com/neos/neos-development-collection/pull/5314/files#diff-4a3a69f0f68fa88f95e6a757f42dee32aa9a14a34ed99433e09a6950b5be0ce1

{
return !is_null($serialization)
? self::from($serialization)
: self::STRATEGY_GATHER_ALL;
return self::STRATEGY_GATHER_ALL;
}

public function jsonSerialize(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

use Neos\ContentRepository\Core\CommandHandler\CommandInterface;
use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint;
use Neos\ContentRepository\Core\Feature\NodeModification\Dto\PropertyValuesToWrite;
use Neos\ContentRepository\Core\Feature\NodeReferencing\Dto\NodeReferencesToWrite;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepository\Core\SharedModel\Node\ReferenceName;
Expand Down Expand Up @@ -47,4 +48,14 @@ public static function create(WorkspaceName $workspaceName, NodeAggregateId $sou
{
return new self($workspaceName, $sourceNodeAggregateId, $sourceOriginDimensionSpacePoint, $references);
}

public static function fromArray(array $array): self
{
return new self(
WorkspaceName::fromString($array['workspaceName']),
NodeAggregateId::fromString($array['sourceNodeAggregateId']),
OriginDimensionSpacePoint::fromArray($array['sourceOriginDimensionSpacePoint']),
NodeReferencesToWrite::fromArray($array['references']),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ public static function create(WorkspaceName $workspaceName, NodeAggregateId $sou
return new self($workspaceName, $sourceNodeAggregateId, $sourceOriginDimensionSpacePoint, $references);
}

/**
* @param array<string,mixed> $array
*/
public static function fromArray(array $array): self
{
return new self(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,6 @@ public static function create(WorkspaceName $workspaceName, NodeAggregateId $nod
return new self($workspaceName, $nodeAggregateId, $coveredDimensionSpacePoint, $nodeVariantSelectionStrategy, null);
}

/**
* @param array<string,mixed> $array
*/
public static function fromArray(array $array): self
{
return new self(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ public static function create(WorkspaceName $workspaceName, NodeAggregateId $nod
return new self($workspaceName, $nodeAggregateId, $newNodeTypeName, $strategy, NodeAggregateIdsByNodePaths::createEmpty());
}

/**
* @param array<string,mixed> $array
*/
public static function fromArray(array $array): self
{
return new self(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ public static function create(WorkspaceName $workspaceName, NodeAggregateId $nod
return new self($workspaceName, $nodeAggregateId, $sourceOrigin, $targetOrigin);
}

/**
* @param array<string,mixed> $array
*/
public static function fromArray(array $array): self
{
return new self(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@ public function withTetheredDescendantNodeAggregateIds(NodeAggregateIdsByNodePat
);
}

/**
* @param array<string,mixed> $array
*/
public static function fromArray(array $array): self
{
return new self(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,6 @@ public static function create(WorkspaceName $workspaceName, NodeAggregateId $nod
return new self($workspaceName, $nodeAggregateId);
}

/**
* @param array<string,string> $array
*/
public static function fromArray(array $array): self
{
return new self(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ public static function create(WorkspaceName $workspaceName, NodeAggregateId $nod
return new self($workspaceName, $nodeAggregateId, $coveredDimensionSpacePoint, $nodeVariantSelectionStrategy, $tag);
}

/**
* @param array<string,mixed> $array
*/
public static function fromArray(array $array): self
{
return new self(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,6 @@ public static function create(WorkspaceName $workspaceName, NodeAggregateId $nod
return new self($workspaceName, $nodeAggregateId, $coveredDimensionSpacePoint, $nodeVariantSelectionStrategy, $tag);
}

/**
* @param array<string,mixed> $array
*/
public static function fromArray(array $array): self
{
return new self(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,12 @@ public static function create(WorkspaceName $workspaceName, ContentStreamId $new
{
return new self($workspaceName, $newContentStreamId);
}

public static function fromArray(array $array): self
{
return new self(
WorkspaceName::fromString($array['workspaceName']),
ContentStreamId::fromString($array['newContentStreamId']),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,13 @@ public static function create(WorkspaceName $workspaceName, WorkspaceName $baseW
{
return new self($workspaceName, $baseWorkspaceName, $newContentStreamId);
}

public static function fromArray(array $array): self
{
return new self(
WorkspaceName::fromString($array['workspaceName']),
WorkspaceName::fromString($array['baseWorkspaceName']),
ContentStreamId::fromString($array['newContentStreamId']),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ public static function create(WorkspaceName $workspaceName, WorkspaceName $baseW
return new self($workspaceName, $baseWorkspaceName, ContentStreamId::create());
}

public static function fromArray(array $array): self
{
return new self(
WorkspaceName::fromString($array['workspaceName']),
WorkspaceName::fromString($array['baseWorkspaceName']),
isset($array['newContentStreamId']) ? ContentStreamId::fromString($array['newContentStreamId']) : ContentStreamId::create(),
);
}

/**
* During the publish process, we create a new content stream.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Neos\ContentRepository\Core\Feature\WorkspaceModification\Command;

use Neos\ContentRepository\Core\CommandHandler\CommandInterface;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;

/**
Expand All @@ -29,4 +30,11 @@ public static function create(WorkspaceName $workspaceName): self
{
return new self($workspaceName);
}

public static function fromArray(array $array): self
{
return new self(
WorkspaceName::fromString($array['workspaceName']),
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,15 @@ public static function create(
);
}

public static function fromArray(array $array): self
{
return new self(
WorkspaceName::fromString($array['workspaceName']),
NodeIdsToPublishOrDiscard::fromArray($array['nodesToDiscard']),
isset($array['newContentStreamId']) ? ContentStreamId::fromString($array['newContentStreamId']) : ContentStreamId::create(),
);
}

/**
* Call this method if you want to run this command fully deterministically, f.e. during test cases
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ public static function create(WorkspaceName $workspaceName): self
return new self($workspaceName, ContentStreamId::create());
}

public static function fromArray(array $array): self
{
return new self(
WorkspaceName::fromString($array['workspaceName']),
isset($array['newContentStreamId']) ? ContentStreamId::fromString($array['newContentStreamId']) : ContentStreamId::create(),
);
}

/**
* Call this method if you want to run this command fully deterministically, f.e. during test cases
*/
Expand Down
Loading
Loading