Skip to content

Commit

Permalink
TASK: Adjusts TestSuite to be synchronous
Browse files Browse the repository at this point in the history
This change was partially ported from neos/neos-development-collection#4988

Following things have been adjusted:

- Removal of the step: The graph projection is fully up to date
  - remove lastCommandOrEventResult
- Removal of the step: The documenturipath projection is up to date
- Use injected Connection in tests instead of DoctrineDbalClient (this will be fully refactored in #4988)
  • Loading branch information
mhsdesign committed May 17, 2024
1 parent c170835 commit 43a05fb
Show file tree
Hide file tree
Showing 19 changed files with 45 additions and 53 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

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

use Neos\ContentRepository\Core\CommandHandler\CommandResult;
use Neos\ContentRepository\Core\ContentGraphFinder;
use Neos\ContentRepository\Core\ContentRepository;
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint;
Expand Down Expand Up @@ -48,8 +47,6 @@ trait CRTestSuiteRuntimeVariables

protected ?NodeAggregateId $currentRootNodeAggregateId = null;

protected ?CommandResult $lastCommandOrEventResult = null;

protected ?\Exception $lastCommandException = null;

protected ?Node $currentNode = null;
Expand Down
21 changes: 0 additions & 21 deletions Classes/Behavior/Features/Bootstrap/CRTestSuiteTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
use Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\Features\WorkspaceCreation;
use Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\Features\WorkspaceDiscarding;
use Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\Features\WorkspacePublishing;
use Neos\ContentRepositoryRegistry\Factory\ProjectionCatchUpTrigger\CatchUpTriggerWithSynchronousOption;
use Neos\EventStore\EventStoreInterface;
use PHPUnit\Framework\Assert;

Expand Down Expand Up @@ -85,13 +84,6 @@ trait CRTestSuiteTrait
use WorkspaceDiscarding;
use WorkspacePublishing;

protected function setupCRTestSuiteTrait(): void
{
if (getenv('CATCHUPTRIGGER_ENABLE_SYNCHRONOUS_OPTION')) {
CatchUpTriggerWithSynchronousOption::enableSynchronicityForSpeedingUpTesting();
}
}

/**
* @BeforeScenario
* @throws \Exception
Expand Down Expand Up @@ -139,18 +131,6 @@ protected function readPayloadTable(TableNode $payloadTable): array
return $eventPayload;
}

/**
* @When /^the graph projection is fully up to date$/
*/
public function theGraphProjectionIsFullyUpToDate(): void
{
if ($this->lastCommandOrEventResult === null) {
throw new \RuntimeException('lastCommandOrEventResult not filled; so I cannot block!');
}
$this->lastCommandOrEventResult->block();
$this->lastCommandOrEventResult = null;
}

/**
* @Then /^workspace "([^"]*)" points to another content stream than workspace "([^"]*)"$/
*/
Expand Down Expand Up @@ -304,7 +284,6 @@ public function iPruneUnusedContentStreams(): void
/** @var ContentStreamPruner $contentStreamPruner */
$contentStreamPruner = $this->getContentRepositoryService(new ContentStreamPrunerFactory());
$contentStreamPruner->prune();
$this->lastCommandOrEventResult = $contentStreamPruner->getLastCommandResult();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function theCommandCloseContentStreamIsExecutedWithPayload(TableNode $pay
$commandArguments = $this->readPayloadTable($payloadTable);
$command = CloseContentStream::create(ContentStreamId::fromString($commandArguments['contentStreamId']));

$this->lastCommandOrEventResult = $this->currentContentRepository->handle($command);
$this->currentContentRepository->handle($command);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function theCommandForkContentStreamIsExecutedWithPayload(TableNode $payl
ContentStreamId::fromString($commandArguments['sourceContentStreamId']),
);

$this->lastCommandOrEventResult = $this->currentContentRepository->handle($command);
$this->currentContentRepository->handle($command);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ public function theCommandCopyNodesRecursivelyIsExecutedCopyingTheCurrentNodeAgg
);
$command = $command->withNodeAggregateIdMapping(NodeAggregateIdMapping::fromArray($commandArguments['nodeAggregateIdMapping']));

$this->lastCommandOrEventResult = $this->currentContentRepository->handle($command);
$this->currentContentRepository->handle($command);
}
}
11 changes: 5 additions & 6 deletions Classes/Behavior/Features/Bootstrap/Features/NodeCreation.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function theCommandCreateRootNodeAggregateWithNodeIsExecutedWithPayload(T
$command = $command->withTetheredDescendantNodeAggregateIds(NodeAggregateIdsByNodePaths::fromArray($commandArguments['tetheredDescendantNodeAggregateIds']));
}

$this->lastCommandOrEventResult = $this->currentContentRepository->handle($command);
$this->currentContentRepository->handle($command);
$this->currentRootNodeAggregateId = $nodeAggregateId;
}

Expand Down Expand Up @@ -121,7 +121,7 @@ public function theCommandUpdateRootNodeAggregateDimensionsIsExecutedWithPayload
$nodeAggregateId,
);

