From 1761ae9d871695caab9368f7986f754111ffe54e Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Wed, 6 Nov 2024 17:41:39 +0100 Subject: [PATCH 01/12] TASK: Move all fakes to `Neos\ContentRepository\TestSuite\Fakes` --- .../Behavior/Features/Bootstrap/FeatureContext.php | 4 ++-- .../Behavior/CRBehavioralTestsSubjectProvider.php | 4 +++- .../Behat/Settings.ContentRepositoryRegistry.yaml | 8 ++++---- .../Tests/Behavior/Bootstrap/FeatureContext.php | 4 ++-- .../WorkspaceWritingDuringRebase.php | 4 ++-- .../Behavior/Features/Bootstrap/FeatureContext.php | 4 ++-- .../Tests/Behavior/Bootstrap/FeatureContext.php | 5 ++--- .../Features/Bootstrap/CRTestSuiteRuntimeVariables.php | 5 ++--- .../Features/Bootstrap/Helpers => Fakes}/FakeClock.php | 2 +- .../Classes/Fakes}/FakeClockFactory.php | 3 +-- .../Bootstrap/Helpers => Fakes}/FakeUserIdProvider.php | 2 +- .../Classes/Fakes}/FakeUserIdProviderFactory.php | 3 +-- .../GherkinPyStringNodeBasedNodeTypeManagerFactory.php | 2 +- .../GherkinTableNodeBasedContentDimensionSource.php | 2 +- ...rkinTableNodeBasedContentDimensionSourceFactory.php | 3 +-- .../Behavior/Features/Bootstrap/FeatureContext.php | 10 +++++----- .../Tests/Behavior/Bootstrap/FeatureContext.php | 4 ++-- 17 files changed, 33 insertions(+), 36 deletions(-) rename Neos.ContentRepository.TestSuite/Classes/{Behavior/Features/Bootstrap/Helpers => Fakes}/FakeClock.php (83%) rename {Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior => Neos.ContentRepository.TestSuite/Classes/Fakes}/FakeClockFactory.php (76%) rename Neos.ContentRepository.TestSuite/Classes/{Behavior/Features/Bootstrap/Helpers => Fakes}/FakeUserIdProvider.php (86%) rename {Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior => Neos.ContentRepository.TestSuite/Classes/Fakes}/FakeUserIdProviderFactory.php (78%) rename {Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior => Neos.ContentRepository.TestSuite/Classes/Fakes}/GherkinPyStringNodeBasedNodeTypeManagerFactory.php (95%) rename Neos.ContentRepository.TestSuite/Classes/{Behavior/Features/Bootstrap/Helpers => Fakes}/GherkinTableNodeBasedContentDimensionSource.php (98%) rename {Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior => Neos.ContentRepository.TestSuite/Classes/Fakes}/GherkinTableNodeBasedContentDimensionSourceFactory.php (86%) diff --git a/Neos.ContentGraph.DoctrineDbalAdapter/Tests/Behavior/Features/Bootstrap/FeatureContext.php b/Neos.ContentGraph.DoctrineDbalAdapter/Tests/Behavior/Features/Bootstrap/FeatureContext.php index 3df89de8c1f..ced1b64b043 100644 --- a/Neos.ContentGraph.DoctrineDbalAdapter/Tests/Behavior/Features/Bootstrap/FeatureContext.php +++ b/Neos.ContentGraph.DoctrineDbalAdapter/Tests/Behavior/Features/Bootstrap/FeatureContext.php @@ -18,13 +18,13 @@ use Neos\Behat\FlowBootstrapTrait; use Neos\ContentGraph\DoctrineDbalAdapter\Tests\Behavior\Features\Bootstrap\ProjectionIntegrityViolationDetectionTrait; use Neos\ContentRepository\BehavioralTests\TestSuite\Behavior\CRBehavioralTestsSubjectProvider; -use Neos\ContentRepository\BehavioralTests\TestSuite\Behavior\GherkinPyStringNodeBasedNodeTypeManagerFactory; -use Neos\ContentRepository\BehavioralTests\TestSuite\Behavior\GherkinTableNodeBasedContentDimensionSourceFactory; use Neos\ContentRepository\Core\ContentRepository; use Neos\ContentRepository\Core\Factory\ContentRepositoryServiceFactoryInterface; 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\ContentRepositoryRegistry\ContentRepositoryRegistry; /** diff --git a/Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/CRBehavioralTestsSubjectProvider.php b/Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/CRBehavioralTestsSubjectProvider.php index 19eb183ff16..7653d709fe1 100644 --- a/Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/CRBehavioralTestsSubjectProvider.php +++ b/Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/CRBehavioralTestsSubjectProvider.php @@ -19,7 +19,9 @@ use Doctrine\DBAL\Connection; use Neos\ContentRepository\Core\ContentRepository; use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId; -use Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\Helpers\GherkinTableNodeBasedContentDimensionSource; +use Neos\ContentRepository\TestSuite\Fakes\GherkinPyStringNodeBasedNodeTypeManagerFactory; +use Neos\ContentRepository\TestSuite\Fakes\GherkinTableNodeBasedContentDimensionSource; +use Neos\ContentRepository\TestSuite\Fakes\GherkinTableNodeBasedContentDimensionSourceFactory; use Neos\EventStore\EventStoreInterface; /** diff --git a/Neos.ContentRepository.BehavioralTests/Configuration/Testing/Behat/Settings.ContentRepositoryRegistry.yaml b/Neos.ContentRepository.BehavioralTests/Configuration/Testing/Behat/Settings.ContentRepositoryRegistry.yaml index 53eafcc4977..db115d048a2 100644 --- a/Neos.ContentRepository.BehavioralTests/Configuration/Testing/Behat/Settings.ContentRepositoryRegistry.yaml +++ b/Neos.ContentRepository.BehavioralTests/Configuration/Testing/Behat/Settings.ContentRepositoryRegistry.yaml @@ -3,10 +3,10 @@ Neos: presets: default: userIdProvider: - factoryObjectName: 'Neos\ContentRepository\BehavioralTests\TestSuite\Behavior\FakeUserIdProviderFactory' + factoryObjectName: 'Neos\ContentRepository\TestSuite\Fakes\FakeUserIdProviderFactory' clock: - factoryObjectName: 'Neos\ContentRepository\BehavioralTests\TestSuite\Behavior\FakeClockFactory' + factoryObjectName: 'Neos\ContentRepository\TestSuite\Fakes\FakeClockFactory' nodeTypeManager: - factoryObjectName: 'Neos\ContentRepository\BehavioralTests\TestSuite\Behavior\GherkinPyStringNodeBasedNodeTypeManagerFactory' + factoryObjectName: 'Neos\ContentRepository\TestSuite\Fakes\GherkinPyStringNodeBasedNodeTypeManagerFactory' contentDimensionSource: - factoryObjectName: 'Neos\ContentRepository\BehavioralTests\TestSuite\Behavior\GherkinTableNodeBasedContentDimensionSourceFactory' + factoryObjectName: 'Neos\ContentRepository\TestSuite\Fakes\GherkinTableNodeBasedContentDimensionSourceFactory' diff --git a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Bootstrap/FeatureContext.php b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Bootstrap/FeatureContext.php index 682bf3c0d66..1e71fb0bc1c 100644 --- a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Bootstrap/FeatureContext.php +++ b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Bootstrap/FeatureContext.php @@ -23,8 +23,6 @@ use Neos\ContentRepository\BehavioralTests\ProjectionRaceConditionTester\Dto\TraceEntryType; use Neos\ContentRepository\BehavioralTests\ProjectionRaceConditionTester\RedisInterleavingLogger; use Neos\ContentRepository\BehavioralTests\TestSuite\Behavior\CRBehavioralTestsSubjectProvider; -use Neos\ContentRepository\BehavioralTests\TestSuite\Behavior\GherkinPyStringNodeBasedNodeTypeManagerFactory; -use Neos\ContentRepository\BehavioralTests\TestSuite\Behavior\GherkinTableNodeBasedContentDimensionSourceFactory; use Neos\ContentRepository\Core\ContentRepository; use Neos\ContentRepository\Core\Factory\ContentRepositoryServiceFactoryInterface; use Neos\ContentRepository\Core\Factory\ContentRepositoryServiceInterface; @@ -36,6 +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\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Configuration\ConfigurationManager; diff --git a/Neos.ContentRepository.BehavioralTests/Tests/Parallel/WorkspaceWritingDuringRebase/WorkspaceWritingDuringRebase.php b/Neos.ContentRepository.BehavioralTests/Tests/Parallel/WorkspaceWritingDuringRebase/WorkspaceWritingDuringRebase.php index dedd5d918da..32ffd18d9fd 100644 --- a/Neos.ContentRepository.BehavioralTests/Tests/Parallel/WorkspaceWritingDuringRebase/WorkspaceWritingDuringRebase.php +++ b/Neos.ContentRepository.BehavioralTests/Tests/Parallel/WorkspaceWritingDuringRebase/WorkspaceWritingDuringRebase.php @@ -15,8 +15,6 @@ namespace Neos\ContentRepository\BehavioralTests\Tests\Parallel\WorkspaceWritingDuringRebase; use Neos\ContentRepository\BehavioralTests\Tests\Parallel\AbstractParallelTestCase; -use Neos\ContentRepository\BehavioralTests\TestSuite\Behavior\GherkinPyStringNodeBasedNodeTypeManagerFactory; -use Neos\ContentRepository\BehavioralTests\TestSuite\Behavior\GherkinTableNodeBasedContentDimensionSourceFactory; use Neos\ContentRepository\Core\ContentRepository; use Neos\ContentRepository\Core\Dimension\ContentDimension; use Neos\ContentRepository\Core\Dimension\ContentDimensionId; @@ -39,6 +37,8 @@ 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\EventStore\Exception\ConcurrencyException; use Neos\Flow\ObjectManagement\ObjectManagerInterface; use PHPUnit\Framework\Assert; diff --git a/Neos.ContentRepository.Export/Tests/Behavior/Features/Bootstrap/FeatureContext.php b/Neos.ContentRepository.Export/Tests/Behavior/Features/Bootstrap/FeatureContext.php index 01310c7beff..6700478b68e 100644 --- a/Neos.ContentRepository.Export/Tests/Behavior/Features/Bootstrap/FeatureContext.php +++ b/Neos.ContentRepository.Export/Tests/Behavior/Features/Bootstrap/FeatureContext.php @@ -18,13 +18,13 @@ use Neos\Behat\FlowBootstrapTrait; use Neos\ContentGraph\DoctrineDbalAdapter\Tests\Behavior\Features\Bootstrap\CrImportExportTrait; use Neos\ContentRepository\BehavioralTests\TestSuite\Behavior\CRBehavioralTestsSubjectProvider; -use Neos\ContentRepository\BehavioralTests\TestSuite\Behavior\GherkinPyStringNodeBasedNodeTypeManagerFactory; -use Neos\ContentRepository\BehavioralTests\TestSuite\Behavior\GherkinTableNodeBasedContentDimensionSourceFactory; use Neos\ContentRepository\Core\ContentRepository; use Neos\ContentRepository\Core\Factory\ContentRepositoryServiceFactoryInterface; 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\ContentRepositoryRegistry\ContentRepositoryRegistry; /** diff --git a/Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/Bootstrap/FeatureContext.php b/Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/Bootstrap/FeatureContext.php index d73bf80096c..2aa7076e723 100644 --- a/Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/Bootstrap/FeatureContext.php +++ b/Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/Bootstrap/FeatureContext.php @@ -9,8 +9,6 @@ use League\Flysystem\InMemory\InMemoryFilesystemAdapter; use Neos\Behat\FlowBootstrapTrait; use Neos\ContentRepository\BehavioralTests\TestSuite\Behavior\CRBehavioralTestsSubjectProvider; -use Neos\ContentRepository\BehavioralTests\TestSuite\Behavior\GherkinPyStringNodeBasedNodeTypeManagerFactory; -use Neos\ContentRepository\BehavioralTests\TestSuite\Behavior\GherkinTableNodeBasedContentDimensionSourceFactory; use Neos\ContentRepository\Core\ContentRepository; use Neos\ContentRepository\Core\EventStore\EventNormalizer; use Neos\ContentRepository\Core\Factory\ContentRepositoryServiceFactoryDependencies; @@ -20,7 +18,6 @@ use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId; -use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName; use Neos\ContentRepository\Export\Asset\AssetExporter; use Neos\ContentRepository\Export\Asset\AssetLoaderInterface; use Neos\ContentRepository\Export\Asset\ResourceLoaderInterface; @@ -34,6 +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\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\Flow\Property\PropertyMapper; use Neos\Flow\ResourceManagement\PersistentResource; diff --git a/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/CRTestSuiteRuntimeVariables.php b/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/CRTestSuiteRuntimeVariables.php index e4505319463..eb160faa805 100644 --- a/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/CRTestSuiteRuntimeVariables.php +++ b/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/CRTestSuiteRuntimeVariables.php @@ -24,10 +24,9 @@ use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId; use Neos\ContentRepository\Core\SharedModel\Node\NodeAggregateId; use Neos\ContentRepository\Core\SharedModel\User\UserId; -use Neos\ContentRepository\Core\SharedModel\Workspace\ContentStreamId; use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName; -use Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\Helpers\FakeClock; -use Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\Helpers\FakeUserIdProvider; +use Neos\ContentRepository\TestSuite\Fakes\FakeClock; +use Neos\ContentRepository\TestSuite\Fakes\FakeUserIdProvider; /** * The node creation trait for behavioral tests diff --git a/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/Helpers/FakeClock.php b/Neos.ContentRepository.TestSuite/Classes/Fakes/FakeClock.php similarity index 83% rename from Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/Helpers/FakeClock.php rename to Neos.ContentRepository.TestSuite/Classes/Fakes/FakeClock.php index 145d3b43b51..feb4d3af2ea 100644 --- a/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/Helpers/FakeClock.php +++ b/Neos.ContentRepository.TestSuite/Classes/Fakes/FakeClock.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\Helpers; +namespace Neos\ContentRepository\TestSuite\Fakes; use DateTimeImmutable; use Psr\Clock\ClockInterface; diff --git a/Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/FakeClockFactory.php b/Neos.ContentRepository.TestSuite/Classes/Fakes/FakeClockFactory.php similarity index 76% rename from Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/FakeClockFactory.php rename to Neos.ContentRepository.TestSuite/Classes/Fakes/FakeClockFactory.php index 0ebded80a10..918cd6923d2 100644 --- a/Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/FakeClockFactory.php +++ b/Neos.ContentRepository.TestSuite/Classes/Fakes/FakeClockFactory.php @@ -2,10 +2,9 @@ declare(strict_types=1); -namespace Neos\ContentRepository\BehavioralTests\TestSuite\Behavior; +namespace Neos\ContentRepository\TestSuite\Fakes; use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId; -use Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\Helpers\FakeClock; use Neos\ContentRepositoryRegistry\Factory\Clock\ClockFactoryInterface; use Psr\Clock\ClockInterface; diff --git a/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/Helpers/FakeUserIdProvider.php b/Neos.ContentRepository.TestSuite/Classes/Fakes/FakeUserIdProvider.php similarity index 86% rename from Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/Helpers/FakeUserIdProvider.php rename to Neos.ContentRepository.TestSuite/Classes/Fakes/FakeUserIdProvider.php index 88614645a23..7211431fed8 100644 --- a/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/Helpers/FakeUserIdProvider.php +++ b/Neos.ContentRepository.TestSuite/Classes/Fakes/FakeUserIdProvider.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\Helpers; +namespace Neos\ContentRepository\TestSuite\Fakes; use Neos\ContentRepository\Core\SharedModel\User\UserId; use Neos\ContentRepository\Core\SharedModel\User\UserIdProviderInterface; diff --git a/Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/FakeUserIdProviderFactory.php b/Neos.ContentRepository.TestSuite/Classes/Fakes/FakeUserIdProviderFactory.php similarity index 78% rename from Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/FakeUserIdProviderFactory.php rename to Neos.ContentRepository.TestSuite/Classes/Fakes/FakeUserIdProviderFactory.php index 6a0a5c7a408..d565b2ee62f 100644 --- a/Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/FakeUserIdProviderFactory.php +++ b/Neos.ContentRepository.TestSuite/Classes/Fakes/FakeUserIdProviderFactory.php @@ -2,11 +2,10 @@ declare(strict_types=1); -namespace Neos\ContentRepository\BehavioralTests\TestSuite\Behavior; +namespace Neos\ContentRepository\TestSuite\Fakes; use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId; use Neos\ContentRepository\Core\SharedModel\User\UserIdProviderInterface; -use Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\Helpers\FakeUserIdProvider; use Neos\ContentRepositoryRegistry\Factory\UserIdProvider\UserIdProviderFactoryInterface; final class FakeUserIdProviderFactory implements UserIdProviderFactoryInterface diff --git a/Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/GherkinPyStringNodeBasedNodeTypeManagerFactory.php b/Neos.ContentRepository.TestSuite/Classes/Fakes/GherkinPyStringNodeBasedNodeTypeManagerFactory.php similarity index 95% rename from Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/GherkinPyStringNodeBasedNodeTypeManagerFactory.php rename to Neos.ContentRepository.TestSuite/Classes/Fakes/GherkinPyStringNodeBasedNodeTypeManagerFactory.php index 82796bf1738..bc1871eb9e5 100644 --- a/Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/GherkinPyStringNodeBasedNodeTypeManagerFactory.php +++ b/Neos.ContentRepository.TestSuite/Classes/Fakes/GherkinPyStringNodeBasedNodeTypeManagerFactory.php @@ -12,7 +12,7 @@ declare(strict_types=1); -namespace Neos\ContentRepository\BehavioralTests\TestSuite\Behavior; +namespace Neos\ContentRepository\TestSuite\Fakes; use Behat\Gherkin\Node\PyStringNode; use Neos\ContentRepository\Core\NodeType\NodeTypeManager; diff --git a/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/Helpers/GherkinTableNodeBasedContentDimensionSource.php b/Neos.ContentRepository.TestSuite/Classes/Fakes/GherkinTableNodeBasedContentDimensionSource.php similarity index 98% rename from Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/Helpers/GherkinTableNodeBasedContentDimensionSource.php rename to Neos.ContentRepository.TestSuite/Classes/Fakes/GherkinTableNodeBasedContentDimensionSource.php index 9de355dfa0a..4329ebc5090 100644 --- a/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/Helpers/GherkinTableNodeBasedContentDimensionSource.php +++ b/Neos.ContentRepository.TestSuite/Classes/Fakes/GherkinTableNodeBasedContentDimensionSource.php @@ -12,7 +12,7 @@ declare(strict_types=1); -namespace Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\Helpers; +namespace Neos\ContentRepository\TestSuite\Fakes; use Behat\Gherkin\Node\TableNode; use Neos\ContentRepository\Core\Dimension\ContentDimension; diff --git a/Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/GherkinTableNodeBasedContentDimensionSourceFactory.php b/Neos.ContentRepository.TestSuite/Classes/Fakes/GherkinTableNodeBasedContentDimensionSourceFactory.php similarity index 86% rename from Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/GherkinTableNodeBasedContentDimensionSourceFactory.php rename to Neos.ContentRepository.TestSuite/Classes/Fakes/GherkinTableNodeBasedContentDimensionSourceFactory.php index cb379048f81..16c24140be5 100644 --- a/Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/GherkinTableNodeBasedContentDimensionSourceFactory.php +++ b/Neos.ContentRepository.TestSuite/Classes/Fakes/GherkinTableNodeBasedContentDimensionSourceFactory.php @@ -2,12 +2,11 @@ declare(strict_types=1); -namespace Neos\ContentRepository\BehavioralTests\TestSuite\Behavior; +namespace Neos\ContentRepository\TestSuite\Fakes; use Behat\Gherkin\Node\TableNode; use Neos\ContentRepository\Core\Dimension\ContentDimensionSourceInterface; use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId; -use Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\Helpers\GherkinTableNodeBasedContentDimensionSource; use Neos\ContentRepositoryRegistry\Factory\ContentDimensionSource\ContentDimensionSourceFactoryInterface; class GherkinTableNodeBasedContentDimensionSourceFactory implements ContentDimensionSourceFactoryInterface diff --git a/Neos.Neos/Tests/Behavior/Features/Bootstrap/FeatureContext.php b/Neos.Neos/Tests/Behavior/Features/Bootstrap/FeatureContext.php index 9d06ce491eb..fdb2e2d9888 100644 --- a/Neos.Neos/Tests/Behavior/Features/Bootstrap/FeatureContext.php +++ b/Neos.Neos/Tests/Behavior/Features/Bootstrap/FeatureContext.php @@ -14,18 +14,18 @@ use Neos\Behat\FlowBootstrapTrait; use Neos\Behat\FlowEntitiesTrait; use Neos\ContentRepository\BehavioralTests\TestSuite\Behavior\CRBehavioralTestsSubjectProvider; -use Neos\ContentRepository\BehavioralTests\TestSuite\Behavior\GherkinPyStringNodeBasedNodeTypeManagerFactory; -use Neos\ContentRepository\BehavioralTests\TestSuite\Behavior\GherkinTableNodeBasedContentDimensionSourceFactory; use Neos\ContentRepository\Core\ContentRepository; -use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId; use Neos\ContentRepository\Core\Factory\ContentRepositoryServiceFactoryInterface; use Neos\ContentRepository\Core\Factory\ContentRepositoryServiceInterface; +use Neos\ContentRepository\Core\Feature\NodeModification\Dto\PropertyValuesToWrite; +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\ContentRepositoryRegistry\ContentRepositoryRegistry; -use Neos\Flow\Utility\Environment; -use Neos\ContentRepository\Core\Feature\NodeModification\Dto\PropertyValuesToWrite; use Neos\Flow\Persistence\PersistenceManagerInterface; +use Neos\Flow\Utility\Environment; class FeatureContext implements BehatContext { diff --git a/Neos.TimeableNodeVisibility/Tests/Behavior/Bootstrap/FeatureContext.php b/Neos.TimeableNodeVisibility/Tests/Behavior/Bootstrap/FeatureContext.php index d1b22507e62..52e906898dc 100644 --- a/Neos.TimeableNodeVisibility/Tests/Behavior/Bootstrap/FeatureContext.php +++ b/Neos.TimeableNodeVisibility/Tests/Behavior/Bootstrap/FeatureContext.php @@ -4,8 +4,6 @@ use Behat\Behat\Context\Context; use Neos\Behat\FlowBootstrapTrait; use Neos\ContentRepository\BehavioralTests\TestSuite\Behavior\CRBehavioralTestsSubjectProvider; -use Neos\ContentRepository\BehavioralTests\TestSuite\Behavior\GherkinPyStringNodeBasedNodeTypeManagerFactory; -use Neos\ContentRepository\BehavioralTests\TestSuite\Behavior\GherkinTableNodeBasedContentDimensionSourceFactory; use Neos\ContentRepository\Core\ContentRepository; use Neos\ContentRepository\Core\Factory\ContentRepositoryServiceFactoryInterface; use Neos\ContentRepository\Core\Factory\ContentRepositoryServiceInterface; @@ -14,6 +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\ContentRepositoryRegistry\ContentRepositoryRegistry; use Neos\TimeableNodeVisibility\Service\TimeableNodeVisibilityService; use PHPUnit\Framework\Assert; From 9772caf768501610877c9938065a4f60afb1f24c Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Wed, 6 Nov 2024 18:09:02 +0100 Subject: [PATCH 02/12] TASK: Remove Gherkin specific logic from static fake factories --- .../CRBehavioralTestsSubjectProvider.php | 21 +++++++---- ...yStringNodeBasedNodeTypeManagerFactory.php | 23 ++++++------ ...inTableNodeBasedContentDimensionSource.php | 3 +- ...NodeBasedContentDimensionSourceFactory.php | 35 ++++++++++++++----- 4 files changed, 55 insertions(+), 27 deletions(-) diff --git a/Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/CRBehavioralTestsSubjectProvider.php b/Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/CRBehavioralTestsSubjectProvider.php index 7653d709fe1..47ad3ca0553 100644 --- a/Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/CRBehavioralTestsSubjectProvider.php +++ b/Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/CRBehavioralTestsSubjectProvider.php @@ -23,6 +23,7 @@ use Neos\ContentRepository\TestSuite\Fakes\GherkinTableNodeBasedContentDimensionSource; use Neos\ContentRepository\TestSuite\Fakes\GherkinTableNodeBasedContentDimensionSourceFactory; use Neos\EventStore\EventStoreInterface; +use Symfony\Component\Yaml\Yaml; /** * Subject provider for behavioral tests @@ -59,7 +60,7 @@ protected function getContentRepository(ContentRepositoryId $contentRepositoryId */ public function usingNoContentDimensions(): void { - GherkinTableNodeBasedContentDimensionSourceFactory::$contentDimensionsToUse = GherkinTableNodeBasedContentDimensionSource::createEmpty(); + GherkinTableNodeBasedContentDimensionSourceFactory::setWithoutDimensions(); } /** @@ -67,7 +68,9 @@ public function usingNoContentDimensions(): void */ public function usingTheFollowingContentDimensions(TableNode $contentDimensions): void { - GherkinTableNodeBasedContentDimensionSourceFactory::initializeFromTableNode($contentDimensions); + GherkinTableNodeBasedContentDimensionSourceFactory::setContentDimensionSource( + GherkinTableNodeBasedContentDimensionSource::fromGherkinTableNode($contentDimensions) + ); } /** @@ -75,7 +78,7 @@ public function usingTheFollowingContentDimensions(TableNode $contentDimensions) */ public function usingTheFollowingNodeTypes(PyStringNode $serializedNodeTypesConfiguration): void { - GherkinPyStringNodeBasedNodeTypeManagerFactory::initializeWithPyStringNode($serializedNodeTypesConfiguration); + GherkinPyStringNodeBasedNodeTypeManagerFactory::setConfiguration(Yaml::parse($serializedNodeTypesConfiguration->getRaw()) ?? []); } /** @@ -99,8 +102,11 @@ public function iChangeTheContentDimensionsInContentRepositoryTo(string $content throw new \DomainException('undeclared content repository ' . $contentRepositoryId); } else { $contentRepository = $this->contentRepositories[$contentRepositoryId]; - GherkinPyStringNodeBasedNodeTypeManagerFactory::$nodeTypesToUse = $contentRepository->getNodeTypeManager(); - GherkinTableNodeBasedContentDimensionSourceFactory::initializeFromTableNode($contentDimensions); + // ensure that the current node types of exactly THE content repository are preserved + GherkinPyStringNodeBasedNodeTypeManagerFactory::setNodeTypeManager($contentRepository->getNodeTypeManager()); + GherkinTableNodeBasedContentDimensionSourceFactory::setContentDimensionSource( + GherkinTableNodeBasedContentDimensionSource::fromGherkinTableNode($contentDimensions) + ); $this->contentRepositories[$contentRepositoryId] = $this->createContentRepository(ContentRepositoryId::fromString($contentRepositoryId)); if ($this->currentContentRepository->id->value === $contentRepositoryId) { $this->currentContentRepository = $this->contentRepositories[$contentRepositoryId]; @@ -119,8 +125,9 @@ public function iChangeTheNodeTypesInContentRepositoryTo( throw new \DomainException('undeclared content repository ' . $contentRepositoryId); } else { $contentRepository = $this->contentRepositories[$contentRepositoryId]; - GherkinPyStringNodeBasedNodeTypeManagerFactory::initializeWithPyStringNode($serializedNodeTypesConfiguration); - GherkinTableNodeBasedContentDimensionSourceFactory::$contentDimensionsToUse = $contentRepository->getContentDimensionSource(); + // ensure that the current node types of exactly THE content repository are preserved + GherkinTableNodeBasedContentDimensionSourceFactory::setContentDimensionSource($contentRepository->getContentDimensionSource()); + GherkinPyStringNodeBasedNodeTypeManagerFactory::setConfiguration(Yaml::parse($serializedNodeTypesConfiguration->getRaw()) ?? []); $this->contentRepositories[$contentRepositoryId] = $this->createContentRepository(ContentRepositoryId::fromString($contentRepositoryId)); if ($this->currentContentRepository->id->value === $contentRepositoryId) { $this->currentContentRepository = $this->contentRepositories[$contentRepositoryId]; diff --git a/Neos.ContentRepository.TestSuite/Classes/Fakes/GherkinPyStringNodeBasedNodeTypeManagerFactory.php b/Neos.ContentRepository.TestSuite/Classes/Fakes/GherkinPyStringNodeBasedNodeTypeManagerFactory.php index bc1871eb9e5..aa17332e15b 100644 --- a/Neos.ContentRepository.TestSuite/Classes/Fakes/GherkinPyStringNodeBasedNodeTypeManagerFactory.php +++ b/Neos.ContentRepository.TestSuite/Classes/Fakes/GherkinPyStringNodeBasedNodeTypeManagerFactory.php @@ -14,39 +14,42 @@ namespace Neos\ContentRepository\TestSuite\Fakes; -use Behat\Gherkin\Node\PyStringNode; use Neos\ContentRepository\Core\NodeType\NodeTypeManager; use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId; use Neos\ContentRepositoryRegistry\Factory\NodeTypeManager\NodeTypeManagerFactoryInterface; -use Symfony\Component\Yaml\Yaml; /** * Factory for node type managers from gherkin py strings */ final class GherkinPyStringNodeBasedNodeTypeManagerFactory implements NodeTypeManagerFactoryInterface { - public static ?NodeTypeManager $nodeTypesToUse = null; + private static ?NodeTypeManager $nodeTypeManager = null; /** * @param array $options */ public function build(ContentRepositoryId $contentRepositoryId, array $options): NodeTypeManager { - if (!self::$nodeTypesToUse) { - throw new \DomainException('NodeTypeManagerFactory uninitialized'); + if (!self::$nodeTypeManager) { + throw new \RuntimeException('NodeTypeManagerFactory uninitialized'); } - return self::$nodeTypesToUse; + return self::$nodeTypeManager; } - public static function initializeWithPyStringNode(PyStringNode $nodeTypesToUse): void + public static function setConfiguration(array $nodeTypesToUse): void { - self::$nodeTypesToUse = new NodeTypeManager( - fn (): array => Yaml::parse($nodeTypesToUse->getRaw()) ?? [] + self::$nodeTypeManager = new NodeTypeManager( + fn (): array => $nodeTypesToUse ); } + public static function setNodeTypeManager(NodeTypeManager $nodeTypeManager): void + { + self::$nodeTypeManager = $nodeTypeManager; + } + public static function reset(): void { - self::$nodeTypesToUse = null; + self::$nodeTypeManager = null; } } diff --git a/Neos.ContentRepository.TestSuite/Classes/Fakes/GherkinTableNodeBasedContentDimensionSource.php b/Neos.ContentRepository.TestSuite/Classes/Fakes/GherkinTableNodeBasedContentDimensionSource.php index 4329ebc5090..7c949db0fac 100644 --- a/Neos.ContentRepository.TestSuite/Classes/Fakes/GherkinTableNodeBasedContentDimensionSource.php +++ b/Neos.ContentRepository.TestSuite/Classes/Fakes/GherkinTableNodeBasedContentDimensionSource.php @@ -28,12 +28,11 @@ /** * The node creation trait for behavioral tests - * todo colocate with GherkinTableNodeBasedContentDimensionSourceFactory */ final readonly class GherkinTableNodeBasedContentDimensionSource implements ContentDimensionSourceInterface { + /** @param array $contentDimensions */ private function __construct( - /** @var array */ private array $contentDimensions ) { } diff --git a/Neos.ContentRepository.TestSuite/Classes/Fakes/GherkinTableNodeBasedContentDimensionSourceFactory.php b/Neos.ContentRepository.TestSuite/Classes/Fakes/GherkinTableNodeBasedContentDimensionSourceFactory.php index 16c24140be5..ea7cbc1a28c 100644 --- a/Neos.ContentRepository.TestSuite/Classes/Fakes/GherkinTableNodeBasedContentDimensionSourceFactory.php +++ b/Neos.ContentRepository.TestSuite/Classes/Fakes/GherkinTableNodeBasedContentDimensionSourceFactory.php @@ -4,33 +4,52 @@ namespace Neos\ContentRepository\TestSuite\Fakes; -use Behat\Gherkin\Node\TableNode; +use Neos\ContentRepository\Core\Dimension\ContentDimension; +use Neos\ContentRepository\Core\Dimension\ContentDimensionId; use Neos\ContentRepository\Core\Dimension\ContentDimensionSourceInterface; use Neos\ContentRepository\Core\SharedModel\ContentRepository\ContentRepositoryId; use Neos\ContentRepositoryRegistry\Factory\ContentDimensionSource\ContentDimensionSourceFactoryInterface; class GherkinTableNodeBasedContentDimensionSourceFactory implements ContentDimensionSourceFactoryInterface { - public static ?ContentDimensionSourceInterface $contentDimensionsToUse = null; + private static ?ContentDimensionSourceInterface $contentDimensionSource = null; /** * @param array $options */ public function build(ContentRepositoryId $contentRepositoryId, array $options): ContentDimensionSourceInterface { - if (!self::$contentDimensionsToUse) { - throw new \DomainException('Content dimension source not initialized.'); + if (!self::$contentDimensionSource) { + throw new \RuntimeException('Content dimension source not initialized.'); } - return self::$contentDimensionsToUse; + return self::$contentDimensionSource; } - public static function initializeFromTableNode(TableNode $contentDimensionsToUse): void + public static function setContentDimensionSource(ContentDimensionSourceInterface $contentDimensionSource): void { - self::$contentDimensionsToUse = GherkinTableNodeBasedContentDimensionSource::fromGherkinTableNode($contentDimensionsToUse); + self::$contentDimensionSource = $contentDimensionSource; + } + + /** + * Configures a zero-dimensional content repository + */ + public static function setWithoutDimensions(): void + { + self::$contentDimensionSource = new class implements ContentDimensionSourceInterface + { + public function getDimension(ContentDimensionId $dimensionId): ?ContentDimension + { + return null; + } + public function getContentDimensionsOrderedByPriority(): array + { + return []; + } + }; } public static function reset(): void { - self::$contentDimensionsToUse = null; + self::$contentDimensionSource = null; } } From 5582ba1ecf077691465640ede47e76b8fa8126e6 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Wed, 6 Nov 2024 18:16:11 +0100 Subject: [PATCH 03/12] TASK: Rename fake factories to be generically used instead of just for gherkin/behat --- .../Features/Bootstrap/FeatureContext.php | 12 +++---- .../CRBehavioralTestsSubjectProvider.php | 18 +++++----- .../Settings.ContentRepositoryRegistry.yaml | 4 +-- .../Behavior/Bootstrap/FeatureContext.php | 12 +++---- .../WorkspaceWritingDuringRebase.php | 36 +++++-------------- .../Features/Bootstrap/FeatureContext.php | 12 +++---- .../Behavior/Bootstrap/FeatureContext.php | 8 ++--- ... => FakeContentDimensionSourceFactory.php} | 6 +++- ...ory.php => FakeNodeTypeManagerFactory.php} | 5 +-- .../Features/Bootstrap/FeatureContext.php | 12 +++---- .../Behavior/Bootstrap/FeatureContext.php | 8 ++--- 11 files changed, 60 insertions(+), 73 deletions(-) rename Neos.ContentRepository.TestSuite/Classes/Fakes/{GherkinTableNodeBasedContentDimensionSourceFactory.php => FakeContentDimensionSourceFactory.php} (85%) rename Neos.ContentRepository.TestSuite/Classes/Fakes/{GherkinPyStringNodeBasedNodeTypeManagerFactory.php => FakeNodeTypeManagerFactory.php} (83%) diff --git a/Neos.ContentGraph.DoctrineDbalAdapter/Tests/Behavior/Features/Bootstrap/FeatureContext.php b/Neos.ContentGraph.DoctrineDbalAdapter/Tests/Behavior/Features/Bootstrap/FeatureContext.php index ced1b64b043..6fa805c907c 100644 --- a/Neos.ContentGraph.DoctrineDbalAdapter/Tests/Behavior/Features/Bootstrap/FeatureContext.php +++ b/Neos.ContentGraph.DoctrineDbalAdapter/Tests/Behavior/Features/Bootstrap/FeatureContext.php @@ -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; /** @@ -52,8 +52,8 @@ public function __construct() */ public function resetContentRepositoryComponents(BeforeScenarioScope $scope): void { - GherkinTableNodeBasedContentDimensionSourceFactory::reset(); - GherkinPyStringNodeBasedNodeTypeManagerFactory::reset(); + FakeContentDimensionSourceFactory::reset(); + FakeNodeTypeManagerFactory::reset(); } protected function getContentRepositoryService( @@ -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; } diff --git a/Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/CRBehavioralTestsSubjectProvider.php b/Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/CRBehavioralTestsSubjectProvider.php index 47ad3ca0553..94b84cdbe17 100644 --- a/Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/CRBehavioralTestsSubjectProvider.php +++ b/Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/CRBehavioralTestsSubjectProvider.php @@ -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; @@ -60,7 +60,7 @@ protected function getContentRepository(ContentRepositoryId $contentRepositoryId */ public function usingNoContentDimensions(): void { - GherkinTableNodeBasedContentDimensionSourceFactory::setWithoutDimensions(); + FakeContentDimensionSourceFactory::setWithoutDimensions(); } /** @@ -68,7 +68,7 @@ public function usingNoContentDimensions(): void */ public function usingTheFollowingContentDimensions(TableNode $contentDimensions): void { - GherkinTableNodeBasedContentDimensionSourceFactory::setContentDimensionSource( + FakeContentDimensionSourceFactory::setContentDimensionSource( GherkinTableNodeBasedContentDimensionSource::fromGherkinTableNode($contentDimensions) ); } @@ -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()) ?? []); } /** @@ -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)); @@ -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]; diff --git a/Neos.ContentRepository.BehavioralTests/Configuration/Testing/Behat/Settings.ContentRepositoryRegistry.yaml b/Neos.ContentRepository.BehavioralTests/Configuration/Testing/Behat/Settings.ContentRepositoryRegistry.yaml index db115d048a2..32f24c1b128 100644 --- a/Neos.ContentRepository.BehavioralTests/Configuration/Testing/Behat/Settings.ContentRepositoryRegistry.yaml +++ b/Neos.ContentRepository.BehavioralTests/Configuration/Testing/Behat/Settings.ContentRepositoryRegistry.yaml @@ -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' diff --git a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Bootstrap/FeatureContext.php b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Bootstrap/FeatureContext.php index 1e71fb0bc1c..9646198d20d 100644 --- a/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Bootstrap/FeatureContext.php +++ b/Neos.ContentRepository.BehavioralTests/Tests/Behavior/Bootstrap/FeatureContext.php @@ -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; @@ -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( @@ -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; } diff --git a/Neos.ContentRepository.BehavioralTests/Tests/Parallel/WorkspaceWritingDuringRebase/WorkspaceWritingDuringRebase.php b/Neos.ContentRepository.BehavioralTests/Tests/Parallel/WorkspaceWritingDuringRebase/WorkspaceWritingDuringRebase.php index 32ffd18d9fd..01a14ea75d9 100644 --- a/Neos.ContentRepository.BehavioralTests/Tests/Parallel/WorkspaceWritingDuringRebase/WorkspaceWritingDuringRebase.php +++ b/Neos.ContentRepository.BehavioralTests/Tests/Parallel/WorkspaceWritingDuringRebase/WorkspaceWritingDuringRebase.php @@ -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; @@ -29,7 +26,6 @@ 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; @@ -37,8 +33,8 @@ 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; @@ -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' ] ] ] diff --git a/Neos.ContentRepository.Export/Tests/Behavior/Features/Bootstrap/FeatureContext.php b/Neos.ContentRepository.Export/Tests/Behavior/Features/Bootstrap/FeatureContext.php index 6700478b68e..15543eef068 100644 --- a/Neos.ContentRepository.Export/Tests/Behavior/Features/Bootstrap/FeatureContext.php +++ b/Neos.ContentRepository.Export/Tests/Behavior/Features/Bootstrap/FeatureContext.php @@ -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; /** @@ -52,8 +52,8 @@ public function __construct() */ public function resetContentRepositoryComponents(BeforeScenarioScope $scope): void { - GherkinTableNodeBasedContentDimensionSourceFactory::reset(); - GherkinPyStringNodeBasedNodeTypeManagerFactory::reset(); + FakeContentDimensionSourceFactory::reset(); + FakeNodeTypeManagerFactory::reset(); } protected function getContentRepositoryService( @@ -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; } diff --git a/Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/Bootstrap/FeatureContext.php b/Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/Bootstrap/FeatureContext.php index 2aa7076e723..eeae7a06620 100644 --- a/Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/Bootstrap/FeatureContext.php +++ b/Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/Bootstrap/FeatureContext.php @@ -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; @@ -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; } diff --git a/Neos.ContentRepository.TestSuite/Classes/Fakes/GherkinTableNodeBasedContentDimensionSourceFactory.php b/Neos.ContentRepository.TestSuite/Classes/Fakes/FakeContentDimensionSourceFactory.php similarity index 85% rename from Neos.ContentRepository.TestSuite/Classes/Fakes/GherkinTableNodeBasedContentDimensionSourceFactory.php rename to Neos.ContentRepository.TestSuite/Classes/Fakes/FakeContentDimensionSourceFactory.php index ea7cbc1a28c..66a2bbd612f 100644 --- a/Neos.ContentRepository.TestSuite/Classes/Fakes/GherkinTableNodeBasedContentDimensionSourceFactory.php +++ b/Neos.ContentRepository.TestSuite/Classes/Fakes/FakeContentDimensionSourceFactory.php @@ -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; diff --git a/Neos.ContentRepository.TestSuite/Classes/Fakes/GherkinPyStringNodeBasedNodeTypeManagerFactory.php b/Neos.ContentRepository.TestSuite/Classes/Fakes/FakeNodeTypeManagerFactory.php similarity index 83% rename from Neos.ContentRepository.TestSuite/Classes/Fakes/GherkinPyStringNodeBasedNodeTypeManagerFactory.php rename to Neos.ContentRepository.TestSuite/Classes/Fakes/FakeNodeTypeManagerFactory.php index aa17332e15b..2d67e533234 100644 --- a/Neos.ContentRepository.TestSuite/Classes/Fakes/GherkinPyStringNodeBasedNodeTypeManagerFactory.php +++ b/Neos.ContentRepository.TestSuite/Classes/Fakes/FakeNodeTypeManagerFactory.php @@ -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; diff --git a/Neos.Neos/Tests/Behavior/Features/Bootstrap/FeatureContext.php b/Neos.Neos/Tests/Behavior/Features/Bootstrap/FeatureContext.php index fdb2e2d9888..e8636b4aac2 100644 --- a/Neos.Neos/Tests/Behavior/Features/Bootstrap/FeatureContext.php +++ b/Neos.Neos/Tests/Behavior/Features/Bootstrap/FeatureContext.php @@ -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; @@ -73,8 +73,8 @@ public function __construct() */ public function resetContentRepositoryComponents(): void { - GherkinTableNodeBasedContentDimensionSourceFactory::reset(); - GherkinPyStringNodeBasedNodeTypeManagerFactory::reset(); + FakeContentDimensionSourceFactory::reset(); + FakeNodeTypeManagerFactory::reset(); } /** @@ -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; } diff --git a/Neos.TimeableNodeVisibility/Tests/Behavior/Bootstrap/FeatureContext.php b/Neos.TimeableNodeVisibility/Tests/Behavior/Bootstrap/FeatureContext.php index 52e906898dc..2656730cb90 100644 --- a/Neos.TimeableNodeVisibility/Tests/Behavior/Bootstrap/FeatureContext.php +++ b/Neos.TimeableNodeVisibility/Tests/Behavior/Bootstrap/FeatureContext.php @@ -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; @@ -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; } From c5bb8ea1ed0289d3b033f0ec6ac2bebd189bff49 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Wed, 6 Nov 2024 21:01:31 +0100 Subject: [PATCH 04/12] TASK: Add test for GherkinTableNodeBasedContentDimensionSource and document --- .../CRBehavioralTestsSubjectProvider.php | 4 +- ...inTableNodeBasedContentDimensionSource.php | 6 +- ...bleNodeBasedContentDimensionSourceTest.php | 236 ++++++++++++++++++ 3 files changed, 242 insertions(+), 4 deletions(-) rename Neos.ContentRepository.TestSuite/Classes/{Fakes => Behavior/Features/Bootstrap/Helpers}/GherkinTableNodeBasedContentDimensionSource.php (93%) create mode 100644 Neos.ContentRepository.TestSuite/Tests/Unit/GherkinTableNodeBasedContentDimensionSourceTest.php diff --git a/Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/CRBehavioralTestsSubjectProvider.php b/Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/CRBehavioralTestsSubjectProvider.php index 94b84cdbe17..9f8d56cda7f 100644 --- a/Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/CRBehavioralTestsSubjectProvider.php +++ b/Neos.ContentRepository.BehavioralTests/Classes/TestSuite/Behavior/CRBehavioralTestsSubjectProvider.php @@ -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\FakeNodeTypeManagerFactory; -use Neos\ContentRepository\TestSuite\Fakes\GherkinTableNodeBasedContentDimensionSource; +use Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\Helpers\GherkinTableNodeBasedContentDimensionSource; use Neos\ContentRepository\TestSuite\Fakes\FakeContentDimensionSourceFactory; +use Neos\ContentRepository\TestSuite\Fakes\FakeNodeTypeManagerFactory; use Neos\EventStore\EventStoreInterface; use Symfony\Component\Yaml\Yaml; diff --git a/Neos.ContentRepository.TestSuite/Classes/Fakes/GherkinTableNodeBasedContentDimensionSource.php b/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/Helpers/GherkinTableNodeBasedContentDimensionSource.php similarity index 93% rename from Neos.ContentRepository.TestSuite/Classes/Fakes/GherkinTableNodeBasedContentDimensionSource.php rename to Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/Helpers/GherkinTableNodeBasedContentDimensionSource.php index 7c949db0fac..0b528ef7337 100644 --- a/Neos.ContentRepository.TestSuite/Classes/Fakes/GherkinTableNodeBasedContentDimensionSource.php +++ b/Neos.ContentRepository.TestSuite/Classes/Behavior/Features/Bootstrap/Helpers/GherkinTableNodeBasedContentDimensionSource.php @@ -12,7 +12,7 @@ declare(strict_types=1); -namespace Neos\ContentRepository\TestSuite\Fakes; +namespace Neos\ContentRepository\TestSuite\Behavior\Features\Bootstrap\Helpers; use Behat\Gherkin\Node\TableNode; use Neos\ContentRepository\Core\Dimension\ContentDimension; @@ -27,7 +27,9 @@ use Neos\Utility\Arrays; /** - * The node creation trait for behavioral tests + * Compact syntax to declare content dimensions in gherkin tables. + * + * see also {@see \Neos\ContentRepository\TestSuite\Tests\Unit\GherkinTableNodeBasedContentDimensionSourceTest} */ final readonly class GherkinTableNodeBasedContentDimensionSource implements ContentDimensionSourceInterface { diff --git a/Neos.ContentRepository.TestSuite/Tests/Unit/GherkinTableNodeBasedContentDimensionSourceTest.php b/Neos.ContentRepository.TestSuite/Tests/Unit/GherkinTableNodeBasedContentDimensionSourceTest.php new file mode 100644 index 00000000000..dfc29c25490 --- /dev/null +++ b/Neos.ContentRepository.TestSuite/Tests/Unit/GherkinTableNodeBasedContentDimensionSourceTest.php @@ -0,0 +1,236 @@ +valueA1'], + ['dimensionB', 'valueB1,valueB2,valueB3' , '' ], + ]; + $this->subject = GherkinTableNodeBasedContentDimensionSource::fromGherkinTableNode(new TableNode($table)); + } + + public function testEmptyDimensionConfigurationIsCorrectlyInitialized() + { + $subject = GherkinTableNodeBasedContentDimensionSource::createEmpty(); + + $this->assertSame([], $subject->getContentDimensionsOrderedByPriority()); + } + + public function testDimensionsAreInitializedInCorrectOrder() + { + $dimensions = $this->subject->getContentDimensionsOrderedByPriority(); + $dimensionKeys = array_keys($dimensions); + + $this->assertSame('dimensionA', $dimensionKeys[0]); + $this->assertSame('dimensionB', $dimensionKeys[1]); + } + + public function testDimensionValuesAreCorrectlyInitialized() + { + $dimensionA = $this->subject->getDimension(new ContentDimensionId('dimensionA')); + $dimensionB = $this->subject->getDimension(new ContentDimensionId('dimensionB')); + + $this->assertEquals( + new ContentDimensionValue( + 'valueA1', + new ContentDimensionValueSpecializationDepth(0), + ContentDimensionConstraintSet::createEmpty(), + [] + ), + $dimensionA->getValue('valueA1') + ); + $this->assertEquals( + new ContentDimensionValue( + 'valueA1.1', + new ContentDimensionValueSpecializationDepth(1), + ContentDimensionConstraintSet::createEmpty() + ), + $dimensionA->getValue('valueA1.1') + ); + $this->assertEquals( + new ContentDimensionValue( + 'valueA2', + new ContentDimensionValueSpecializationDepth(0), + ContentDimensionConstraintSet::createEmpty() + ), + $dimensionA->getValue('valueA2') + ); + + $this->assertEquals( + new ContentDimensionValue( + 'valueB1', + new ContentDimensionValueSpecializationDepth(0) + ), + $dimensionB->getValue('valueB1') + ); + $this->assertEquals( + new ContentDimensionValue( + 'valueB2', + new ContentDimensionValueSpecializationDepth(0) + ), + $dimensionB->getValue('valueB2') + ); + $this->assertEquals( + new ContentDimensionValue( + 'valueB3', + new ContentDimensionValueSpecializationDepth(0) + ), + $dimensionB->getValue('valueB3') + ); + } + + public function testSpecializationsAreCorrectlyInitialized() + { + $dimensionA = $this->subject->getDimension(new ContentDimensionId('dimensionA')); + $this->assertSame( + [ + 'valueA1.1' => $dimensionA->getValue('valueA1.1') + ], + $dimensionA->getSpecializations($dimensionA->getValue('valueA1')) + ); + $this->assertSame( + null, + $dimensionA->getGeneralization($dimensionA->getValue('valueA1')) + ); + + $this->assertSame( + [], + $dimensionA->getSpecializations($dimensionA->getValue('valueA1.1')) + ); + $this->assertSame( + $dimensionA->getValue('valueA1'), + $dimensionA->getGeneralization($dimensionA->getValue('valueA1.1')) + ); + + $this->assertSame( + [], + $dimensionA->getSpecializations($dimensionA->getValue('valueA2')) + ); + $this->assertSame( + null, + $dimensionA->getGeneralization($dimensionA->getValue('valueA2')) + ); + + $dimensionB = $this->subject->getDimension(new ContentDimensionId('dimensionB')); + $this->assertSame( + [], + $dimensionB->getSpecializations($dimensionB->getValue('valueB1')) + ); + $this->assertSame( + null, + $dimensionA->getGeneralization($dimensionB->getValue('valueB1')) + ); + + $this->assertSame( + [], + $dimensionB->getSpecializations($dimensionB->getValue('valueB2')) + ); + $this->assertSame( + null, + $dimensionA->getGeneralization($dimensionB->getValue('valueB2')) + ); + + $this->assertSame( + [], + $dimensionB->getSpecializations($dimensionB->getValue('valueB3')) + ); + $this->assertSame( + null, + $dimensionA->getGeneralization($dimensionB->getValue('valueB3')) + ); + } + + public function testMaximumDepthIsCorrectlyInitialized() + { + $dimensionA = $this->subject->getDimension(new ContentDimensionId('dimensionA')); + $dimensionB = $this->subject->getDimension(new ContentDimensionId('dimensionB')); + + $this->assertEquals( + new ContentDimensionValueSpecializationDepth(1), + $dimensionA->getMaximumDepth() + ); + $this->assertEquals( + new ContentDimensionValueSpecializationDepth(0), + $dimensionB->getMaximumDepth() + ); + } + + public function testRestrictionsAreCorrectlyInitialized() + { + $dimensionA = $this->subject->getDimension(new ContentDimensionId('dimensionA')); + $dimensionB = $this->subject->getDimension(new ContentDimensionId('dimensionB')); + + $valueA1 = $dimensionA->getValue('valueA1'); + $this->assertEquals( + ContentDimensionConstraintSet::createEmpty(), + $valueA1->constraints + ); + + $valueA11 = $dimensionA->getValue('valueA1.1'); + $this->assertEquals( + ContentDimensionConstraintSet::createEmpty(), + $valueA11->constraints + ); + + $valueA2 = $dimensionA->getValue('valueA2'); + $this->assertEquals( + ContentDimensionConstraintSet::createEmpty(), + $valueA2->constraints + ); + + $valueB1 = $dimensionB->getValue('valueB1'); + $this->assertEquals( + ContentDimensionConstraintSet::createEmpty(), + $valueB1->constraints + ); + + $valueB2 = $dimensionB->getValue('valueB2'); + $this->assertEquals( + ContentDimensionConstraintSet::createEmpty(), + $valueB2->constraints + ); + + $valueB3 = $dimensionB->getValue('valueB3'); + $this->assertEquals( + ContentDimensionConstraintSet::createEmpty(), + $valueB3->constraints + ); + } +} From f0b1e14e4feac0f07034d01d3ce44f068c357d21 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Wed, 6 Nov 2024 21:09:52 +0100 Subject: [PATCH 05/12] TASK: Allow to configure `FakeNodeTypeManagerFactory` for testing --- .../Classes/Fakes/FakeNodeTypeManagerFactory.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Neos.ContentRepository.TestSuite/Classes/Fakes/FakeNodeTypeManagerFactory.php b/Neos.ContentRepository.TestSuite/Classes/Fakes/FakeNodeTypeManagerFactory.php index 2d67e533234..10e8f31ff2f 100644 --- a/Neos.ContentRepository.TestSuite/Classes/Fakes/FakeNodeTypeManagerFactory.php +++ b/Neos.ContentRepository.TestSuite/Classes/Fakes/FakeNodeTypeManagerFactory.php @@ -31,10 +31,14 @@ final class FakeNodeTypeManagerFactory implements NodeTypeManagerFactoryInterfac */ public function build(ContentRepositoryId $contentRepositoryId, array $options): NodeTypeManager { - if (!self::$nodeTypeManager) { - throw new \RuntimeException('NodeTypeManagerFactory uninitialized'); + if (self::$nodeTypeManager) { + return self::$nodeTypeManager; } - return self::$nodeTypeManager; + if (isset($options['nodeTypes'])) { + // allows to be configured for testing + return new NodeTypeManager(fn (): array => $options['nodeTypes']); + } + throw new \RuntimeException('NodeTypeManagerFactory uninitialized'); } public static function setConfiguration(array $nodeTypesToUse): void From d47d2123527cf2419d57cad753a33bb150ef115d Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Wed, 6 Nov 2024 21:22:15 +0100 Subject: [PATCH 06/12] WIP --- .../Configuration/Settings.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Neos.ContentRepository.BehavioralTests/Configuration/Settings.yaml b/Neos.ContentRepository.BehavioralTests/Configuration/Settings.yaml index 212fb010b63..039cd2925f8 100644 --- a/Neos.ContentRepository.BehavioralTests/Configuration/Settings.yaml +++ b/Neos.ContentRepository.BehavioralTests/Configuration/Settings.yaml @@ -24,9 +24,9 @@ Neos: eventStore: factoryObjectName: Neos\ContentRepositoryRegistry\Factory\EventStore\DoctrineEventStoreFactory nodeTypeManager: - factoryObjectName: Neos\ContentRepository\BehavioralTests\TestSuite\Behavior\GherkinPyStringNodeBasedNodeTypeManagerFactory + factoryObjectName: Neos\ContentRepository\TestSuite\Fakes\FakeNodeTypeManagerFactory contentDimensionSource: - factoryObjectName: Neos\ContentRepository\BehavioralTests\TestSuite\Behavior\GherkinTableNodeBasedContentDimensionSourceFactory + factoryObjectName: Neos\ContentRepository\TestSuite\Fakes\FakeContentDimensionSourceFactory userIdProvider: factoryObjectName: Neos\ContentRepositoryRegistry\Factory\UserIdProvider\StaticUserIdProviderFactory clock: From 3c2036513453663c8163f7ecbb178cd8feb3a2e7 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Wed, 6 Nov 2024 21:22:26 +0100 Subject: [PATCH 07/12] Fix php types and missing brace --- .../WorkspaceWritingDuringRebase.php | 2 +- .../Classes/Fakes/FakeNodeTypeManagerFactory.php | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Neos.ContentRepository.BehavioralTests/Tests/Parallel/WorkspaceWritingDuringRebase/WorkspaceWritingDuringRebase.php b/Neos.ContentRepository.BehavioralTests/Tests/Parallel/WorkspaceWritingDuringRebase/WorkspaceWritingDuringRebase.php index 01a14ea75d9..5a4feaabb46 100644 --- a/Neos.ContentRepository.BehavioralTests/Tests/Parallel/WorkspaceWritingDuringRebase/WorkspaceWritingDuringRebase.php +++ b/Neos.ContentRepository.BehavioralTests/Tests/Parallel/WorkspaceWritingDuringRebase/WorkspaceWritingDuringRebase.php @@ -63,7 +63,7 @@ public function setUp(): void ] ] ] - ); + ]); $setupLockResource = fopen(self::SETUP_LOCK_PATH, 'w+'); diff --git a/Neos.ContentRepository.TestSuite/Classes/Fakes/FakeNodeTypeManagerFactory.php b/Neos.ContentRepository.TestSuite/Classes/Fakes/FakeNodeTypeManagerFactory.php index 10e8f31ff2f..220d2ea843f 100644 --- a/Neos.ContentRepository.TestSuite/Classes/Fakes/FakeNodeTypeManagerFactory.php +++ b/Neos.ContentRepository.TestSuite/Classes/Fakes/FakeNodeTypeManagerFactory.php @@ -41,6 +41,9 @@ public function build(ContentRepositoryId $contentRepositoryId, array $options): throw new \RuntimeException('NodeTypeManagerFactory uninitialized'); } + /** + * @param array $nodeTypesToUse + */ public static function setConfiguration(array $nodeTypesToUse): void { self::$nodeTypeManager = new NodeTypeManager( From eaefd33dabcaef38095e32a5ffa63ef7e570e643 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Mu=CC=88ller?= Date: Tue, 19 Nov 2024 16:32:05 +0100 Subject: [PATCH 08/12] Move parallel test settings to Testing context --- .../Configuration/{ => Testing}/Settings.yaml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename Neos.ContentRepository.BehavioralTests/Configuration/{ => Testing}/Settings.yaml (100%) diff --git a/Neos.ContentRepository.BehavioralTests/Configuration/Settings.yaml b/Neos.ContentRepository.BehavioralTests/Configuration/Testing/Settings.yaml similarity index 100% rename from Neos.ContentRepository.BehavioralTests/Configuration/Settings.yaml rename to Neos.ContentRepository.BehavioralTests/Configuration/Testing/Settings.yaml From 50a680fc5c7b31a3e10ada1728f6d02f1d01e441 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Tue, 19 Nov 2024 17:03:35 +0100 Subject: [PATCH 09/12] TASK: Lotta adjustments --- .composer.json | 4 +- .../WorkspacePublicationDuringWritingTest.php | 38 +++++-------------- Neos.ContentRepository.Core/composer.json | 2 +- Neos.ContentRepository.Export/composer.json | 2 +- .../Behavior/Bootstrap/FeatureContext.php | 14 ------- composer.json | 11 +----- 6 files changed, 15 insertions(+), 56 deletions(-) diff --git a/.composer.json b/.composer.json index e7f37b99667..2f96abd741b 100644 --- a/.composer.json +++ b/.composer.json @@ -13,7 +13,7 @@ "scripts": { "lint:phpcs": "../../bin/phpcs --colors", "lint:phpcs:fix": "../../bin/phpcbf --colors", - "lint:phpstan": "../../bin/phpstan analyse", + "lint:phpstan": "../../bin/phpstan analyse -v", "lint:phpstan-generate-baseline": "../../bin/phpstan analyse --generate-baseline", "lint:distributionintegrity": "[ -d 'Neos.ContentRepository' ] && { echo 'Package Neos.ContentRepository should not exist.' 1>&2; exit 1; } || exit 0;", "lint": [ @@ -27,7 +27,7 @@ ], "test:paratest-cli": "../../bin/paratest --debug -v --functional --processes 2 --colors --stop-on-failure -c ../../Build/BuildEssentials/PhpUnit/FunctionalTests.xml", "test:parallel": [ - "for f in Neos.ContentRepository.BehavioralTests/Tests/Parallel/**/*Test.php; do composer test:paratest-cli $f; done" + "for f in Neos.ContentRepository.BehavioralTests/Tests/Parallel/**/*Test.php; do composer test:paratest-cli $f || exit 1; done" ], "test:behat-cli": "../../bin/behat -f progress --strict --no-interaction", "test:behavioral": [ diff --git a/Neos.ContentRepository.BehavioralTests/Tests/Parallel/WorkspacePublicationDuringWriting/WorkspacePublicationDuringWritingTest.php b/Neos.ContentRepository.BehavioralTests/Tests/Parallel/WorkspacePublicationDuringWriting/WorkspacePublicationDuringWritingTest.php index d96a9adddf0..1dcc9fcdd03 100644 --- a/Neos.ContentRepository.BehavioralTests/Tests/Parallel/WorkspacePublicationDuringWriting/WorkspacePublicationDuringWritingTest.php +++ b/Neos.ContentRepository.BehavioralTests/Tests/Parallel/WorkspacePublicationDuringWriting/WorkspacePublicationDuringWritingTest.php @@ -15,12 +15,7 @@ namespace Neos\ContentRepository\BehavioralTests\Tests\Parallel\WorkspacePublicationDuringWriting; use Neos\ContentRepository\BehavioralTests\Tests\Parallel\AbstractParallelTestCase; -use Neos\ContentRepository\BehavioralTests\TestSuite\Behavior\GherkinPyStringNodeBasedNodeTypeManagerFactory; -use Neos\ContentRepository\BehavioralTests\TestSuite\Behavior\GherkinTableNodeBasedContentDimensionSourceFactory; 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; @@ -30,7 +25,6 @@ use Neos\ContentRepository\Core\Feature\WorkspaceCreation\Command\CreateRootWorkspace; use Neos\ContentRepository\Core\Feature\WorkspaceCreation\Command\CreateWorkspace; use Neos\ContentRepository\Core\Feature\WorkspacePublication\Command\PublishWorkspace; -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; @@ -38,6 +32,8 @@ 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\FakeContentDimensionSourceFactory; +use Neos\ContentRepository\TestSuite\Fakes\FakeNodeTypeManagerFactory; use Neos\EventStore\Exception\ConcurrencyException; use Neos\Flow\ObjectManagement\ObjectManagerInterface; use PHPUnit\Framework\Assert; @@ -55,31 +51,17 @@ 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' ] ] ] - ); + ]); $setupLockResource = fopen(self::SETUP_LOCK_PATH, 'w+'); diff --git a/Neos.ContentRepository.Core/composer.json b/Neos.ContentRepository.Core/composer.json index 0951197e5b6..c7cc7e759bb 100644 --- a/Neos.ContentRepository.Core/composer.json +++ b/Neos.ContentRepository.Core/composer.json @@ -25,7 +25,7 @@ }, "require-dev": { "roave/security-advisories": "dev-latest", - "phpstan/phpstan": "^1.5", + "phpstan/phpstan": "^1.11", "squizlabs/php_codesniffer": "^3.6", "phpunit/phpunit": "^9.0" }, diff --git a/Neos.ContentRepository.Export/composer.json b/Neos.ContentRepository.Export/composer.json index cdaf568f4ed..545aceb6c37 100644 --- a/Neos.ContentRepository.Export/composer.json +++ b/Neos.ContentRepository.Export/composer.json @@ -15,7 +15,7 @@ }, "require-dev": { "roave/security-advisories": "dev-latest", - "phpstan/phpstan": "^1.8" + "phpstan/phpstan": "^1.11" }, "suggest": { "league/flysystem-ziparchive": "to export zip archives", diff --git a/Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/Bootstrap/FeatureContext.php b/Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/Bootstrap/FeatureContext.php index bf3dbb7a436..7b8ef635cf2 100644 --- a/Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/Bootstrap/FeatureContext.php +++ b/Neos.ContentRepository.LegacyNodeMigration/Tests/Behavior/Bootstrap/FeatureContext.php @@ -252,20 +252,6 @@ public function iRunTheSiteMigration(): void /** ---------------------------------- */ - /** - * @param TableNode $table - * @return array - * @throws JsonException - */ - private function parseJsonTable(TableNode $table): array - { - return array_map(static function (array $row) { - return array_map(static function (string $jsonValue) { - return json_decode($jsonValue, true, 512, JSON_THROW_ON_ERROR); - }, $row); - }, $table->getHash()); - } - protected function getContentRepositoryService( ContentRepositoryServiceFactoryInterface $factory ): ContentRepositoryServiceInterface { diff --git a/composer.json b/composer.json index 668fb6e7918..36369a705c5 100644 --- a/composer.json +++ b/composer.json @@ -110,7 +110,7 @@ ], "test:paratest-cli": "../../bin/paratest --debug -v --functional --processes 2 --colors --stop-on-failure -c ../../Build/BuildEssentials/PhpUnit/FunctionalTests.xml", "test:parallel": [ - "for f in Neos.ContentRepository.BehavioralTests/Tests/Parallel/**/*Test.php; do composer test:paratest-cli $f; done" + "for f in Neos.ContentRepository.BehavioralTests/Tests/Parallel/**/*Test.php; do composer test:paratest-cli $f || exit 1; done" ], "test:behat-cli": "../../bin/behat -f progress --strict --no-interaction", "test:behavioral": [ @@ -297,14 +297,5 @@ "phpunit/phpunit": "^9.0", "neos/behat": "*", "league/flysystem-memory": "^3" - }, - - "config": { - "_comment": "We need to insert a vendor dir (even though composer install MUST NOT be run here) but so autoloading works for composer scripts", - "vendor-dir": "../Libraries", - "allow-plugins": { - "neos/composer-plugin": false, - "cweagans/composer-patches": false - } } } From 61e3952f523fcb613986292f25ff8b5d1bd3d992 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Wed, 20 Nov 2024 19:45:48 +0100 Subject: [PATCH 10/12] TASK: Add documentation to fakes --- .../Classes/Fakes/FakeAuthProvider.php | 4 ++++ Neos.ContentRepository.TestSuite/Classes/Fakes/FakeClock.php | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/Neos.ContentRepository.TestSuite/Classes/Fakes/FakeAuthProvider.php b/Neos.ContentRepository.TestSuite/Classes/Fakes/FakeAuthProvider.php index f3413550065..7cf61436185 100644 --- a/Neos.ContentRepository.TestSuite/Classes/Fakes/FakeAuthProvider.php +++ b/Neos.ContentRepository.TestSuite/Classes/Fakes/FakeAuthProvider.php @@ -12,6 +12,10 @@ use Neos\ContentRepository\Core\SharedModel\Workspace\WorkspaceName; use Neos\Neos\Security\ContentRepositoryAuthProvider\ContentRepositoryAuthProvider; +/** + * Content Repository AuthProvider implementation for tests + * This is a mutable class in order to allow to adjust the behaviour during runtime for testing purposes + */ final class FakeAuthProvider implements AuthProviderInterface { private static ?UserId $userId = null; diff --git a/Neos.ContentRepository.TestSuite/Classes/Fakes/FakeClock.php b/Neos.ContentRepository.TestSuite/Classes/Fakes/FakeClock.php index feb4d3af2ea..a77e9f92801 100644 --- a/Neos.ContentRepository.TestSuite/Classes/Fakes/FakeClock.php +++ b/Neos.ContentRepository.TestSuite/Classes/Fakes/FakeClock.php @@ -7,6 +7,10 @@ use DateTimeImmutable; use Psr\Clock\ClockInterface; +/** + * Clock implementation for tests + * This is a mutable class in order to allow to adjust the behaviour during runtime for testing purposes + */ final class FakeClock implements ClockInterface { private static ?DateTimeImmutable $now = null; From 195329b902b612eaefb1a9eaa78f906598c2bb9e Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Wed, 20 Nov 2024 20:13:32 +0100 Subject: [PATCH 11/12] TASK: Introduce `NodeTypeManager::createFromArrayConfiguration` to better document use-case --- .../Classes/NodeType/NodeTypeManager.php | 49 +++++++++++++++++-- .../Dto/NodeAggregateIdsByNodePathsTest.php | 4 +- .../Unit/NodeType/NodeTypeManagerTest.php | 12 ++--- .../Fakes/FakeNodeTypeManagerFactory.php | 6 +-- .../DefaultNodeTypeManagerFactory.php | 2 +- .../Service/NodeTypeSchemaBuilderTest.php | 2 +- 6 files changed, 58 insertions(+), 17 deletions(-) diff --git a/Neos.ContentRepository.Core/Classes/NodeType/NodeTypeManager.php b/Neos.ContentRepository.Core/Classes/NodeType/NodeTypeManager.php index 75cef7fa24f..1f13359d8fb 100644 --- a/Neos.ContentRepository.Core/Classes/NodeType/NodeTypeManager.php +++ b/Neos.ContentRepository.Core/Classes/NodeType/NodeTypeManager.php @@ -40,14 +40,55 @@ final class NodeTypeManager */ private array $cachedSubNodeTypes = []; - /** - * @internal - */ - public function __construct( + private function __construct( private readonly \Closure $nodeTypeConfigLoader ) { } + /** + * Initialise the NodeType manager with the NodeTypes configuration. + * + * The configuration is usually written in yaml format and then passed as array. + * + * A simple schema might look like this, were each key represents a NodeType: + * + * 'Vendor.Package:Root': + * superTypes: + * 'Neos.ContentRepository:Root': true + * 'Vendor.Package:Document': + * properties: + * title: + * type: string + * uri: + * type: GuzzleHttp\Psr7\Uri + * references: + * someReference: {} + * 'Vendor.Package:Text': + * properties: + * text: + * type: string + * + * FIXME, for standalone integrations a type safe API should be offered: {@link https://github.com/neos/neos-development-collection/issues/4228} + * + * @param array $configuration + * @internal only API for custom content repository integrations + */ + public static function createFromArrayConfiguration(array $configuration): self + { + return new self(fn () => $configuration); + } + + /** + * For documentation regarding the configuration format {@see NodeTypeManager::createFromArrayConfiguration} + * + * @param \Closure(): array $nodeTypeConfigurationLoader + * @internal only API for custom content repository integrations + */ + public static function createFromArrayConfigurationLoader(\Closure $nodeTypeConfigurationLoader): self + { + return new self($nodeTypeConfigurationLoader); + } + /** * Return all registered node types. * diff --git a/Neos.ContentRepository.Core/Tests/Unit/Feature/NodeCreation/Dto/NodeAggregateIdsByNodePathsTest.php b/Neos.ContentRepository.Core/Tests/Unit/Feature/NodeCreation/Dto/NodeAggregateIdsByNodePathsTest.php index cc4a645daf6..e5126866499 100644 --- a/Neos.ContentRepository.Core/Tests/Unit/Feature/NodeCreation/Dto/NodeAggregateIdsByNodePathsTest.php +++ b/Neos.ContentRepository.Core/Tests/Unit/Feature/NodeCreation/Dto/NodeAggregateIdsByNodePathsTest.php @@ -32,8 +32,8 @@ class NodeAggregateIdsByNodePathsTest extends TestCase */ public function testCompleteForNodeOfType(NodeAggregateIdsByNodePaths $subject, array $expectedNodeAggregateIdsByPath): void { - $nodeTypeManager = new NodeTypeManager( - fn (): array => [ + $nodeTypeManager = NodeTypeManager::createFromArrayConfiguration( + [ 'Neos.ContentRepository.Testing:Content' => [], 'Neos.ContentRepository.Testing:LeafDocument' => [ 'childNodes' => [ diff --git a/Neos.ContentRepository.Core/Tests/Unit/NodeType/NodeTypeManagerTest.php b/Neos.ContentRepository.Core/Tests/Unit/NodeType/NodeTypeManagerTest.php index 578378366ce..31e493ae4ee 100644 --- a/Neos.ContentRepository.Core/Tests/Unit/NodeType/NodeTypeManagerTest.php +++ b/Neos.ContentRepository.Core/Tests/Unit/NodeType/NodeTypeManagerTest.php @@ -41,8 +41,8 @@ public function setUp(): void */ protected function prepareNodeTypeManager(array $nodeTypesFixtureData) { - $this->nodeTypeManager = new NodeTypeManager( - fn() => $nodeTypesFixtureData + $this->nodeTypeManager = NodeTypeManager::createFromArrayConfiguration( + $nodeTypesFixtureData ); } @@ -443,8 +443,8 @@ public function getAutoCreatedChildNodesReturnsLowercaseNames() */ public function rootNodeTypeIsAlwaysPresent() { - $nodeTypeManager = new NodeTypeManager( - fn() => [] + $nodeTypeManager = NodeTypeManager::createFromArrayConfiguration( + [] ); self::assertTrue($nodeTypeManager->hasNodeType(NodeTypeName::ROOT_NODE_TYPE_NAME)); self::assertInstanceOf(NodeType::class, $nodeTypeManager->getNodeType(NodeTypeName::ROOT_NODE_TYPE_NAME)); @@ -455,8 +455,8 @@ public function rootNodeTypeIsAlwaysPresent() */ public function rootNodeTypeIsPresentAfterOverride() { - $nodeTypeManager = new NodeTypeManager( - fn() => [] + $nodeTypeManager = NodeTypeManager::createFromArrayConfiguration( + [] ); $nodeTypeManager->overrideNodeTypes(['Some:NewNodeType' => []]); self::assertTrue($nodeTypeManager->hasNodeType(NodeTypeName::fromString('Some:NewNodeType'))); diff --git a/Neos.ContentRepository.TestSuite/Classes/Fakes/FakeNodeTypeManagerFactory.php b/Neos.ContentRepository.TestSuite/Classes/Fakes/FakeNodeTypeManagerFactory.php index 220d2ea843f..6a06acc6bfe 100644 --- a/Neos.ContentRepository.TestSuite/Classes/Fakes/FakeNodeTypeManagerFactory.php +++ b/Neos.ContentRepository.TestSuite/Classes/Fakes/FakeNodeTypeManagerFactory.php @@ -36,7 +36,7 @@ public function build(ContentRepositoryId $contentRepositoryId, array $options): } if (isset($options['nodeTypes'])) { // allows to be configured for testing - return new NodeTypeManager(fn (): array => $options['nodeTypes']); + return NodeTypeManager::createFromArrayConfiguration($options['nodeTypes']); } throw new \RuntimeException('NodeTypeManagerFactory uninitialized'); } @@ -46,8 +46,8 @@ public function build(ContentRepositoryId $contentRepositoryId, array $options): */ public static function setConfiguration(array $nodeTypesToUse): void { - self::$nodeTypeManager = new NodeTypeManager( - fn (): array => $nodeTypesToUse + self::$nodeTypeManager = NodeTypeManager::createFromArrayConfiguration( + $nodeTypesToUse ); } diff --git a/Neos.ContentRepositoryRegistry/Classes/Factory/NodeTypeManager/DefaultNodeTypeManagerFactory.php b/Neos.ContentRepositoryRegistry/Classes/Factory/NodeTypeManager/DefaultNodeTypeManagerFactory.php index 2b1d783ec05..2be87c7696a 100644 --- a/Neos.ContentRepositoryRegistry/Classes/Factory/NodeTypeManager/DefaultNodeTypeManagerFactory.php +++ b/Neos.ContentRepositoryRegistry/Classes/Factory/NodeTypeManager/DefaultNodeTypeManagerFactory.php @@ -18,7 +18,7 @@ public function __construct( /** @param array $options */ public function build(ContentRepositoryId $contentRepositoryId, array $options): NodeTypeManager { - return new NodeTypeManager( + return NodeTypeManager::createFromArrayConfigurationLoader( function () { $configuration = $this->configurationManager->getConfiguration('NodeTypes'); return $this->nodeTypeEnrichmentService->enrichNodeTypeLabelsConfiguration($configuration); diff --git a/Neos.Neos/Tests/Functional/Service/NodeTypeSchemaBuilderTest.php b/Neos.Neos/Tests/Functional/Service/NodeTypeSchemaBuilderTest.php index a71db4cd5fe..abc88364265 100644 --- a/Neos.Neos/Tests/Functional/Service/NodeTypeSchemaBuilderTest.php +++ b/Neos.Neos/Tests/Functional/Service/NodeTypeSchemaBuilderTest.php @@ -38,7 +38,7 @@ public function setUp(): void parent::setUp(); $configurationManager = $this->objectManager->get(ConfigurationManager::class); $this->nodeTypeSchemaBuilder = NodeTypeSchemaBuilder::create( - new NodeTypeManager( + NodeTypeManager::createFromArrayConfigurationLoader( fn() => $configurationManager->getConfiguration('NodeTypes') ) ); From 24ffeff863eb202b3c7494641dbd73ddd74dfcb1 Mon Sep 17 00:00:00 2001 From: mhsdesign <85400359+mhsdesign@users.noreply.github.com> Date: Wed, 20 Nov 2024 20:15:59 +0100 Subject: [PATCH 12/12] TASK: Remove `NodeTypeManager::overrideNodeTypes` as its no longer needed for testing Instead, we replace the node type manager and rebuild the content repository. See `iChangeTheNodeTypesInContentRepositoryTo` and `FakeNodeTypeManagerFactory` --- .../Classes/NodeType/NodeTypeManager.php | 28 ------------------- .../Unit/NodeType/NodeTypeManagerTest.php | 13 --------- 2 files changed, 41 deletions(-) diff --git a/Neos.ContentRepository.Core/Classes/NodeType/NodeTypeManager.php b/Neos.ContentRepository.Core/Classes/NodeType/NodeTypeManager.php index 1f13359d8fb..700ae691cad 100644 --- a/Neos.ContentRepository.Core/Classes/NodeType/NodeTypeManager.php +++ b/Neos.ContentRepository.Core/Classes/NodeType/NodeTypeManager.php @@ -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 $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. * diff --git a/Neos.ContentRepository.Core/Tests/Unit/NodeType/NodeTypeManagerTest.php b/Neos.ContentRepository.Core/Tests/Unit/NodeType/NodeTypeManagerTest.php index 31e493ae4ee..97c50d28f27 100644 --- a/Neos.ContentRepository.Core/Tests/Unit/NodeType/NodeTypeManagerTest.php +++ b/Neos.ContentRepository.Core/Tests/Unit/NodeType/NodeTypeManagerTest.php @@ -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)); - } }