From 60bf327d2ca6a96373f5d3f80f003d2860a9096d Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Sat, 2 Sep 2023 11:12:03 +0200 Subject: [PATCH 1/3] TASK: document and assert Node.nodeName behavior related https://github.com/neos/neos-development-collection/issues/4311 --- .../Classes/Projection/ContentGraph/Node.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/Node.php b/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/Node.php index 55f6e39a563..4bb69d0c16e 100644 --- a/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/Node.php +++ b/Neos.ContentRepository.Core/Classes/Projection/ContentGraph/Node.php @@ -60,6 +60,9 @@ private function __construct( public ?NodeName $nodeName, public Timestamps $timestamps, ) { + if ($this->classification->isTethered() && $this->nodeName === null) { + throw new \InvalidArgumentException('The NodeName must be set if the Node is tethered.', 1695118377); + } } /** From cd8408c9b40ba283dcf44f01aa743857a7aa6e4f Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Sat, 3 Feb 2024 00:07:34 +0100 Subject: [PATCH 2/3] TASK: Manipulate content graph manually for TetheredNodesAreNamed test otherwise it's basically impossible now to reproduce the state, as publishing an event will lead to the catchup's to run, which might instantiate a node: the neos.neos `GraphProjectorCatchUpHookForCacheFlushingFactor` catchUpHook would fail for example: > When the event NodeAggregateWithNodeWasCreated was published with payload: > # Features/ProjectionIntegrityViolationDetection/TetheredNodesAreNamed.feature:41 > InvalidArgumentException: The NodeName must be set if the Node is tethered. --- ...ectionIntegrityViolationDetectionTrait.php | 20 +++++++++++++++++++ .../TetheredNodesAreNamed.feature | 8 ++++++++ 2 files changed, 28 insertions(+) rename {Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features => Neos.ContentGraph.DoctrineDbalAdapter/Tests/Behavior/Features/Projection}/ProjectionIntegrityViolationDetection/TetheredNodesAreNamed.feature (86%) diff --git a/Neos.ContentGraph.DoctrineDbalAdapter/Tests/Behavior/Features/Bootstrap/ProjectionIntegrityViolationDetectionTrait.php b/Neos.ContentGraph.DoctrineDbalAdapter/Tests/Behavior/Features/Bootstrap/ProjectionIntegrityViolationDetectionTrait.php index 4aff7d34cf8..258d58d8b3f 100644 --- a/Neos.ContentGraph.DoctrineDbalAdapter/Tests/Behavior/Features/Bootstrap/ProjectionIntegrityViolationDetectionTrait.php +++ b/Neos.ContentGraph.DoctrineDbalAdapter/Tests/Behavior/Features/Bootstrap/ProjectionIntegrityViolationDetectionTrait.php @@ -150,6 +150,26 @@ public function iChangeTheFollowingHierarchyRelationsDimensionSpacePointHash(Tab ); } + /** + * @When /^I change the following hierarchy relation's name:$/ + * @param TableNode $payloadTable + * @throws DBALException + */ + public function iChangeTheFollowingHierarchyRelationsEdgeName(TableNode $payloadTable): void + { + $dataset = $this->transformPayloadTableToDataset($payloadTable); + $record = $this->transformDatasetToHierarchyRelationRecord($dataset); + unset($record['position']); + + $this->dbalClient->getConnection()->update( + $this->getTableNamePrefix() . '_hierarchyrelation', + [ + 'name' => $dataset['newName'] + ], + $record + ); + } + /** * @When /^I set the following position:$/ * @param TableNode $payloadTable diff --git a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/ProjectionIntegrityViolationDetection/TetheredNodesAreNamed.feature b/Neos.ContentGraph.DoctrineDbalAdapter/Tests/Behavior/Features/Projection/ProjectionIntegrityViolationDetection/TetheredNodesAreNamed.feature similarity index 86% rename from Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/ProjectionIntegrityViolationDetection/TetheredNodesAreNamed.feature rename to Neos.ContentGraph.DoctrineDbalAdapter/Tests/Behavior/Features/Projection/ProjectionIntegrityViolationDetection/TetheredNodesAreNamed.feature index db68d13c03e..b767c0e392e 100644 --- a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Features/ProjectionIntegrityViolationDetection/TetheredNodesAreNamed.feature +++ b/Neos.ContentGraph.DoctrineDbalAdapter/Tests/Behavior/Features/Projection/ProjectionIntegrityViolationDetection/TetheredNodesAreNamed.feature @@ -46,8 +46,16 @@ Feature: Run projection integrity violation detection regarding naming of tether | originDimensionSpacePoint | {"language":"de"} | | coveredDimensionSpacePoints | [{"language":"de"}] | | parentNodeAggregateId | "sir-david-nodenborough" | + | nodeName | "to-be-hacked-to-null" | | nodeAggregateClassification | "tethered" | And the graph projection is fully up to date + And I change the following hierarchy relation's name: + | Key | Value | + | contentStreamId | "cs-identifier" | + | dimensionSpacePoint | {"language":"de"} | + | parentNodeAggregateId | "sir-david-nodenborough" | + | childNodeAggregateId | "nodewyn-tetherton" | + | newName | null | And I run integrity violation detection Then I expect the integrity violation detection result to contain exactly 1 errors And I expect integrity violation detection result error number 1 to have code 1597923103 From 1602b8d6adb3ad6298fa486a5b780399774e3ae1 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Sat, 3 Feb 2024 00:14:36 +0100 Subject: [PATCH 3/3] TASK: Add @var types to \TestSuite\GenericCommandExecutionAndEventPublication::publishEvent ... where its impossible to infer types --- .../Bootstrap/GenericCommandExecutionAndEventPublication.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/GenericCommandExecutionAndEventPublication.php b/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/GenericCommandExecutionAndEventPublication.php index 32e5de9f0fd..df2a0c56aa1 100644 --- a/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/GenericCommandExecutionAndEventPublication.php +++ b/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/GenericCommandExecutionAndEventPublication.php @@ -15,6 +15,8 @@ namespace Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap; use Behat\Gherkin\Node\TableNode; +use Neos\ContentRepository\Core\EventStore\EventNormalizer; +use Neos\ContentRepository\Core\EventStore\EventPersister; use Neos\ContentRepository\Core\EventStore\Events; use Neos\ContentRepository\Core\EventStore\EventsToPublish; use Neos\ContentRepository\Core\Feature\NodeMove\Command\MoveNodeAggregate; @@ -136,8 +138,10 @@ protected function publishEvent(string $eventType, StreamName $streamName, array Event\EventData::fromString(json_encode($eventPayload)), Event\EventMetadata::fromArray([]) ); + /** @var EventPersister $eventPersister */ $eventPersister = (new \ReflectionClass($this->currentContentRepository))->getProperty('eventPersister') ->getValue($this->currentContentRepository); + /** @var EventNormalizer $eventPersister */ $eventNormalizer = (new \ReflectionClass($eventPersister))->getProperty('eventNormalizer') ->getValue($eventPersister); $event = $eventNormalizer->denormalize($artificiallyConstructedEvent);