Skip to content

Commit

Permalink
TASK: Remove deprecated usage $node->subgraphIdentity->contentStreamId
Browse files Browse the repository at this point in the history
  • Loading branch information
mhsdesign committed Jun 28, 2024
1 parent 8052772 commit c7099ab
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

namespace Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\Helpers;

use Neos\ContentRepository\Core\ContentRepository;
use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint;
use Neos\ContentRepository\Core\Projection\ContentGraph\Node;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
Expand Down Expand Up @@ -47,10 +48,12 @@ public static function fromShorthand(string $shorthand): self
);
}

public static function fromNode(Node $node): self
public static function fromNode(Node $node, ContentRepository $contentRepository): self
{
// todo call ContentGraphFinder::forgetInstances ???
$contentStreamOfNode = $contentRepository->getContentGraph($node->workspaceName)->getContentStreamId();
return new self(
$node->subgraphIdentity->contentStreamId,
$contentStreamOfNode,
$node->aggregateId,
$node->originDimensionSpacePoint
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,6 @@ public static function fromArray(array $array): self
));
}

public static function fromNodes(Nodes $nodes): self
{
return new self(...array_map(
fn (Node $node): NodeDiscriminator => NodeDiscriminator::fromNode($node),
iterator_to_array($nodes)
));
}

