public function testOrder($nodes, $orderBy, $expectedOrder)
{
$rootNode = $this->session->getNode('/');
foreach ($nodes as $nodeName => $nodeProperties) {
$node = $rootNode->addNode($nodeName);
foreach ($nodeProperties as $name => $value) {
$node->setProperty($name, $value);
}
}
$this->session->save();
$qm = $this->session->getWorkspace()->getQueryManager();
$query = $qm->createQuery('SELECT * FROM [nt:unstructured] WHERE value IS NOT NULL ORDER BY ' . $orderBy, \PHPCR\Query\QueryInterface::JCR_SQL2);
$result = $query->execute();
$rows = $result->getRows();
$this->assertGreaterThan(0, count($rows));
foreach ($rows as $index => $row) {
$path = $row->getNode()->getPath();
$name = PathHelper::getNodeName($path);
$expectedName = $expectedOrder[$index];
$this->assertEquals($expectedName, $name);
}
}