Skip to content

Commit

Permalink
TASK: Hack unregister Neos' `GraphProjectorCatchUpHookForCacheFlushin…
Browse files Browse the repository at this point in the history
…gFactor` 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.
  • Loading branch information
mhsdesign committed Feb 1, 2024
1 parent 59b3a13 commit 328e308
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 328e308

Please sign in to comment.