Error using "children" or "find" operation in functionnal test

Hello,

I want to do a functionnal test using “children” or “find” operation.
The test looks like :

/**
* @test
*/
public function myTest()
{
$rootNode = $this->nodeDataRepository->findByIdentifier(‘d245107b-c9e3-4072-9ba0-3fed8a48f2c1’);

    $pages = (new FlowQuery([$rootNode]))->children("[instanceof Neos.Neos:Document]")->get();
    \Neos\Flow\var_dump(count($pages));
    //TODO rest of test
}

But i’ve got an error

There was 1 error:

  1. TC\NeosSiteStarter\Tests\Functional\FlowQueryOperations\TestOperationTest::myTest
    Neos\Eel\FlowQuery\FizzleException: children() must have a property name filter and cannot only have an attribute filter.

/Volumes/www/tc-neos-starter/Data/Temporary/Testing/Cache/Code/Flow_Object_Classes/Neos_Eel_FlowQuery_Operations_Object_ChildrenOperation.php:79
/Volumes/www/tc-neos-starter/Data/Temporary/Testing/Cache/Code/Flow_Object_Classes/Neos_Eel_FlowQuery_FlowQuery.php:203
/Volumes/www/tc-neos-starter/Data/Temporary/Testing/Cache/Code/Flow_Object_Classes/Neos_Eel_FlowQuery_FlowQuery.php:156
/Volumes/www/tc-neos-starter/Packages/Sites/TC.NeosSiteStarter/Tests/Functionnal/FlowQueryOperations/TestOperationTest.php:76
/Volumes/www/tc-neos-starter/Packages/Libraries/phpunit/phpunit/phpunit:47

ERRORS!
Tests: 1, Assertions: 0, Errors: 1.

Does anybody already have this kind of problem ?
Thank you :slight_smile:

Best regards

Khang Doan

The NodeData object is not a Node and doesn’T fullfill the NodeInterface you need a CR Context object and ideally the NodeFactory and create an actual Node object from your NodeData before using it in FlowQuery.

@doank I can show you an example:

// get context
$context = $this->contextFactory->create(array('workspaceName' => 'live', 'currentDateTime' => new \Neos\Flow\Utility\Now(), 'dimensions' => array(), 'invisibleContentShown' => FALSE, 'removedContentShown' => FALSE, 'inaccessibleContentShown' => FALSE));

// get root node
$rootNode = $context->getRootNode();

/*
//or you can get the root node by an identifier
$nodeIdentifier = 'd245107b-c9e3-4072-9ba0-3fed8a48f2c1';
$rootNode = $context->getNodeByIdentifier($nodeIdentifier);
*/

$pages = (new \Neos\Eel\FlowQuery\FlowQuery([$rootNode]))
            ->find('[instanceof Neos.Neos:Document]')
            ->context(array('workspaceName' => 'live'))
            ->get();