From 328e3082842345039bb14fbe78c4fced8409d8de Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Thu, 1 Feb 2024 21:46:09 +0100 Subject: [PATCH] TASK: Hack unregister Neos' `GraphProjectorCatchUpHookForCacheFlushingFactor` catchUpHook otherwise the test wont pass with our stricter validation: > When the event NodeAggregateWithNodeWasCreated was published with payload: > # Features/ProjectionIntegrityViolationDetection/TetheredNodesAreNamed.feature:41 > InvalidArgumentException: The NodeName must be set if the Node is tethered. --- .../Behavior/Bootstrap/FeatureContext.php | 19 ++++++++++++++++++- ...ricCommandExecutionAndEventPublication.php | 4 ++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Bootstrap/FeatureContext.php b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Bootstrap/FeatureContext.php index f6e7e6d0786..6d9d417bb98 100644 --- a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Bootstrap/FeatureContext.php +++ b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Bootstrap/FeatureContext.php @@ -38,6 +38,7 @@ use Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\StructureAdjustmentsTrait; use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Configuration\ConfigurationManager; +use Neos\Flow\ObjectManagement\ObjectManagerInterface; /** * Features context @@ -62,7 +63,23 @@ public function __construct() $this->dbalClient = $this->getObject(DbalClientInterface::class); $this->setupCRTestSuiteTrait(); $this->setUpInterleavingLogger(); - $this->contentRepositoryRegistry = $this->getObject(ContentRepositoryRegistry::class); + + // todo hack we shouldn't rely on the registry here in the first place, but we do, and we have to exclude the `GraphProjectorCatchUpHookForCacheFlushingFactory` + // as in the ProjectionIntegrityViolationDetection/TetheredNodesAreNamed.feature:40 test we create invalid state to be recognized (via events) + // but the catchup wont let us create invalid state + // see https://github.com/neos/neos-development-collection/pull/4469#issuecomment-1807178264 + // this _would_ be easily fixable by just hard coding all the information in here, but then we wont test or own default preset which is quite good that we do. + $contentRepositoryRegistrySettings = $this->getObject(ConfigurationManager::class) + ->getConfiguration( + ConfigurationManager::CONFIGURATION_TYPE_SETTINGS, + 'Neos.ContentRepositoryRegistry' + ); + unset($contentRepositoryRegistrySettings['presets']['default']['projections']['Neos.ContentRepository:ContentGraph']['catchUpHooks']['Neos.Neos:FlushContentCache']); + + $this->contentRepositoryRegistry = new ContentRepositoryRegistry( + $contentRepositoryRegistrySettings, + $this->getObject(ObjectManagerInterface::class) + ); } private function setUpInterleavingLogger(): void 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);