Skip to content

Commit

Permalink
TASK: Rename fake factories to be generically used instead of just fo…
Browse files Browse the repository at this point in the history
…r gherkin/behat
  • Loading branch information
mhsdesign committed Nov 10, 2024
1 parent 9772caf commit 5582ba1
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
use Neos\ContentRepository\Core\Factory\ContentRepositoryServiceInterface;
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
use Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\CRTestSuiteTrait;
use Neos\ContentRepository\TestSuite\Fakes\GherkinPyStringNodeBasedNodeTypeManagerFactory;
use Neos\ContentRepository\TestSuite\Fakes\GherkinTableNodeBasedContentDimensionSourceFactory;
use Neos\ContentRepository\TestSuite\Fakes\FakeNodeTypeManagerFactory;
use Neos\ContentRepository\TestSuite\Fakes\FakeContentDimensionSourceFactory;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;

/**
Expand Down Expand Up @@ -52,8 +52,8 @@ public function __construct()
*/
public function resetContentRepositoryComponents(BeforeScenarioScope $scope): void
{
GherkinTableNodeBasedContentDimensionSourceFactory::reset();
GherkinPyStringNodeBasedNodeTypeManagerFactory::reset();
FakeContentDimensionSourceFactory::reset();
FakeNodeTypeManagerFactory::reset();
}

