2424use Flowpack \ElasticSearch \ContentRepositoryAdaptor \Tests \Functional \BaseElasticsearchContentRepositoryAdapterTest ;
2525use Flowpack \ElasticSearch \ContentRepositoryAdaptor \Tests \Functional \Traits \Assertions ;
2626use Flowpack \ElasticSearch \ContentRepositoryAdaptor \Tests \Functional \Traits \ContentRepositoryNodeCreationTrait ;
27+ use Flowpack \ElasticSearch \ContentRepositoryAdaptor \Tests \Functional \Traits \ContentRepositorySetupTrait ;
2728use Flowpack \ElasticSearch \Domain \Model \Mapping ;
2829use Flowpack \ElasticSearch \Exception ;
2930use Flowpack \ElasticSearch \Transfer \Exception \ApiException ;
3334
3435class NodeIndexerTest extends BaseElasticsearchContentRepositoryAdapterTest
3536{
36- use ContentRepositoryNodeCreationTrait, Assertions;
37+ use ContentRepositorySetupTrait, ContentRepositoryNodeCreationTrait, Assertions;
3738
3839 /**
3940 * @var NodeIndexer
@@ -107,23 +108,7 @@ public function updateIndexAlias(): void
107108 */
108109 public function indexAndDeleteNode (): void
109110 {
110- $ this ->setupContentRepository ();
111- $ this ->createNodesForNodeSearchTest ();
112- /** @var NodeInterface $testNode */
113- $ testNode = current ($ this ->siteNode ->getChildNodes ('Neos.NodeTypes:Page ' , 1 ));
114-
115- $ this ->nodeIndexer ->setDimensions ($ testNode ->getDimensions ());
116- $ this ->nodeIndexer ->getIndex ()->create ();
117-
118- $ nodeTypeMappingCollection = $ this ->nodeTypeMappingBuilder ->buildMappingInformation ($ this ->nodeIndexer ->getIndex ());
119- foreach ($ nodeTypeMappingCollection as $ mapping ) {
120- /** @var Mapping $mapping */
121- $ mapping ->apply ();
122- }
123-
124- $ this ->nodeIndexer ->indexNode ($ testNode );
125- $ this ->nodeIndexer ->flush ();
126- sleep (1 );
111+ $ testNode = $ this ->setupCrAndIndexTestNode ();
127112 self ::assertTrue ($ this ->nodeExistsInIndex ($ testNode ), 'Node was not successfully indexed. ' );
128113
129114 $ this ->nodeIndexer ->removeNode ($ testNode );
@@ -132,6 +117,17 @@ public function indexAndDeleteNode(): void
132117 self ::assertFalse ($ this ->nodeExistsInIndex ($ testNode ), 'Node still exists after delete ' );
133118 }
134119
120+ /**
121+ * @test
122+ */
123+ public function nodeMoveIsHandledCorrectly (): void
124+ {
125+ $ testNode = $ this ->setupCrAndIndexTestNode ();
126+ self ::assertTrue ($ this ->nodeExistsInIndex ($ testNode ), 'Node was not successfully indexed. ' );
127+
128+ // $testNode->moveInto();
129+ }
130+
135131 /**
136132 * @param NodeInterface $testNode
137133 * @return bool
@@ -151,4 +147,33 @@ private function nodeExistsInIndex(NodeInterface $testNode): bool
151147 $ result = $ this ->nodeIndexer ->getIndex ()->request ('GET ' , '/_search ' , [], $ query ->toArray ())->getTreatedContent ();
152148 return count (Arrays::getValueByPath ($ result , 'hits.hits ' )) === 1 ;
153149 }
150+
151+ /**
152+ * @return NodeInterface
153+ * @throws ConfigurationException
154+ * @throws Exception
155+ * @throws \Flowpack\ElasticSearch\ContentRepositoryAdaptor\Exception
156+ * @throws \Neos\Flow\Http\Exception
157+ */
158+ protected function setupCrAndIndexTestNode (): NodeInterface
159+ {
160+ $ this ->setupContentRepository ();
161+ $ this ->createNodesForNodeSearchTest ();
162+ /** @var NodeInterface $testNode */
163+ $ testNode = current ($ this ->siteNode ->getChildNodes ('Flowpack.ElasticSearch.ContentRepositoryAdaptor:Document ' , 1 ));
164+
165+ $ this ->nodeIndexer ->setDimensions ($ testNode ->getDimensions ());
166+ $ this ->nodeIndexer ->getIndex ()->create ();
167+
168+ $ nodeTypeMappingCollection = $ this ->nodeTypeMappingBuilder ->buildMappingInformation ($ this ->nodeIndexer ->getIndex ());
169+ foreach ($ nodeTypeMappingCollection as $ mapping ) {
170+ /** @var Mapping $mapping */
171+ $ mapping ->apply ();
172+ }
173+
174+ $ this ->nodeIndexer ->indexNode ($ testNode );
175+ $ this ->nodeIndexer ->flush ();
176+ sleep (1 );
177+ return $ testNode ;
178+ }
154179}
0 commit comments