public function equal(self $other): bool
{
return $this->discriminators == $other->discriminators;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public function iExpectNodeAggregateIdToLeadToNode(
$this->initializeCurrentNodeFromContentSubgraph(function (ContentSubgraphInterface $subgraph) use ($nodeAggregateId, $expectedDiscriminator) {
$currentNode = $subgraph->findNodeById($nodeAggregateId);
Assert::assertNotNull($currentNode, 'No node could be found by node aggregate id "' . $nodeAggregateId->value . '" in content subgraph "' . $this->currentDimensionSpacePoint->toJson() . '@' . $this->currentWorkspaceName->value . '"');
$actualDiscriminator = NodeDiscriminator::fromNode($currentNode);
$actualDiscriminator = NodeDiscriminator::fromNode($currentNode, $this->currentContentRepository);
Assert::assertTrue($expectedDiscriminator->equals($actualDiscriminator), 'Node discriminators do not match. Expected was ' . json_encode($expectedDiscriminator) . ' , given was ' . json_encode($actualDiscriminator));
return $currentNode;
});
Expand Down Expand Up @@ -147,7 +147,7 @@ public function iExpectPathToLeadToNode(string $serializedNodePath, string $seri
$this->initializeCurrentNodeFromContentSubgraph(function (ContentSubgraphInterface $subgraph) use ($nodePath, $expectedDiscriminator) {
$currentNode = $subgraph->findNodeByPath($nodePath, $this->getRootNodeAggregateId());
Assert::assertNotNull($currentNode, 'No node could be found by node path "' . $nodePath->serializeToString() . '" in content subgraph "' . $this->currentDimensionSpacePoint->toJson() . '@' . $this->currentWorkspaceName->value . '"');
$actualDiscriminator = NodeDiscriminator::fromNode($currentNode);
$actualDiscriminator = NodeDiscriminator::fromNode($currentNode, $this->currentContentRepository);
Assert::assertTrue($expectedDiscriminator->equals($actualDiscriminator), 'Node discriminators do not match. Expected was ' . json_encode($expectedDiscriminator) . ' , given was ' . json_encode($actualDiscriminator));
return $currentNode;
});
Expand Down Expand Up @@ -479,7 +479,7 @@ private function assertReferencesMatch(TableNode $expectedReferencesTable, Refer
$actualReferences[$index]->name->value
);
$expectedReferenceDiscriminator = NodeDiscriminator::fromShorthand($row['Node']);
$actualReferenceDiscriminator = NodeDiscriminator::fromNode($actualReferences[$index]->node);
$actualReferenceDiscriminator = NodeDiscriminator::fromNode($actualReferences[$index]->node, $this->currentContentRepository);
Assert::assertTrue(
$expectedReferenceDiscriminator->equals($actualReferenceDiscriminator),
'Reference discriminator does not match.'
Expand Down Expand Up @@ -553,12 +553,12 @@ public function iExpectThisNodeToBeTheChildOfNode(string $serializedParentNodeDi

$parent = $subgraph->findParentNode($currentNode->aggregateId);
Assert::assertInstanceOf(Node::class, $parent, 'Parent not found.');
$actualParentDiscriminator = NodeDiscriminator::fromNode($parent);
$actualParentDiscriminator = NodeDiscriminator::fromNode($parent, $this->currentContentRepository);
Assert::assertTrue($expectedParentDiscriminator->equals($actualParentDiscriminator), 'Parent discriminator does not match. Expected was ' . json_encode($expectedParentDiscriminator) . ', given was ' . json_encode($actualParentDiscriminator));

$expectedChildDiscriminator = NodeDiscriminator::fromNode($currentNode);
$expectedChildDiscriminator = NodeDiscriminator::fromNode($currentNode, $this->currentContentRepository);
$child = $subgraph->findNodeByPath($currentNode->name, $parent->aggregateId);
$actualChildDiscriminator = NodeDiscriminator::fromNode($child);
$actualChildDiscriminator = NodeDiscriminator::fromNode($child, $this->currentContentRepository);
Assert::assertTrue($expectedChildDiscriminator->equals($actualChildDiscriminator), 'Child discriminator does not match. Expected was ' . json_encode($expectedChildDiscriminator) . ', given was ' . json_encode($actualChildDiscriminator));
});
}
Expand Down Expand Up @@ -596,7 +596,10 @@ public function iExpectThisNodeToHaveTheFollowingChildNodes(TableNode $expectedC
Assert::assertTrue($expectedNodeName->equals($actualNodeName), 'ContentSubgraph::findChildNodes: Node name in index ' . $index . ' does not match. Expected: "' . $expectedNodeName->value . '" Actual: "' . $actualNodeName->value . '"');
if (isset($row['NodeDiscriminator'])) {
$expectedNodeDiscriminator = NodeDiscriminator::fromShorthand($row['NodeDiscriminator']);
$actualNodeDiscriminator = NodeDiscriminator::fromNode($actualChildNodes[$index]);
$actualNodeDiscriminator = NodeDiscriminator::fromNode(
$actualChildNodes[$index],
$this->currentContentRepository
);
Assert::assertTrue($expectedNodeDiscriminator->equals($actualNodeDiscriminator), 'ContentSubgraph::findChildNodes: Node discriminator in index ' . $index . ' does not match. Expected: ' . json_encode($expectedNodeDiscriminator->jsonSerialize()) . ' Actual: ' . json_encode($actualNodeDiscriminator));
}
}
Expand Down Expand Up @@ -635,7 +638,10 @@ public function iExpectThisNodeToHaveTheFollowingPrecedingSiblings(TableNode $ex
Assert::assertCount(count($expectedPrecedingSiblingsTable->getHash()), $actualSiblings, 'ContentSubgraph::findPrecedingSiblingNodes: Sibling count does not match');
foreach ($expectedPrecedingSiblingsTable->getHash() as $index => $row) {
$expectedNodeDiscriminator = NodeDiscriminator::fromShorthand($row['NodeDiscriminator']);
$actualNodeDiscriminator = NodeDiscriminator::fromNode($actualSiblings[$index]);
$actualNodeDiscriminator = NodeDiscriminator::fromNode(
$actualSiblings[$index],
$this->currentContentRepository
);
Assert::assertTrue($expectedNodeDiscriminator->equals($actualNodeDiscriminator), 'ContentSubgraph::findPrecedingSiblingNodes: Node discriminator in index ' . $index . ' does not match. Expected: ' . json_encode($expectedNodeDiscriminator) . ' Actual: ' . json_encode($actualNodeDiscriminator));
}
});
Expand Down Expand Up @@ -672,7 +678,10 @@ public function iExpectThisNodeToHaveTheFollowingSucceedingSiblings(TableNode $e
Assert::assertCount(count($expectedSucceedingSiblingsTable->getHash()), $actualSiblings, 'ContentSubgraph::findSucceedingSiblingNodes: Sibling count does not match');
foreach ($expectedSucceedingSiblingsTable->getHash() as $index => $row) {
$expectedNodeDiscriminator = NodeDiscriminator::fromShorthand($row['NodeDiscriminator']);
$actualNodeDiscriminator = NodeDiscriminator::fromNode($actualSiblings[$index]);
$actualNodeDiscriminator = NodeDiscriminator::fromNode(
$actualSiblings[$index],
$this->currentContentRepository
);
Assert::assertTrue($expectedNodeDiscriminator->equals($actualNodeDiscriminator), 'ContentSubgraph::findSucceedingSiblingNodes: Node discriminator in index ' . $index . ' does not match. Expected: ' . json_encode($expectedNodeDiscriminator) . ' Actual: ' . json_encode($actualNodeDiscriminator));
}
});
Expand Down

0 comments on commit c7099ab

Please sign in to comment.