@@ -28,6 +28,8 @@ abstract class AbstractNodeTemplateTestCase extends FunctionalTestCase
2828 use WithConfigurationTrait;
2929 use FakeNodeTypeManagerTrait;
3030
31+ protected static bool $ showDisabledNodesInSubgraph = false ;
32+
3133 protected static $ testablePersistenceEnabled = true ;
3234
3335 private ContextFactoryInterface $ contextFactory ;
@@ -44,21 +46,21 @@ abstract class AbstractNodeTemplateTestCase extends FunctionalTestCase
4446
4547 private string $ fixturesDir ;
4648
47- /** @deprecated please use {@see self::getObject()} instead */
49+ /** @internal please use {@see self::getObject()} instead */
4850 protected $ objectManager ;
4951
5052 public function setUp (): void
5153 {
5254 parent ::setUp ();
5355
54- $ this ->nodeTypeManager = $ this ->objectManager -> get (NodeTypeManager::class);
56+ $ this ->nodeTypeManager = $ this ->getObject (NodeTypeManager::class);
5557
5658 $ this ->loadFakeNodeTypes ();
5759
5860 $ this ->setupContentRepository ();
59- $ this ->nodeTemplateDumper = $ this ->objectManager -> get (NodeTemplateDumper::class);
61+ $ this ->nodeTemplateDumper = $ this ->getObject (NodeTemplateDumper::class);
6062
61- $ templateFactory = $ this ->objectManager -> get (TemplateConfigurationProcessor::class);
63+ $ templateFactory = $ this ->getObject (TemplateConfigurationProcessor::class);
6264
6365 $ templateFactoryMock = $ this ->getMockBuilder (TemplateConfigurationProcessor::class)->disableOriginalConstructor ()->getMock ();
6466 $ templateFactoryMock ->expects (self ::once ())->method ('processTemplateConfiguration ' )->willReturnCallback (function (...$ args ) use ($ templateFactory ) {
@@ -76,7 +78,7 @@ public function tearDown(): void
7678 {
7779 parent ::tearDown ();
7880 $ this ->inject ($ this ->contextFactory , 'contextInstances ' , []);
79- $ this ->objectManager -> get (FeedbackCollection::class)->reset ();
81+ $ this ->getObject (FeedbackCollection::class)->reset ();
8082 $ this ->objectManager ->forgetInstance (ContentDimensionRepository::class);
8183 $ this ->objectManager ->forgetInstance (TemplateConfigurationProcessor::class);
8284 $ this ->objectManager ->forgetInstance (NodeTypeManager::class);
@@ -96,20 +98,20 @@ final protected function getObject(string $className): object
9698 private function setupContentRepository (): void
9799 {
98100 // Create an environment to create nodes.
99- $ this ->objectManager -> get (ContentDimensionRepository::class)->setDimensionsConfiguration ([]);
101+ $ this ->getObject (ContentDimensionRepository::class)->setDimensionsConfiguration ([]);
100102
101103 $ liveWorkspace = new Workspace ('live ' );
102- $ workspaceRepository = $ this ->objectManager -> get (WorkspaceRepository::class);
104+ $ workspaceRepository = $ this ->getObject (WorkspaceRepository::class);
103105 $ workspaceRepository ->add ($ liveWorkspace );
104106
105107 $ testSite = new Site ('test-site ' );
106108 $ testSite ->setSiteResourcesPackageKey ('Test.Site ' );
107- $ siteRepository = $ this ->objectManager -> get (SiteRepository::class);
109+ $ siteRepository = $ this ->getObject (SiteRepository::class);
108110 $ siteRepository ->add ($ testSite );
109111
110112 $ this ->persistenceManager ->persistAll ();
111- $ this ->contextFactory = $ this ->objectManager -> get (ContextFactoryInterface::class);
112- $ subgraph = $ this ->contextFactory ->create (['workspaceName ' => 'live ' ]);
113+ $ this ->contextFactory = $ this ->getObject (ContextFactoryInterface::class);
114+ $ subgraph = $ this ->contextFactory ->create (['workspaceName ' => 'live ' , ' invisibleContentShown ' => static :: $ showDisabledNodesInSubgraph ]);
113115
114116 $ rootNode = $ subgraph ->getRootNode ();
115117
@@ -153,7 +155,11 @@ protected function createNodeInto(NodeInterface $targetNode, string $nodeTypeNam
153155 assert ($ changeCollection instanceof ChangeCollection);
154156 $ changeCollection ->apply ();
155157
156- return $ targetNode ->getNode ('new-node ' );
158+ $ newNode = $ targetNode ->getNode ('new-node ' );
159+ if (!$ newNode ) {
160+ throw new \RuntimeException ('New node not found at expected location. Try settting $showDisabledNodesInSubgraph. ' , 1719079419 );
161+ }
162+ return $ newNode ;
157163 }
158164
159165 protected function createFakeNode (string $ nodeAggregateId ): NodeInterface
0 commit comments