/** * Tests on a tree: * * a * a1 * b * b1 (TestingNodeType) * b1a * c * * @test * @dataProvider hasOperationDataProvider() */ public function hasOperationTests(array $currentNodePaths, $subject, array $expectedNodePaths) { $nodeTypeManager = $this->objectManager->get(NodeTypeManager::class); $testNodeType1 = $nodeTypeManager->getNodeType('Neos.ContentRepository.Testing:NodeType'); $rootNode = $this->node->getNode('/'); $nodeA = $rootNode->createNode('a'); $nodeA->createNode('a1'); $nodeB = $rootNode->createNode('b'); $nodeB1 = $nodeB->createNode('b1', $testNodeType1); $nodeB1->createNode('b1a'); $rootNode->createNode('c'); $currentNodes = array(); foreach ($currentNodePaths as $currentNodePath) { $currentNodes[] = $rootNode->getNode($currentNodePath); } if (is_array($subject)) { $subjectNodes = array(); foreach ($subject as $subjectNodePath) { $subjectNodes[] = $rootNode->getNode($subjectNodePath); } $subject = $subjectNodes; } $q = new FlowQuery($currentNodes); $result = $q->has($subject)->get(); if ($expectedNodePaths === array()) { $this->assertEmpty($result); } else { foreach ($expectedNodePaths as $expectedNodePath) { $expectedNode = $rootNode->getNode($expectedNodePath); if (!in_array($expectedNode, $result)) { $this->fail(sprintf('Expected result to contain node "%s"', $expectedNodePath)); } } } }