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#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 neos#4988)
  • Loading branch information
mhsdesign committed May 17, 2024
1 parent 81dffe9 commit 93310d8
Show file tree
Hide file tree
Showing 181 changed files with 60 additions and 1,181 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ public function __construct()
self::bootstrapFlow();
$this->contentRepositoryRegistry = $this->getObject(ContentRepositoryRegistry::class);

$this->setupCRTestSuiteTrait();
$this->setupDbalGraphAdapterIntegrityViolationTrait();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
namespace Neos\ContentGraph\DoctrineDbalAdapter\Tests\Behavior\Features\Bootstrap;

use Behat\Gherkin\Node\TableNode;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Exception\InvalidArgumentException;
use Neos\ContentGraph\DoctrineDbalAdapter\ContentGraphTableNames;
Expand All @@ -41,7 +42,7 @@ trait ProjectionIntegrityViolationDetectionTrait
{
use CRTestSuiteRuntimeVariables;

private DoctrineDbalClient $dbalClient;
private Connection $dbal;

protected Result $lastIntegrityViolationDetectionResult;

Expand All @@ -62,7 +63,7 @@ private function tableNames(): ContentGraphTableNames

public function setupDbalGraphAdapterIntegrityViolationTrait()
{
$this->dbalClient = $this->getObject(DoctrineDbalClient::class);
$this->dbal = $this->getObject(Connection::class);
}

/**
Expand All @@ -80,7 +81,7 @@ public function iRemoveTheFollowingSubtreeTag(TableNode $payloadTable): void
if (!$subtreeTags->contain($subtreeTagToRemove)) {
throw new \RuntimeException(sprintf('Failed to remove subtree tag "%s" because that tag is not set', $subtreeTagToRemove->value), 1708618267);
}
$this->dbalClient->getConnection()->update(
$this->dbal->update(
$this->tableNames()->hierarchyRelation(),
[
'subtreetags' => json_encode($subtreeTags->without($subtreeTagToRemove), JSON_THROW_ON_ERROR | JSON_FORCE_OBJECT),
Expand All @@ -97,7 +98,7 @@ public function iAddTheFollowingHierarchyRelation(TableNode $payloadTable): void
{
$dataset = $this->transformPayloadTableToDataset($payloadTable);
$record = $this->transformDatasetToHierarchyRelationRecord($dataset);
$this->dbalClient->getConnection()->insert(
$this->dbal->insert(
$this->tableNames()->hierarchyRelation(),
$record
);
Expand All @@ -114,7 +115,7 @@ public function iChangeTheFollowingHierarchyRelationsDimensionSpacePointHash(Tab
$record = $this->transformDatasetToHierarchyRelationRecord($dataset);
unset($record['position']);

$this->dbalClient->getConnection()->update(
$this->dbal->update(
$this->tableNames()->hierarchyRelation(),
[
'dimensionspacepointhash' => $dataset['newDimensionSpacePointHash']
Expand Down Expand Up @@ -145,7 +146,7 @@ public function iChangeTheFollowingNodesName(TableNode $payloadTable): void
]
)->fetchOne();

$this->dbalClient->getConnection()->update(
$this->dbal->update(
$this->tableNames()->node(),
[
'name' => $dataset['newName']
Expand All @@ -171,7 +172,7 @@ public function iSetTheFollowingPosition(TableNode $payloadTable): void
'childnodeanchor' => $this->findRelationAnchorPointByDataset($dataset)
];

$this->dbalClient->getConnection()->update(
$this->dbal->update(
$this->tableNames()->hierarchyRelation(),
[
'position' => $dataset['newPosition']
Expand All @@ -189,7 +190,7 @@ public function iDetachTheFollowingReferenceRelationFromItsSource(TableNode $pay
{
$dataset = $this->transformPayloadTableToDataset($payloadTable);

$this->dbalClient->getConnection()->update(
$this->dbal->update(
$this->tableNames()->referenceRelation(),
[
'nodeanchorpoint' => 7777777
Expand All @@ -207,7 +208,7 @@ public function iSetTheFollowingReferencePosition(TableNode $payloadTable): void
{
$dataset = $this->transformPayloadTableToDataset($payloadTable);

$this->dbalClient->getConnection()->update(
$this->dbal->update(
$this->tableNames()->referenceRelation(),
[
'position' => $dataset['newPosition']
Expand Down Expand Up @@ -277,7 +278,7 @@ private function findHierarchyRelationByIds(
DimensionSpacePoint $dimensionSpacePoint,
NodeAggregateId $nodeAggregateId
): array {
$nodeRecord = $this->dbalClient->getConnection()->executeQuery(
$nodeRecord = $this->dbal->executeQuery(
'SELECT h.*
FROM ' . $this->tableNames()->node() . ' n
INNER JOIN ' . $this->tableNames()->hierarchyRelation() . ' h
Expand Down Expand Up @@ -313,7 +314,7 @@ private function transformPayloadTableToDataset(TableNode $payloadTable): array
*/
public function iRunIntegrityViolationDetection(): void
{
$projectionIntegrityViolationDetectionRunner = $this->getContentRepositoryService(new DoctrineDbalProjectionIntegrityViolationDetectionRunnerFactory($this->dbalClient));
$projectionIntegrityViolationDetectionRunner = $this->getContentRepositoryService(new DoctrineDbalProjectionIntegrityViolationDetectionRunnerFactory($this->getObject(DoctrineDbalClient::class)));
$this->lastIntegrityViolationDetectionResult = $projectionIntegrityViolationDetectionRunner->run();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Feature: Run integrity violation detection regarding hierarchy relations and nod
| workspaceTitle | "Live" |
| workspaceDescription | "The live workspace" |
| newContentStreamId | "cs-identifier" |
And the graph projection is fully up to date
And I am in workspace "live" and dimension space point {}
And the command CreateRootNodeAggregateWithNode is executed with payload:
| Key | Value |
Expand All @@ -35,7 +34,6 @@ Feature: Run integrity violation detection regarding hierarchy relations and nod
| parentNodeAggregateId | "lady-eleonode-rootford" |
| nodeName | "child-document" |
| nodeAggregateClassification | "regular" |
And the graph projection is fully up to date

Scenario: Detach a hierarchy relation from its parent
When I add the following hierarchy relation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Feature: Run integrity violation detection regarding parent relations
| workspaceTitle | "Live" |
| workspaceDescription | "The live workspace" |
| newContentStreamId | "cs-identifier" |
And the graph projection is fully up to date
And I am in workspace "live" and dimension space point {"language":"de"}
And the command CreateRootNodeAggregateWithNode is executed with payload:
| Key | Value |
Expand Down Expand Up @@ -55,7 +54,6 @@ Feature: Run integrity violation detection regarding parent relations
| parentNodeAggregateId | "sir-david-nodenborough" |
| nodeName | "child-document" |
| nodeAggregateClassification | "regular" |
And the graph projection is fully up to date

Scenario: Set a second parent for Nody McNodeface
And I add the following hierarchy relation:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ Feature: Run integrity violation detection regarding reference relations
| workspaceTitle | "Live" |
| workspaceDescription | "The live workspace" |
| newContentStreamId | "cs-identifier" |
And the graph projection is fully up to date
And I am in workspace "live" and dimension space point {"language":"de"}
And the command CreateRootNodeAggregateWithNode is executed with payload:
| Key | Value |
Expand All @@ -46,7 +45,6 @@ Feature: Run integrity violation detection regarding reference relations
| coveredDimensionSpacePoints | [{"language":"de"},{"language":"gsw"},{"language":"fr"}] |
| parentNodeAggregateId | "lady-eleonode-rootford" |
| nodeAggregateClassification | "regular" |
And the graph projection is fully up to date

Scenario: Detach a reference relation from its source
When the command SetNodeReferences is executed with payload:
Expand All @@ -55,7 +53,6 @@ Feature: Run integrity violation detection regarding reference relations
| sourceNodeAggregateId | "source-nodandaise" |
| referenceName | "referenceProperty" |
| references | [{"target": "anthony-destinode"}] |
And the graph projection is fully up to date
And I detach the following reference relation from its source:
| Key | Value |
| contentStreamId | "cs-identifier" |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ Feature: Run integrity violation detection regarding sibling sorting
| workspaceTitle | "Live" |
| workspaceDescription | "The live workspace" |
| newContentStreamId | "cs-identifier" |
And the graph projection is fully up to date
And I am in workspace "live" and dimension space point {"language":"de"}
And the command CreateRootNodeAggregateWithNode is executed with payload:
| Key | Value |
| nodeAggregateId | "lady-eleonode-rootford" |
| nodeTypeName | "Neos.ContentRepository:Root" |
And the graph projection is fully up to date

Scenario: Create two siblings and set the sorting to the same value
When the event NodeAggregateWithNodeWasCreated was published with payload:
Expand All @@ -46,7 +44,6 @@ Feature: Run integrity violation detection regarding sibling sorting
| coveredDimensionSpacePoints | [{"language":"de"},{"language":"gsw"},{"language":"fr"}] |
| parentNodeAggregateId | "lady-eleonode-rootford" |
| nodeAggregateClassification | "regular" |
And the graph projection is fully up to date
And I set the following position:
| Key | Value |
| contentStreamId | "cs-identifier" |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,11 @@ Feature: Run integrity violation detection regarding subtree tag inheritance
| workspaceTitle | "Live" |
| workspaceDescription | "The live workspace" |
| newContentStreamId | "cs-identifier" |
And the graph projection is fully up to date
And I am in workspace "live" and dimension space point {"language":"de"}
And the command CreateRootNodeAggregateWithNode is executed with payload:
| Key | Value |
| nodeAggregateId | "lady-eleonode-rootford" |
| nodeTypeName | "Neos.ContentRepository:Root" |
And the graph projection is fully up to date

Scenario: Create nodes, disable the topmost and remove some restriction edges manually
When the event NodeAggregateWithNodeWasCreated was published with payload:
Expand Down Expand Up @@ -64,7 +62,6 @@ Feature: Run integrity violation detection regarding subtree tag inheritance
| nodeAggregateId | "sir-david-nodenborough" |
| affectedDimensionSpacePoints | [{"language":"de"},{"language":"gsw"},{"language":"fr"}] |
| tag | "disabled" |
And the graph projection is fully up to date
And I remove the following subtree tag:
| Key | Value |
| contentStreamId | "cs-identifier" |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ Feature: Run projection integrity violation detection regarding naming of tether
| workspaceTitle | "Live" |
| workspaceDescription | "The live workspace" |
| newContentStreamId | "cs-identifier" |
And the graph projection is fully up to date
And I am in workspace "live" and dimension space point {"language":"de"}
And the command CreateRootNodeAggregateWithNode is executed with payload:
| Key | Value |
Expand All @@ -35,7 +34,6 @@ Feature: Run projection integrity violation detection regarding naming of tether
| parentNodeAggregateId | "lady-eleonode-rootford" |
| nodeName | "document" |
| nodeAggregateClassification | "regular" |
And the graph projection is fully up to date

Scenario: Remove tethered node's name
When the event NodeAggregateWithNodeWasCreated was published with payload:
Expand All @@ -48,7 +46,6 @@ Feature: Run projection integrity violation detection regarding naming of tether
| 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 node's name:
| Key | Value |
| contentStreamId | "cs-identifier" |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ Feature: Sibling positions are properly resolved
| workspaceTitle | "Live" |
| workspaceDescription | "The live workspace" |
| newContentStreamId | "cs-identifier" |
And the graph projection is fully up to date
And I am in workspace "live" and dimension space point {"example": "general"}
And the command CreateRootNodeAggregateWithNode is executed with payload:
| Key | Value |
Expand Down Expand Up @@ -50,49 +49,41 @@ Feature: Sibling positions are properly resolved
| Key | Value |
| nodeAggregateId | "lady-nodette-nodington-ii" |
| newSucceedingSiblingNodeAggregateId | "lady-nodette-nodington-x" |
And the graph projection is fully up to date
# distance iii to x: 32
And the command MoveNodeAggregate is executed with payload:
| Key | Value |
| nodeAggregateId | "lady-nodette-nodington-iii" |
| newSucceedingSiblingNodeAggregateId | "lady-nodette-nodington-x" |
And the graph projection is fully up to date
# distance iv to x: 16
And the command MoveNodeAggregate is executed with payload:
| Key | Value |
| nodeAggregateId | "lady-nodette-nodington-iv" |
| newSucceedingSiblingNodeAggregateId | "lady-nodette-nodington-x" |
And the graph projection is fully up to date
# distance v to x: 8
And the command MoveNodeAggregate is executed with payload:
| Key | Value |
| nodeAggregateId | "lady-nodette-nodington-v" |
| newSucceedingSiblingNodeAggregateId | "lady-nodette-nodington-x" |
And the graph projection is fully up to date
# distance vi to x: 4
And the command MoveNodeAggregate is executed with payload:
| Key | Value |
| nodeAggregateId | "lady-nodette-nodington-vi" |
| newSucceedingSiblingNodeAggregateId | "lady-nodette-nodington-x" |
And the graph projection is fully up to date
# distance vii to x: 2
And the command MoveNodeAggregate is executed with payload:
| Key | Value |
| nodeAggregateId | "lady-nodette-nodington-vii" |
| newSucceedingSiblingNodeAggregateId | "lady-nodette-nodington-x" |
And the graph projection is fully up to date
# distance viii to x: 1 -> reorder -> 128
And the command MoveNodeAggregate is executed with payload:
| Key | Value |
| nodeAggregateId | "lady-nodette-nodington-viii" |
| newSucceedingSiblingNodeAggregateId | "lady-nodette-nodington-x" |
And the graph projection is fully up to date
# distance ix to x: 64 after reorder
And the command MoveNodeAggregate is executed with payload:
| Key | Value |
| nodeAggregateId | "lady-nodette-nodington-ix" |
| newSucceedingSiblingNodeAggregateId | "lady-nodette-nodington-x" |
And the graph projection is fully up to date

Then I expect node aggregate identifier "lady-eleonode-rootford" to lead to node cs-identifier;lady-eleonode-rootford;{}
And I expect this node to have the following child nodes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function preparePerformanceTestCommand(int $nodesPerLevel, int $levels):
public function testPerformanceCommand(): void
{
$time = microtime(true);
$this->performanceMeasurementService->forkContentStream()
$this->performanceMeasurementService->forkContentStream();

$timeElapsed = microtime(true) - $time;
$this->outputLine('Time: ' . $timeElapsed);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

use Behat\Behat\Context\Context as BehatContext;
use Behat\Behat\Hook\Scope\BeforeScenarioScope;
use Doctrine\DBAL\Connection;
use GuzzleHttp\Psr7\Uri;
use Neos\Behat\FlowBootstrapTrait;
use Neos\ContentGraph\DoctrineDbalAdapter\Tests\Behavior\Features\Bootstrap\ProjectionIntegrityViolationDetectionTrait;
Expand All @@ -28,7 +29,6 @@
use Neos\ContentRepository\Core\Factory\ContentRepositoryServiceFactoryInterface;
use Neos\ContentRepository\Core\Factory\ContentRepositoryServiceInterface;
use Neos\ContentRepository\Core\Feature\NodeModification\Dto\PropertyValuesToWrite;
use Neos\ContentRepository\Core\Infrastructure\DbalClientInterface;
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
use Neos\ContentRepository\Core\Tests\Behavior\Fixtures\DayOfWeek;
use Neos\ContentRepository\Core\Tests\Behavior\Fixtures\PostalAddress;
Expand Down Expand Up @@ -59,8 +59,7 @@ public function __construct()
{
self::bootstrapFlow();

$this->dbalClient = $this->getObject(DbalClientInterface::class);
$this->setupCRTestSuiteTrait();
$this->dbal = $this->getObject(Connection::class);
$this->setUpInterleavingLogger();
$this->contentRepositoryRegistry = $this->getObject(ContentRepositoryRegistry::class);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@ Feature: Create a root node aggregate
| workspaceTitle | "Live" |
| workspaceDescription | "The live workspace" |
| newContentStreamId | "cs-identifier" |
And the graph projection is fully up to date
And I am in workspace "live"
And the command CreateRootNodeAggregateWithNode is executed with payload:
| Key | Value |
| nodeAggregateId | "lady-eleonode-rootford" |
| nodeTypeName | "Neos.ContentRepository:Root" |
And the graph projection is fully up to date

Scenario: Try to create a root node aggregate in a workspace that currently does not exist:
When the command CreateRootNodeAggregateWithNode is executed with payload and exceptions are caught:
Expand Down
Loading

0 comments on commit 93310d8

Please sign in to comment.