55namespace Flowpack \NodeTemplates \Tests \Functional \Features \StandaloneValidationCommand ;
66
77use Flowpack \NodeTemplates \Application \Command \NodeTemplateCommandController ;
8- use Flowpack \NodeTemplates \Domain \NodeTemplateDumper \NodeTemplateDumper ;
9- use Flowpack \NodeTemplates \Domain \Template \RootTemplate ;
108use Flowpack \NodeTemplates \Tests \Functional \FakeNodeTypeManagerTrait ;
119use Flowpack \NodeTemplates \Tests \Functional \SnapshotTrait ;
12- use Neos \ContentRepository \Domain \Model \NodeInterface ;
1310use Neos \ContentRepository \Domain \Model \Workspace ;
1411use Neos \ContentRepository \Domain \Repository \ContentDimensionRepository ;
1512use Neos \ContentRepository \Domain \Repository \WorkspaceRepository ;
@@ -33,14 +30,6 @@ final class StandaloneValidationCommandTest extends FunctionalTestCase
3330
3431 private ContextFactoryInterface $ contextFactory ;
3532
36- protected NodeInterface $ homePageNode ;
37-
38- protected NodeInterface $ homePageMainContentCollectionNode ;
39-
40- private NodeTemplateDumper $ nodeTemplateDumper ;
41-
42- private RootTemplate $ lastCreatedRootTemplate ;
43-
4433 private NodeTypeManager $ nodeTypeManager ;
4534
4635 private string $ fixturesDir ;
@@ -49,7 +38,7 @@ public function setUp(): void
4938 {
5039 parent ::setUp ();
5140
52- $ this ->nodeTypeManager = $ this ->objectManager -> get (NodeTypeManager::class);
41+ $ this ->nodeTypeManager = $ this ->getObject (NodeTypeManager::class);
5342
5443 $ this ->loadFakeNodeTypes ();
5544
@@ -63,34 +52,45 @@ public function tearDown(): void
6352 {
6453 parent ::tearDown ();
6554 $ this ->inject ($ this ->contextFactory , 'contextInstances ' , []);
66- $ this ->objectManager -> get (FeedbackCollection::class)->reset ();
55+ $ this ->getObject (FeedbackCollection::class)->reset ();
6756 $ this ->objectManager ->forgetInstance (ContentDimensionRepository::class);
6857 $ this ->objectManager ->forgetInstance (NodeTypeManager::class);
6958 }
7059
60+ /**
61+ * @template T of object
62+ * @param class-string<T> $className
63+ *
64+ * @return T
65+ */
66+ final protected function getObject (string $ className ): object
67+ {
68+ return $ this ->objectManager ->get ($ className );
69+ }
70+
7171 private function setupContentRepository (): void
7272 {
7373 // Create an environment to create nodes.
74- $ this ->objectManager -> get (ContentDimensionRepository::class)->setDimensionsConfiguration ([]);
74+ $ this ->getObject (ContentDimensionRepository::class)->setDimensionsConfiguration ([]);
7575
7676 $ liveWorkspace = new Workspace ('live ' );
77- $ workspaceRepository = $ this ->objectManager -> get (WorkspaceRepository::class);
77+ $ workspaceRepository = $ this ->getObject (WorkspaceRepository::class);
7878 $ workspaceRepository ->add ($ liveWorkspace );
7979
8080 $ testSite = new Site ('test-site ' );
8181 $ testSite ->setSiteResourcesPackageKey ('Test.Site ' );
82- $ siteRepository = $ this ->objectManager -> get (SiteRepository::class);
82+ $ siteRepository = $ this ->getObject (SiteRepository::class);
8383 $ siteRepository ->add ($ testSite );
8484
8585 $ this ->persistenceManager ->persistAll ();
86- $ this ->contextFactory = $ this ->objectManager -> get (ContextFactoryInterface::class);
86+ $ this ->contextFactory = $ this ->getObject (ContextFactoryInterface::class);
8787 $ subgraph = $ this ->contextFactory ->create (['workspaceName ' => 'live ' ]);
8888
8989 $ rootNode = $ subgraph ->getRootNode ();
9090
9191 $ sitesRootNode = $ rootNode ->createNode ('sites ' );
9292 $ testSiteNode = $ sitesRootNode ->createNode ('test-site ' );
93- $ this -> homePageNode = $ testSiteNode ->createNode (
93+ $ testSiteNode ->createNode (
9494 'homepage ' ,
9595 $ this ->nodeTypeManager ->getNodeType ('Flowpack.NodeTemplates:Document.HomePage ' )
9696 );
@@ -99,7 +99,7 @@ private function setupContentRepository(): void
9999 /** @test */
100100 public function itMatchesSnapshot ()
101101 {
102- $ commandController = $ this ->objectManager -> get (NodeTemplateCommandController::class);
102+ $ commandController = $ this ->getObject (NodeTemplateCommandController::class);
103103
104104 ObjectAccess::setProperty ($ commandController , 'response ' , $ cliResponse = new Response (), true );
105105 ObjectAccess::getProperty ($ commandController , 'output ' , true )->setOutput ($ bufferedOutput = new BufferedOutput ());
0 commit comments