Skip to content

Commit

Permalink
TASK: Remove NodeTypeManager::overrideNodeTypes as its no longer ne…
Browse files Browse the repository at this point in the history
…eded for testing

Instead, we replace the node type manager and rebuild the content repository.
See `iChangeTheNodeTypesInContentRepositoryTo` and `FakeNodeTypeManagerFactory`
  • Loading branch information
mhsdesign committed Nov 20, 2024
1 parent 195329b commit 24ffeff
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 41 deletions.
28 changes: 0 additions & 28 deletions Neos.ContentRepository.Core/Classes/NodeType/NodeTypeManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -199,34 +199,6 @@ private function loadNodeTypes(): void
}
}

/**
* This method can be used by Functional of Behavioral Tests to completely
* override the node types known in the system.
*
* In order to reset the node type override, an empty array can be passed in.
* In this case, the system-node-types are used again.
*
* @internal
* @param array<string,mixed> $completeNodeTypeConfiguration
*/
public function overrideNodeTypes(array $completeNodeTypeConfiguration): void
{
$this->cachedNodeTypes = [];

if ($completeNodeTypeConfiguration === []) {
// as cachedNodeTypes is now empty loadNodeTypes will reload the default nodeTypes
return;
}

// the root node type must always exist
$completeNodeTypeConfiguration[NodeTypeName::ROOT_NODE_TYPE_NAME] ??= [];

foreach (array_keys($completeNodeTypeConfiguration) as $nodeTypeName) {
/** @var string $nodeTypeName */
$this->loadNodeType($nodeTypeName, $completeNodeTypeConfiguration);
}
}

/**
* Checks if the given $nodeTypeNameToCheck is allowed as a childNode of the given $tetheredNodeName.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -449,17 +449,4 @@ public function rootNodeTypeIsAlwaysPresent()
self::assertTrue($nodeTypeManager->hasNodeType(NodeTypeName::ROOT_NODE_TYPE_NAME));
self::assertInstanceOf(NodeType::class, $nodeTypeManager->getNodeType(NodeTypeName::ROOT_NODE_TYPE_NAME));
}

/**
* @test
*/
public function rootNodeTypeIsPresentAfterOverride()
{
$nodeTypeManager = NodeTypeManager::createFromArrayConfiguration(
[]
);
$nodeTypeManager->overrideNodeTypes(['Some:NewNodeType' => []]);
self::assertTrue($nodeTypeManager->hasNodeType(NodeTypeName::fromString('Some:NewNodeType')));
self::assertTrue($nodeTypeManager->hasNodeType(NodeTypeName::ROOT_NODE_TYPE_NAME));
}
}

0 comments on commit 24ffeff

Please sign in to comment.