$this->lastCommandOrEventResult = $this->currentContentRepository->handle($command);
$this->currentContentRepository->handle($command);
$this->currentRootNodeAggregateId = $nodeAggregateId;
}

Expand Down Expand Up @@ -158,7 +158,7 @@ public function theCommandCreateNodeAggregateWithNodeIsExecutedWithPayload(Table
if (isset($commandArguments['tetheredDescendantNodeAggregateIds'])) {
$command = $command->withTetheredDescendantNodeAggregateIds(NodeAggregateIdsByNodePaths::fromArray($commandArguments['tetheredDescendantNodeAggregateIds']));
}
$this->lastCommandOrEventResult = $this->currentContentRepository->handle($command);
$this->currentContentRepository->handle($command);
}

/**
Expand Down Expand Up @@ -208,8 +208,7 @@ public function theFollowingCreateNodeAggregateWithNodeCommandsAreExecuted(Table
if (isset($row['tetheredDescendantNodeAggregateIds'])) {
$command = $command->withTetheredDescendantNodeAggregateIds(NodeAggregateIdsByNodePaths::fromJsonString($row['tetheredDescendantNodeAggregateIds']));
}
$this->lastCommandOrEventResult = $this->currentContentRepository->handle($command);
$this->theGraphProjectionIsFullyUpToDate();
$this->currentContentRepository->handle($command);
}
}

Expand Down Expand Up @@ -254,7 +253,7 @@ public function theCommandCreateNodeAggregateWithNodeAndSerializedPropertiesIsEx
if (isset($commandArguments['tetheredDescendantNodeAggregateIds'])) {
$command = $command->withTetheredDescendantNodeAggregateIds(NodeAggregateIdsByNodePaths::fromArray($commandArguments['tetheredDescendantNodeAggregateIds']));
}
$this->lastCommandOrEventResult = $this->currentContentRepository->handle($command);
$this->currentContentRepository->handle($command);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public function theCommandDisableNodeAggregateIsExecutedWithPayload(TableNode $p
NodeVariantSelectionStrategy::from($commandArguments['nodeVariantSelectionStrategy']),
);

$this->lastCommandOrEventResult = $this->currentContentRepository->handle($command);
$this->currentContentRepository->handle($command);
}

/**
Expand Down Expand Up @@ -95,7 +95,7 @@ public function theCommandEnableNodeAggregateIsExecutedWithPayload(TableNode $pa
NodeVariantSelectionStrategy::from($commandArguments['nodeVariantSelectionStrategy']),
);

$this->lastCommandOrEventResult = $this->currentContentRepository->handle($command);
$this->currentContentRepository->handle($command);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function theCommandSetPropertiesIsExecutedWithPayload(TableNode $payloadT
$this->deserializeProperties($commandArguments['propertyValues']),
);

$this->lastCommandOrEventResult = $this->currentContentRepository->handle($command);
$this->currentContentRepository->handle($command);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Classes/Behavior/Features/Bootstrap/Features/NodeMove.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function theCommandMoveNodeIsExecutedWithPayload(TableNode $payloadTable)
$newSucceedingSiblingNodeAggregateId,
);

$this->lastCommandOrEventResult = $this->currentContentRepository->handle($command);
$this->currentContentRepository->handle($command);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function theCommandSetNodeReferencesIsExecutedWithPayload(TableNode $payl
$references,
);

$this->lastCommandOrEventResult = $this->currentContentRepository->handle($command);
$this->currentContentRepository->handle($command);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function theCommandRemoveNodeAggregateIsExecutedWithPayload(TableNode $pa
$command = $command->withRemovalAttachmentPoint(NodeAggregateId::fromString($commandArguments['removalAttachmentPoint']));
}

$this->lastCommandOrEventResult = $this->currentContentRepository->handle($command);
$this->currentContentRepository->handle($command);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function theCommandChangeNodeAggregateNameIsExecutedWithPayload(TableNode
NodeName::fromString($commandArguments['newNodeName']),
);

$this->lastCommandOrEventResult = $this->currentContentRepository->handle($command);
$this->currentContentRepository->handle($command);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function theCommandChangeNodeAggregateTypeIsExecutedWithPayload(TableNode
$command = $command->withTetheredDescendantNodeAggregateIds(NodeAggregateIdsByNodePaths::fromArray($commandArguments['tetheredDescendantNodeAggregateIds']));
}

$this->lastCommandOrEventResult = $this->currentContentRepository->handle($command);
$this->currentContentRepository->handle($command);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public function theCommandCreateNodeVariantIsExecutedWithPayload(TableNode $payl
OriginDimensionSpacePoint::fromArray($commandArguments['sourceOrigin']),
OriginDimensionSpacePoint::fromArray($commandArguments['targetOrigin']),
);
$this->lastCommandOrEventResult = $this->currentContentRepository->handle($command);
$this->currentContentRepository->handle($command);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function theCommandTagSubtreeIsExecutedWithPayload(TableNode $payloadTabl
SubtreeTag::fromString($commandArguments['tag']),
);

$this->lastCommandOrEventResult = $this->currentContentRepository->handle($command);
$this->currentContentRepository->handle($command);
}

/**
Expand Down Expand Up @@ -132,7 +132,7 @@ public function theCommandUntagSubtreeIsExecutedWithPayload(TableNode $payloadTa
SubtreeTag::fromString($commandArguments['tag']),
);

$this->lastCommandOrEventResult = $this->currentContentRepository->handle($command);
$this->currentContentRepository->handle($command);
}

/**
Expand Down
23 changes: 20 additions & 3 deletions Classes/Behavior/Features/Bootstrap/Features/WorkspaceCreation.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
namespace Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\Features;

use Behat\Gherkin\Node\TableNode;
use Neos\ContentRepository\Core\Feature\ContentStreamCreation\Command\CreateContentStream;
use Neos\ContentRepository\Core\Feature\ContentStreamEventStreamName;
use Neos\ContentRepository\Core\Feature\WorkspaceCreation\Command\CreateRootWorkspace;
use Neos\ContentRepository\Core\Feature\WorkspaceCreation\Command\CreateWorkspace;
Expand All @@ -39,6 +40,22 @@ abstract protected function readPayloadTable(TableNode $payloadTable): array;

abstract protected function publishEvent(string $eventType, StreamName $streamName, array $eventPayload): void;

/**
* @When /^the command CreateContentStream is executed with payload:$/
* @param TableNode $payloadTable
* @throws \Exception
*/
public function theCommandCreateContentStreamIsExecutedWithPayload(TableNode $payloadTable)
{
$commandArguments = $this->readPayloadTable($payloadTable);

$command = CreateContentStream::create(
ContentStreamId::fromString($commandArguments['contentStreamId']),
);

$this->currentContentRepository->handle($command);
}

