Skip to content

Commit

Permalink
Merge pull request #4770 from neos/bugfix/4769-order-nodes-by-position
Browse files Browse the repository at this point in the history
BUGFIX: Respect position when ordering nodes
  • Loading branch information
bwaidelich authored Nov 24, 2023
2 parents 4649655 + 8af009d commit 05400d6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public function findChildNodeAggregates(
): iterable {
$connection = $this->client->getConnection();

$query = $this->createChildNodeAggregateQuery();
$query = $this->createChildNodeAggregateQuery() . ' ORDER BY ch.position';

$parameters = [
'parentNodeAggregateId' => $parentNodeAggregateId->value,
Expand All @@ -344,7 +344,8 @@ public function findChildNodeAggregatesByName(
$connection = $this->client->getConnection();

$query = $this->createChildNodeAggregateQuery() . '
AND ch.name = :relationName';
AND ch.name = :relationName
ORDER BY ch.position';

$parameters = [
'contentStreamId' => $contentStreamId->value,
Expand All @@ -371,7 +372,8 @@ public function findTetheredChildNodeAggregates(
$connection = $this->client->getConnection();

$query = $this->createChildNodeAggregateQuery() . '
AND c.classification = :tetheredClassification';
AND c.classification = :tetheredClassification
ORDER BY ch.position';

$parameters = [
'contentStreamId' => $contentStreamId->value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ public function eventNumberIs(int $eventNumber, string $eventType, TableNode $pa
$key = $assertionTableRow['Key'];
$actualValue = Arrays::getValueByPath($actualEventPayload, $key);

if ($key === 'affectedDimensionSpacePoints') {
// Note: For dimension space points we switch to an array comparison because the order is not deterministic (@see https://github.com/neos/neos-development-collection/issues/4769)
if ($key === 'affectedDimensionSpacePoints' || $key === 'affectedOccupiedDimensionSpacePoints') {
$expected = DimensionSpacePointSet::fromJsonString($assertionTableRow['Expected']);
$actual = DimensionSpacePointSet::fromArray($actualValue);
Assert::assertTrue($expected->equals($actual), 'Actual Dimension Space Point set "' . json_encode($actualValue) . '" does not match expected Dimension Space Point set "' . $assertionTableRow['Expected'] . '"');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ public function iExecuteTheFindDescendantNodesQueryIExpectTheFollowingNodes(stri
$subgraph = $this->getCurrentSubgraph();

$actualNodeIds = array_map(static fn(Node $node) => $node->nodeAggregateId->value, iterator_to_array($subgraph->findDescendantNodes($entryNodeAggregateId, $filter)));
Assert::assertSame($expectedNodeIds, $actualNodeIds, 'findDescendantNodes returned an unexpected result');
// Note: In contrast to other similar checks, in this case we use assertEqualsCanonicalizing() instead of assertSame() because the order of descendant nodes is not completely deterministic (@see https://github.com/neos/neos-development-collection/issues/4769)
Assert::assertEqualsCanonicalizing($expectedNodeIds, $actualNodeIds, 'findDescendantNodes returned an unexpected result');
$actualCount = $subgraph->countDescendantNodes($entryNodeAggregateId, CountDescendantNodesFilter::fromFindDescendantNodesFilter($filter));
Assert::assertSame($expectedTotalCount ?? count($expectedNodeIds), $actualCount, 'countDescendantNodes returned an unexpected result');
}
Expand Down

0 comments on commit 05400d6

Please sign in to comment.