protected function getContentRepositoryService(
Expand All @@ -70,8 +70,8 @@ protected function createContentRepository(
): ContentRepository {
$this->contentRepositoryRegistry->resetFactoryInstance($contentRepositoryId);
$contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId);
GherkinTableNodeBasedContentDimensionSourceFactory::reset();
GherkinPyStringNodeBasedNodeTypeManagerFactory::reset();
FakeContentDimensionSourceFactory::reset();
FakeNodeTypeManagerFactory::reset();

return $contentRepository;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
use Doctrine\DBAL\Connection;
use Neos\ContentRepository\Core\ContentRepository;
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
use Neos\ContentRepository\TestSuite\Fakes\GherkinPyStringNodeBasedNodeTypeManagerFactory;
use Neos\ContentRepository\TestSuite\Fakes\FakeNodeTypeManagerFactory;
use Neos\ContentRepository\TestSuite\Fakes\GherkinTableNodeBasedContentDimensionSource;
use Neos\ContentRepository\TestSuite\Fakes\GherkinTableNodeBasedContentDimensionSourceFactory;
use Neos\ContentRepository\TestSuite\Fakes\FakeContentDimensionSourceFactory;
use Neos\EventStore\EventStoreInterface;
use Symfony\Component\Yaml\Yaml;

Expand Down Expand Up @@ -60,15 +60,15 @@ protected function getContentRepository(ContentRepositoryId $contentRepositoryId
*/
public function usingNoContentDimensions(): void
{
GherkinTableNodeBasedContentDimensionSourceFactory::setWithoutDimensions();
FakeContentDimensionSourceFactory::setWithoutDimensions();
}

/**
* @Given /^using the following content dimensions:$/
*/
public function usingTheFollowingContentDimensions(TableNode $contentDimensions): void
{
GherkinTableNodeBasedContentDimensionSourceFactory::setContentDimensionSource(
FakeContentDimensionSourceFactory::setContentDimensionSource(
GherkinTableNodeBasedContentDimensionSource::fromGherkinTableNode($contentDimensions)
);
}
Expand All @@ -78,7 +78,7 @@ public function usingTheFollowingContentDimensions(TableNode $contentDimensions)
*/
public function usingTheFollowingNodeTypes(PyStringNode $serializedNodeTypesConfiguration): void
{
GherkinPyStringNodeBasedNodeTypeManagerFactory::setConfiguration(Yaml::parse($serializedNodeTypesConfiguration->getRaw()) ?? []);
FakeNodeTypeManagerFactory::setConfiguration(Yaml::parse($serializedNodeTypesConfiguration->getRaw()) ?? []);
}

/**
Expand All @@ -103,8 +103,8 @@ public function iChangeTheContentDimensionsInContentRepositoryTo(string $content
} else {
$contentRepository = $this->contentRepositories[$contentRepositoryId];
// ensure that the current node types of exactly THE content repository are preserved
GherkinPyStringNodeBasedNodeTypeManagerFactory::setNodeTypeManager($contentRepository->getNodeTypeManager());
GherkinTableNodeBasedContentDimensionSourceFactory::setContentDimensionSource(
FakeNodeTypeManagerFactory::setNodeTypeManager($contentRepository->getNodeTypeManager());
FakeContentDimensionSourceFactory::setContentDimensionSource(
GherkinTableNodeBasedContentDimensionSource::fromGherkinTableNode($contentDimensions)
);
$this->contentRepositories[$contentRepositoryId] = $this->createContentRepository(ContentRepositoryId::fromString($contentRepositoryId));
Expand All @@ -126,8 +126,8 @@ public function iChangeTheNodeTypesInContentRepositoryTo(
} else {
$contentRepository = $this->contentRepositories[$contentRepositoryId];
// ensure that the current node types of exactly THE content repository are preserved
GherkinTableNodeBasedContentDimensionSourceFactory::setContentDimensionSource($contentRepository->getContentDimensionSource());
GherkinPyStringNodeBasedNodeTypeManagerFactory::setConfiguration(Yaml::parse($serializedNodeTypesConfiguration->getRaw()) ?? []);
FakeContentDimensionSourceFactory::setContentDimensionSource($contentRepository->getContentDimensionSource());
FakeNodeTypeManagerFactory::setConfiguration(Yaml::parse($serializedNodeTypesConfiguration->getRaw()) ?? []);
$this->contentRepositories[$contentRepositoryId] = $this->createContentRepository(ContentRepositoryId::fromString($contentRepositoryId));
if ($this->currentContentRepository->id->value === $contentRepositoryId) {
$this->currentContentRepository = $this->contentRepositories[$contentRepositoryId];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ Neos:
clock:
factoryObjectName: 'Neos\ContentRepository\TestSuite\Fakes\FakeClockFactory'
nodeTypeManager:
factoryObjectName: 'Neos\ContentRepository\TestSuite\Fakes\GherkinPyStringNodeBasedNodeTypeManagerFactory'
factoryObjectName: 'Neos\ContentRepository\TestSuite\Fakes\FakeNodeTypeManagerFactory'
contentDimensionSource:
factoryObjectName: 'Neos\ContentRepository\TestSuite\Fakes\GherkinTableNodeBasedContentDimensionSourceFactory'
factoryObjectName: 'Neos\ContentRepository\TestSuite\Fakes\FakeContentDimensionSourceFactory'
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
use Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\CRTestSuiteTrait;
use Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\MigrationsTrait;
use Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\StructureAdjustmentsTrait;
use Neos\ContentRepository\TestSuite\Fakes\GherkinPyStringNodeBasedNodeTypeManagerFactory;
use Neos\ContentRepository\TestSuite\Fakes\GherkinTableNodeBasedContentDimensionSourceFactory;
use Neos\ContentRepository\TestSuite\Fakes\FakeNodeTypeManagerFactory;
use Neos\ContentRepository\TestSuite\Fakes\FakeContentDimensionSourceFactory;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Configuration\ConfigurationManager;

Expand Down Expand Up @@ -106,8 +106,8 @@ public function logToRaceConditionTracker(array $payload): void
*/
public function resetContentRepositoryComponents(BeforeScenarioScope $scope): void
{
GherkinTableNodeBasedContentDimensionSourceFactory::reset();
GherkinPyStringNodeBasedNodeTypeManagerFactory::reset();
FakeContentDimensionSourceFactory::reset();
FakeNodeTypeManagerFactory::reset();
}

protected function getContentRepositoryService(
Expand Down Expand Up @@ -161,8 +161,8 @@ protected function createContentRepository(
): ContentRepository {
$this->contentRepositoryRegistry->resetFactoryInstance($contentRepositoryId);
$contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId);
GherkinTableNodeBasedContentDimensionSourceFactory::reset();
GherkinPyStringNodeBasedNodeTypeManagerFactory::reset();
FakeContentDimensionSourceFactory::reset();
FakeNodeTypeManagerFactory::reset();

return $contentRepository;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@

use Neos\ContentRepository\BehavioralTests\Tests\Parallel\AbstractParallelTestCase;
use Neos\ContentRepository\Core\ContentRepository;
use Neos\ContentRepository\Core\Dimension\ContentDimension;
use Neos\ContentRepository\Core\Dimension\ContentDimensionId;
use Neos\ContentRepository\Core\Dimension\ContentDimensionSourceInterface;
use Neos\ContentRepository\Core\DimensionSpace\DimensionSpacePoint;
use Neos\ContentRepository\Core\DimensionSpace\OriginDimensionSpacePoint;
use Neos\ContentRepository\Core\Feature\NodeCreation\Command\CreateNodeAggregateWithNode;
Expand All @@ -29,16 +26,15 @@
use Neos\ContentRepository\Core\Feature\WorkspaceCreation\Command\CreateWorkspace;
use Neos\ContentRepository\Core\Feature\WorkspaceRebase\Command\RebaseWorkspace;
use Neos\ContentRepository\Core\Feature\WorkspaceRebase\Dto\RebaseErrorHandlingStrategy;
use Neos\ContentRepository\Core\NodeType\NodeTypeManager;
use Neos\ContentRepository\Core\NodeType\NodeTypeName;
use Neos\ContentRepository\Core\Projection\ContentGraph\VisibilityConstraints;
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
use Neos\ContentRepository\Core\SharedModel\Exception\ContentStreamIsClosed;
use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId;
use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\ContentRepository\TestSuite\Fakes\GherkinPyStringNodeBasedNodeTypeManagerFactory;
use Neos\ContentRepository\TestSuite\Fakes\GherkinTableNodeBasedContentDimensionSourceFactory;
use Neos\ContentRepository\TestSuite\Fakes\FakeContentDimensionSourceFactory;
use Neos\ContentRepository\TestSuite\Fakes\FakeNodeTypeManagerFactory;
use Neos\EventStore\Exception\ConcurrencyException;
use Neos\Flow\ObjectManagement\ObjectManagerInterface;
use PHPUnit\Framework\Assert;
Expand All @@ -57,27 +53,13 @@ public function setUp(): void
{
parent::setUp();
$this->log('------ process started ------');
// todo refrain from Gherkin naming here and make fakes easier to use: https://github.com/neos/neos-development-collection/pull/5346
GherkinTableNodeBasedContentDimensionSourceFactory::$contentDimensionsToUse = new class implements ContentDimensionSourceInterface
{
public function getDimension(ContentDimensionId $dimensionId): ?ContentDimension
{
return null;
}
public function getContentDimensionsOrderedByPriority(): array
{
return [];
}
};
// todo refrain from Gherkin naming here and make fakes easier to use: https://github.com/neos/neos-development-collection/pull/5346
GherkinPyStringNodeBasedNodeTypeManagerFactory::$nodeTypesToUse = new NodeTypeManager(
fn (): array => [
'Neos.ContentRepository:Root' => [],
'Neos.ContentRepository.Testing:Document' => [
'properties' => [
'title' => [
'type' => 'string'
]
FakeContentDimensionSourceFactory::setWithoutDimensions();
FakeNodeTypeManagerFactory::setConfiguration([
'Neos.ContentRepository:Root' => [],
'Neos.ContentRepository.Testing:Document' => [
'properties' => [
'title' => [
'type' => 'string'
]
]
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
use Neos\ContentRepository\Core\Factory\ContentRepositoryServiceInterface;
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
use Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\CRTestSuiteTrait;
use Neos\ContentRepository\TestSuite\Fakes\GherkinPyStringNodeBasedNodeTypeManagerFactory;
use Neos\ContentRepository\TestSuite\Fakes\GherkinTableNodeBasedContentDimensionSourceFactory;
use Neos\ContentRepository\TestSuite\Fakes\FakeNodeTypeManagerFactory;
use Neos\ContentRepository\TestSuite\Fakes\FakeContentDimensionSourceFactory;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;

/**
Expand Down Expand Up @@ -52,8 +52,8 @@ public function __construct()
*/
public function resetContentRepositoryComponents(BeforeScenarioScope $scope): void
{
GherkinTableNodeBasedContentDimensionSourceFactory::reset();
GherkinPyStringNodeBasedNodeTypeManagerFactory::reset();
FakeContentDimensionSourceFactory::reset();
FakeNodeTypeManagerFactory::reset();
}

protected function getContentRepositoryService(
Expand All @@ -70,8 +70,8 @@ protected function createContentRepository(
): ContentRepository {
$this->contentRepositoryRegistry->resetFactoryInstance($contentRepositoryId);
$contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId);
GherkinTableNodeBasedContentDimensionSourceFactory::reset();
GherkinPyStringNodeBasedNodeTypeManagerFactory::reset();
FakeContentDimensionSourceFactory::reset();
FakeNodeTypeManagerFactory::reset();

return $contentRepository;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
use Neos\ContentRepository\LegacyNodeMigration\NodeDataToEventsProcessor;
use Neos\ContentRepository\LegacyNodeMigration\RootNodeTypeMapping;
use Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\CRTestSuiteTrait;
use Neos\ContentRepository\TestSuite\Fakes\GherkinPyStringNodeBasedNodeTypeManagerFactory;
use Neos\ContentRepository\TestSuite\Fakes\GherkinTableNodeBasedContentDimensionSourceFactory;
use Neos\ContentRepository\TestSuite\Fakes\FakeNodeTypeManagerFactory;
use Neos\ContentRepository\TestSuite\Fakes\FakeContentDimensionSourceFactory;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Property\PropertyMapper;
use Neos\Flow\ResourceManagement\PersistentResource;
Expand Down Expand Up @@ -425,8 +425,8 @@ protected function createContentRepository(
): ContentRepository {
$this->contentRepositoryRegistry->resetFactoryInstance($contentRepositoryId);
$contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId);
GherkinTableNodeBasedContentDimensionSourceFactory::reset();
GherkinPyStringNodeBasedNodeTypeManagerFactory::reset();
FakeContentDimensionSourceFactory::reset();
FakeNodeTypeManagerFactory::reset();

return $contentRepository;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
use Neos\ContentRepositoryRegistry\Factory\ContentDimensionSource\ContentDimensionSourceFactoryInterface;

class GherkinTableNodeBasedContentDimensionSourceFactory implements ContentDimensionSourceFactoryInterface
/**
* Fake factory for testing. Note that the factory MUST be initialised BEFORE the content repository is fetched.
* Any changes after initialing a cr are lost UNLESS the content repository is rebuild.
*/
class FakeContentDimensionSourceFactory implements ContentDimensionSourceFactoryInterface
{
private static ?ContentDimensionSourceInterface $contentDimensionSource = null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
use Neos\ContentRepositoryRegistry\Factory\NodeTypeManager\NodeTypeManagerFactoryInterface;

/**
* Factory for node type managers from gherkin py strings
* Fake factory for testing. Note that the factory MUST be initialised BEFORE the content repository is fetched.
* Any changes after initialing a cr are lost UNLESS the content repository is rebuild.
*/
final class GherkinPyStringNodeBasedNodeTypeManagerFactory implements NodeTypeManagerFactoryInterface
final class FakeNodeTypeManagerFactory implements NodeTypeManagerFactoryInterface
{
private static ?NodeTypeManager $nodeTypeManager = null;

Expand Down
12 changes: 6 additions & 6 deletions Neos.Neos/Tests/Behavior/Features/Bootstrap/FeatureContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
use Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\CRTestSuiteTrait;
use Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\MigrationsTrait;
use Neos\ContentRepository\TestSuite\Fakes\GherkinPyStringNodeBasedNodeTypeManagerFactory;
use Neos\ContentRepository\TestSuite\Fakes\GherkinTableNodeBasedContentDimensionSourceFactory;
use Neos\ContentRepository\TestSuite\Fakes\FakeNodeTypeManagerFactory;
use Neos\ContentRepository\TestSuite\Fakes\FakeContentDimensionSourceFactory;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\Flow\Persistence\PersistenceManagerInterface;
use Neos\Flow\Utility\Environment;
Expand Down Expand Up @@ -73,8 +73,8 @@ public function __construct()
*/
public function resetContentRepositoryComponents(): void
{
GherkinTableNodeBasedContentDimensionSourceFactory::reset();
GherkinPyStringNodeBasedNodeTypeManagerFactory::reset();
FakeContentDimensionSourceFactory::reset();
FakeNodeTypeManagerFactory::reset();
}

/**
Expand Down Expand Up @@ -106,8 +106,8 @@ protected function createContentRepository(
): ContentRepository {
$this->contentRepositoryRegistry->resetFactoryInstance($contentRepositoryId);
$contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId);
GherkinTableNodeBasedContentDimensionSourceFactory::reset();
GherkinPyStringNodeBasedNodeTypeManagerFactory::reset();
FakeContentDimensionSourceFactory::reset();
FakeNodeTypeManagerFactory::reset();

return $contentRepository;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId;
use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName;
use Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\CRTestSuiteTrait;
use Neos\ContentRepository\TestSuite\Fakes\GherkinPyStringNodeBasedNodeTypeManagerFactory;
use Neos\ContentRepository\TestSuite\Fakes\GherkinTableNodeBasedContentDimensionSourceFactory;
use Neos\ContentRepository\TestSuite\Fakes\FakeNodeTypeManagerFactory;
use Neos\ContentRepository\TestSuite\Fakes\FakeContentDimensionSourceFactory;
use Neos\ContentRepositoryRegistry\ContentRepositoryRegistry;
use Neos\TimeableNodeVisibility\Service\TimeableNodeVisibilityService;
use PHPUnit\Framework\Assert;
Expand Down Expand Up @@ -91,8 +91,8 @@ protected function createContentRepository(
): ContentRepository {
$this->contentRepositoryRegistry->resetFactoryInstance($contentRepositoryId);
$contentRepository = $this->contentRepositoryRegistry->get($contentRepositoryId);
GherkinTableNodeBasedContentDimensionSourceFactory::reset();
GherkinPyStringNodeBasedNodeTypeManagerFactory::reset();
FakeContentDimensionSourceFactory::reset();
FakeNodeTypeManagerFactory::reset();

return $contentRepository;
}
Expand Down

0 comments on commit 5582ba1

Please sign in to comment.