1313 * source code.
1414 */
1515
16- use DateTime ;
1716use DateTimeImmutable ;
1817use Exception ;
1918use Flowpack \ElasticSearch \ContentRepositoryAdaptor \Command \NodeIndexCommandController ;
2019use Flowpack \ElasticSearch \ContentRepositoryAdaptor \Eel \ElasticSearchQueryBuilder ;
2120use Flowpack \ElasticSearch \ContentRepositoryAdaptor \Eel \ElasticSearchQueryResult ;
2221use Flowpack \ElasticSearch \ContentRepositoryAdaptor \Exception \QueryBuildingException ;
23- use Flowpack \ElasticSearch \Transfer \ Exception \ ApiException ;
22+ use Flowpack \ElasticSearch \ContentRepositoryAdaptor \ Tests \ Functional \ Traits \ ContentRepositoryNodeCreationTrait ;
2423use Neos \ContentRepository \Domain \Model \NodeInterface ;
25- use Neos \ContentRepository \Domain \Model \Workspace ;
26- use Neos \ContentRepository \Domain \Repository \NodeDataRepository ;
27- use Neos \ContentRepository \Domain \Repository \WorkspaceRepository ;
28- use Neos \ContentRepository \Domain \Service \Context ;
29- use Neos \ContentRepository \Domain \Service \ContextFactoryInterface ;
30- use Neos \ContentRepository \Domain \Service \NodeTypeManager ;
31- use Neos \ContentRepository \Exception \NodeExistsException ;
32- use Neos \ContentRepository \Exception \NodeTypeNotFoundException ;
33- use Neos \Flow \Cli \Exception \StopCommandException ;
34- use Neos \Flow \Mvc \Exception \StopActionException ;
3524use Neos \Flow \Persistence \QueryResultInterface ;
3625use Neos \Flow \Tests \FunctionalTestCase ;
3726
3827class ElasticSearchQueryTest extends FunctionalTestCase
3928{
40- /**
41- * @var WorkspaceRepository
42- */
43- protected $ workspaceRepository ;
29+ use ContentRepositoryNodeCreationTrait;
4430
4531 /**
4632 * @var NodeIndexCommandController
4733 */
4834 protected $ nodeIndexCommandController ;
4935
50- /**
51- * @var Context
52- */
53- protected $ context ;
54-
55- /**
56- * @var NodeInterface
57- */
58- protected $ siteNode ;
59-
6036 /**
6137 * @var boolean
6238 */
6339 protected static $ testablePersistenceEnabled = true ;
6440
65- /**
66- * @var ContextFactoryInterface
67- */
68- protected $ contextFactory ;
69-
70- /**
71- * @var NodeTypeManager
72- */
73- protected $ nodeTypeManager ;
74-
75- /**
76- * @var NodeDataRepository
77- */
78- protected $ nodeDataRepository ;
79-
8041 /**
8142 * @var boolean
8243 */
@@ -85,27 +46,13 @@ class ElasticSearchQueryTest extends FunctionalTestCase
8546 public function setUp (): void
8647 {
8748 parent ::setUp ();
88- $ this ->workspaceRepository = $ this ->objectManager ->get (WorkspaceRepository::class);
89- $ liveWorkspace = new Workspace ('live ' );
90- $ this ->workspaceRepository ->add ($ liveWorkspace );
91-
92- $ this ->nodeTypeManager = $ this ->objectManager ->get (NodeTypeManager::class);
93- $ this ->contextFactory = $ this ->objectManager ->get (ContextFactoryInterface::class);
94- $ this ->context = $ this ->contextFactory ->create ([
95- 'workspaceName ' => 'live ' ,
96- 'dimensions ' => ['language ' => ['en_US ' ]],
97- 'targetDimensions ' => ['language ' => 'en_US ' ]
98- ]);
99- $ rootNode = $ this ->context ->getRootNode ();
100-
101- $ this ->siteNode = $ rootNode ->createNode ('welcome ' , $ this ->nodeTypeManager ->getNodeType ('Neos.NodeTypes:Page ' ));
102- $ this ->siteNode ->setProperty ('title ' , 'welcome ' );
103-
104- $ this ->nodeDataRepository = $ this ->objectManager ->get (NodeDataRepository::class);
49+ $ this ->setupContentRepository ();
10550
10651 $ this ->nodeIndexCommandController = $ this ->objectManager ->get (NodeIndexCommandController::class);
10752
10853 $ this ->createNodesForNodeSearchTest ();
54+ sleep (2 );
55+ $ this ->indexNodes ();
10956 }
11057
11158 public function tearDown (): void
@@ -394,52 +341,8 @@ protected function getLogMessagePrefix(string $method): string
394341 return substr (strrchr ($ method , '\\' ), 1 );
395342 }
396343
397- /**
398- * Creates some sample nodes to run tests against
399- *
400- * @throws NodeExistsException
401- * @throws NodeTypeNotFoundException
402- * @throws StopActionException
403- * @throws \Flowpack\ElasticSearch\ContentRepositoryAdaptor\Exception
404- * @throws ApiException
405- * @throws StopCommandException
406- */
407- protected function createNodesForNodeSearchTest (): void
344+ protected function indexNodes (): void
408345 {
409- $ newDocumentNode1 = $ this ->siteNode ->createNode ('test-node-1 ' , $ this ->nodeTypeManager ->getNodeType ('Neos.NodeTypes:Page ' ));
410- $ newDocumentNode1 ->setProperty ('title ' , 'chicken ' );
411- $ newDocumentNode1 ->setProperty ('title_analyzed ' , 'chicken ' );
412-
413- $ newContentNode1 = $ newDocumentNode1 ->getNode ('main ' )->createNode ('document-1-text-1 ' , $ this ->nodeTypeManager ->getNodeType ('Neos.NodeTypes:Text ' ));
414- $ newContentNode1 ->setProperty ('text ' , 'A Scout smiles and whistles under all circumstances. ' );
415-
416- $ newDocumentNode2 = $ this ->siteNode ->createNode ('test-node-2 ' , $ this ->nodeTypeManager ->getNodeType ('Neos.NodeTypes:Page ' ));
417- $ newDocumentNode2 ->setProperty ('title ' , 'chicken ' );
418- $ newDocumentNode2 ->setProperty ('title_analyzed ' , 'chicken ' );
419-
420- // Nodes for cacheLifetime test
421- $ newContentNode2 = $ newDocumentNode2 ->getNode ('main ' )->createNode ('document-2-text-1 ' , $ this ->nodeTypeManager ->getNodeType ('Neos.NodeTypes:Text ' ));
422- $ newContentNode2 ->setProperty ('text ' , 'Hidden after 2025-01-01 ' );
423- $ newContentNode2 ->setHiddenAfterDateTime (new DateTime ('@1735686000 ' ));
424- $ newContentNode3 = $ newDocumentNode2 ->getNode ('main ' )->createNode ('document-2-text-2 ' , $ this ->nodeTypeManager ->getNodeType ('Neos.NodeTypes:Text ' ));
425- $ newContentNode3 ->setProperty ('text ' , 'Hidden before 2018-07-18 ' );
426- $ newContentNode3 ->setHiddenBeforeDateTime (new DateTime ('@1531864800 ' ));
427-
428- $ newDocumentNode3 = $ this ->siteNode ->createNode ('test-node-3 ' , $ this ->nodeTypeManager ->getNodeType ('Neos.NodeTypes:Page ' ));
429- $ newDocumentNode3 ->setProperty ('title ' , 'egg ' );
430- $ newDocumentNode3 ->setProperty ('title_analyzed ' , 'egg ' );
431-
432- $ dimensionContext = $ this ->contextFactory ->create ([
433- 'workspaceName ' => 'live ' ,
434- 'dimensions ' => ['language ' => ['de ' ]]
435- ]);
436- $ translatedNode3 = $ dimensionContext ->adoptNode ($ newDocumentNode3 , true );
437- $ translatedNode3 ->setProperty ('title ' , 'De ' );
438-
439- $ this ->persistenceManager ->persistAll ();
440-
441- sleep (2 );
442-
443346 if (self ::$ indexInitialized === true ) {
444347 return ;
445348 }
0 commit comments