Skip to content

Commit

Permalink
TASK: Improve testing api for CopyNodesRecursively and improve asse…
Browse files Browse the repository at this point in the history
…rtions made (a little)
  • Loading branch information
mhsdesign committed Nov 10, 2024
1 parent 85b6a4d commit c84e341
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ Feature: Copy nodes (without dimensions)
And using identifier "default", I define a content repository
And I am in content repository "default"
And the command CreateRootWorkspace is executed with payload:
| Key | Value |
| workspaceName | "live" |
| newContentStreamId | "cs-identifier" |
| Key | Value |
| workspaceName | "live" |
| newContentStreamId | "cs-identifier" |
And I am in workspace "live"
And the command CreateRootNodeAggregateWithNode is executed with payload:
| Key | Value |
Expand Down Expand Up @@ -56,28 +56,37 @@ Feature: Copy nodes (without dimensions)

Scenario: Copy
When I am in workspace "live" and dimension space point {}
# node to copy (currentNode): "sir-nodeward-nodington-iii"
Then I expect node aggregate identifier "sir-nodeward-nodington-iii" to lead to node cs-identifier;sir-nodeward-nodington-iii;{}
When the command CopyNodesRecursively is executed, copying the current node aggregate with payload:
When the command CopyNodesRecursively is executed with payload:
| Key | Value |
| sourceDimensionSpacePoint | {} |
| sourceNodeAggregateId | "sir-nodeward-nodington-iii" |
| targetDimensionSpacePoint | {} |
| targetParentNodeAggregateId | "nody-mc-nodeface" |
| targetNodeName | "target-nn" |
| targetSucceedingSiblingnodeAggregateId | null |
| nodeAggregateIdMapping | {"sir-nodeward-nodington-iii": "sir-nodeward-nodington-iii-copy"} |

Then I expect node aggregate identifier "sir-nodeward-nodington-iii-copy" to lead to node cs-identifier;sir-nodeward-nodington-iii-copy;{}
And I expect the node aggregate "sir-nodeward-nodington-iii-copy" to exist
And I expect this node aggregate to be classified as "regular"
And I expect this node aggregate to be named "target-nn"
And I expect this node aggregate to be of type "Neos.ContentRepository.Testing:Document"
And I expect this node aggregate to occupy dimension space points [[]]
And I expect this node aggregate to disable dimension space points []
And I expect this node aggregate to have no child node aggregates
And I expect this node aggregate to have the parent node aggregates ["nody-mc-nodeface"]

Scenario: Copy References
When I am in workspace "live" and dimension space point {}
And the command SetNodeReferences is executed with payload:
| Key | Value |
| sourceNodeAggregateId | "sir-nodeward-nodington-iii" |
| Key | Value |
| sourceNodeAggregateId | "sir-nodeward-nodington-iii" |
| references | [{"referenceName": "ref", "references": [{"target": "sir-david-nodenborough"}]}] |

Then I expect node aggregate identifier "sir-nodeward-nodington-iii" to lead to node cs-identifier;sir-nodeward-nodington-iii;{}
And the command CopyNodesRecursively is executed, copying the current node aggregate with payload:
When the command CopyNodesRecursively is executed with payload:
| Key | Value |
| sourceDimensionSpacePoint | {} |
| sourceNodeAggregateId | "sir-nodeward-nodington-iii" |
| targetDimensionSpacePoint | {} |
| targetParentNodeAggregateId | "nody-mc-nodeface" |
| targetNodeName | "target-nn" |
Expand All @@ -86,5 +95,5 @@ Feature: Copy nodes (without dimensions)

And I expect node aggregate identifier "sir-nodeward-nodington-iii-copy" to lead to node cs-identifier;sir-nodeward-nodington-iii-copy;{}
And I expect this node to have the following references:
| Name | Node | Properties |
| ref | cs-identifier;sir-david-nodenborough;{} | null |
| Name | Node | Properties |
| ref | cs-identifier;sir-david-nodenborough;{} | null |
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
namespace Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\Features;

use Behat\Gherkin\Node\TableNode;
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint;
use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint;
use Neos\ContentRepository\Core\Feature\NodeDuplication\Command\CopyNodesRecursively;
use Neos\ContentRepository\Core\Feature\NodeDuplication\Dto\NodeAggregateIdMapping;
Expand All @@ -34,30 +35,40 @@ trait NodeCopying
abstract protected function readPayloadTable(TableNode $payloadTable): array;

/**
* @When /^the command CopyNodesRecursively is executed, copying the current node aggregate with payload:$/
* @When /^the command CopyNodesRecursively is executed with payload:$/
*/
public function theCommandCopyNodesRecursivelyIsExecutedCopyingTheCurrentNodeAggregateWithPayload(TableNode $payloadTable): void
public function theCommandCopyNodesRecursivelyIsExecutedWithPayload(TableNode $payloadTable): void
{
$commandArguments = $this->readPayloadTable($payloadTable);
$subgraph = $this->currentContentRepository->getContentGraph($this->currentWorkspaceName)->getSubgraph(
$this->currentDimensionSpacePoint,

$workspaceName = isset($commandArguments['workspaceName'])
? WorkspaceName::fromString($commandArguments['workspaceName'])
: $this->currentWorkspaceName;

// "virtual" command arguments that do not exist YET
$sourceNodeAggregateId = NodeAggregateId::fromString($commandArguments['sourceNodeAggregateId']);
$sourceDimensionSpacePoint = isset($commandArguments['sourceDimensionSpacePoint'])
? DimensionSpacePoint::fromArray($commandArguments['sourceDimensionSpacePoint'])
: $this->currentDimensionSpacePoint;

$subgraphToCopy = $this->currentContentRepository->getContentGraph($workspaceName)->getSubgraph(
$sourceDimensionSpacePoint,
VisibilityConstraints::withoutRestrictions()
);
$nodeToCopy = $subgraphToCopy->findNodeById($sourceNodeAggregateId);

$targetDimensionSpacePoint = isset($commandArguments['targetDimensionSpacePoint'])
? OriginDimensionSpacePoint::fromArray($commandArguments['targetDimensionSpacePoint'])
: OriginDimensionSpacePoint::fromDimensionSpacePoint($this->currentDimensionSpacePoint);

$targetSucceedingSiblingNodeAggregateId = isset($commandArguments['targetSucceedingSiblingNodeAggregateId'])
? NodeAggregateId::fromString($commandArguments['targetSucceedingSiblingNodeAggregateId'])
: null;

$workspaceName = isset($commandArguments['workspaceName'])
? WorkspaceName::fromString($commandArguments['workspaceName'])
: $this->currentWorkspaceName;

$command = CopyNodesRecursively::createFromSubgraphAndStartNode(
$subgraph,
$subgraphToCopy,
$workspaceName,
$this->currentNode,
$nodeToCopy,
$targetDimensionSpacePoint,
NodeAggregateId::fromString($commandArguments['targetParentNodeAggregateId']),
$targetSucceedingSiblingNodeAggregateId
Expand Down

0 comments on commit c84e341

Please sign in to comment.