Skip to content

Commit

Permalink
TASK: Revert using Connection instead of DbalClient in test
Browse files Browse the repository at this point in the history
will be part of #5005
  • Loading branch information
mhsdesign committed May 17, 2024
1 parent bba472b commit 836781b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
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 @@ -42,7 +41,7 @@ trait ProjectionIntegrityViolationDetectionTrait
{
use CRTestSuiteRuntimeVariables;

private Connection $dbal;
private DoctrineDbalClient $dbalClient;

protected Result $lastIntegrityViolationDetectionResult;

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

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

/**
Expand All @@ -81,7 +80,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->dbal->update(
$this->dbalClient->getConnection()->update(
$this->tableNames()->hierarchyRelation(),
[
'subtreetags' => json_encode($subtreeTags->without($subtreeTagToRemove), JSON_THROW_ON_ERROR | JSON_FORCE_OBJECT),
Expand All @@ -98,7 +97,7 @@ public function iAddTheFollowingHierarchyRelation(TableNode $payloadTable): void
{
$dataset = $this->transformPayloadTableToDataset($payloadTable);
$record = $this->transformDatasetToHierarchyRelationRecord($dataset);
$this->dbal->insert(
$this->dbalClient->getConnection()->insert(
$this->tableNames()->hierarchyRelation(),
$record
);
Expand All @@ -115,7 +114,7 @@ public function iChangeTheFollowingHierarchyRelationsDimensionSpacePointHash(Tab
$record = $this->transformDatasetToHierarchyRelationRecord($dataset);
unset($record['position']);

$this->dbal->update(
$this->dbalClient->getConnection()->update(
$this->tableNames()->hierarchyRelation(),
[
'dimensionspacepointhash' => $dataset['newDimensionSpacePointHash']
Expand All @@ -133,7 +132,7 @@ public function iChangeTheFollowingNodesName(TableNode $payloadTable): void
{
$dataset = $this->transformPayloadTableToDataset($payloadTable);

$relationAnchorPoint = $this->dbal->executeQuery(
$relationAnchorPoint = $this->dbalClient->getConnection()->executeQuery(
'SELECT n.relationanchorpoint FROM ' . $this->tableNames()->node() . ' n
JOIN ' . $this->tableNames()->hierarchyRelation() . ' h ON h.childnodeanchor = n.relationanchorpoint
WHERE h.contentstreamid = :contentStreamId
Expand All @@ -146,7 +145,7 @@ public function iChangeTheFollowingNodesName(TableNode $payloadTable): void
]
)->fetchOne();

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

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

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

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function __construct()
{
self::bootstrapFlow();

$this->dbal = $this->getObject(Connection::class);
$this->dbalClient = $this->getObject(DbalClientInterface::class);
$this->setUpInterleavingLogger();
$this->contentRepositoryRegistry = $this->getObject(ContentRepositoryRegistry::class);
}
Expand Down

0 comments on commit 836781b

Please sign in to comment.