Skip to content

Commit 3179185

Browse files
committed
Merge pull request #117 from phpcr/query_alias_test
[WIP] added test for query alias handling
2 parents 2508158 + d09114d commit 3179185

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

tests/06_Query/QueryResultsTest.php

+25
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,31 @@ public function testGetColumnNames()
4848
$this->assertEquals($columnNamesExpected, $columnNames);
4949
}
5050

51+
public function testGetAliasColumnNames()
52+
{
53+
$query = $this->sharedFixture['qm']->createQuery("
54+
SELECT [jcr:mimeType] AS bar, stringToCompare as foo, [nt:unstructured].longNumberToCompare, ding
55+
FROM [nt:unstructured]
56+
WHERE stringToCompare IS NOT NULL
57+
",
58+
\PHPCR\Query\QueryInterface::JCR_SQL2
59+
);
60+
$qr = $query->execute();
61+
62+
$columnNames = $qr->getColumnNames();
63+
sort($columnNames); //order is not determined
64+
$columnNamesExpected = array('bar', 'ding', 'foo', 'nt:unstructured.longNumberToCompare');
65+
$this->assertEquals($columnNamesExpected, $columnNames);
66+
67+
foreach ($qr->getRows() as $row) {
68+
$this->assertNotNull($row->getValue('bar'));
69+
$this->assertNotNull($row->getValue('foo'));
70+
$this->assertNotNull($row->getValue('longNumberToCompare'));
71+
$this->assertEquals('', $row->getValue('ding'));
72+
}
73+
74+
}
75+
5176
public function testGetNodes()
5277
{
5378
$nodes = $this->qr->getNodes();

0 commit comments

Comments
 (0)