/**
* @When /^the command CreateRootWorkspace is executed with payload:$/
* @param TableNode $payloadTable
Expand All @@ -55,7 +72,7 @@ public function theCommandCreateRootWorkspaceIsExecutedWithPayload(TableNode $pa
ContentStreamId::fromString($commandArguments['newContentStreamId'])
);

$this->lastCommandOrEventResult = $this->currentContentRepository->handle($command);
$this->currentContentRepository->handle($command);
}
/**
* @Given /^the event RootWorkspaceWasCreated was published with payload:$/
Expand Down Expand Up @@ -88,7 +105,7 @@ public function theCommandCreateWorkspaceIsExecutedWithPayload(TableNode $payloa
isset($commandArguments['workspaceOwner']) ? UserId::fromString($commandArguments['workspaceOwner']) : null
);

$this->lastCommandOrEventResult = $this->currentContentRepository->handle($command);
$this->currentContentRepository->handle($command);
}


Expand All @@ -110,7 +127,7 @@ public function theCommandRebaseWorkspaceIsExecutedWithPayload(TableNode $payloa
$command = $command->withErrorHandlingStrategy(RebaseErrorHandlingStrategy::from($commandArguments['rebaseErrorHandlingStrategy']));
}

$this->lastCommandOrEventResult = $this->currentContentRepository->handle($command);
$this->currentContentRepository->handle($command);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public function theCommandDiscardWorkspaceIsExecuted(TableNode $payloadTable): v
$command = $command->withNewContentStreamId(ContentStreamId::fromString($commandArguments['newContentStreamId']));
}

$this->lastCommandOrEventResult = $this->currentContentRepository->handle($command);
$this->currentContentRepository->handle($command);
}


Expand All @@ -67,7 +67,7 @@ public function theCommandDiscardIndividualNodesFromWorkspaceIsExecuted(TableNod
$command = $command->withNewContentStreamId(ContentStreamId::fromString($commandArguments['newContentStreamId']));
}

$this->lastCommandOrEventResult = $this->currentContentRepository->handle($command);
$this->currentContentRepository->handle($command);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function theCommandPublishIndividualNodesFromWorkspaceIsExecuted(TableNod
$command = $command->withContentStreamIdForRemainingPart(ContentStreamId::fromString($commandArguments['contentStreamIdForRemainingPart']));
}

$this->lastCommandOrEventResult = $this->currentContentRepository->handle($command);
$this->currentContentRepository->handle($command);
}

/**
Expand Down Expand Up @@ -85,7 +85,7 @@ public function theCommandPublishWorkspaceIsExecuted(TableNode $payloadTable): v
);
}

$this->lastCommandOrEventResult = $this->currentContentRepository->handle($command);
$this->currentContentRepository->handle($command);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function theCommandIsExecutedWithPayload(string $shortCommandName, TableN

$command = $commandClassName::fromArray($commandArguments);

$this->lastCommandOrEventResult = $this->currentContentRepository->handle($command);
$this->currentContentRepository->handle($command);
}

/**
Expand Down Expand Up @@ -140,7 +140,7 @@ protected function publishEvent(string $eventType, StreamName $streamName, array
->getValue($eventPersister);
$event = $eventNormalizer->denormalize($artificiallyConstructedEvent);

$this->lastCommandOrEventResult = $eventPersister->publishEvents(new EventsToPublish(
$eventPersister->publishEvents(new EventsToPublish(
$streamName,
Events::with($event),
ExpectedVersion::ANY()
Expand Down

0 comments on commit 43a05fb

Please sign in to comment.