Skip to content

Commit d70437a

Browse files
committed
added query tests using the node type instead of a selector alias
1 parent 54d9a61 commit d70437a

File tree

1 file changed

+48
-1
lines changed

1 file changed

+48
-1
lines changed

tests/06_Query/QuerySql2OperationsTest.php

Lines changed: 48 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function testQueryField()
3838
$this->assertEquals(array('bar'), $vals);
3939
}
4040

41-
public function testQueryFieldSomenull()
41+
public function testQueryFieldSomeNull()
4242
{
4343
/** @var $query QueryInterface */
4444
$query = $this->sharedFixture['qm']->createQuery('
@@ -68,6 +68,28 @@ public function testQueryFieldSomenull()
6868
}
6969

7070
public function testQueryFieldSelector()
71+
{
72+
/** @var $query QueryInterface */
73+
$query = $this->sharedFixture['qm']->createQuery('
74+
SELECT [nt:unstructured].foo
75+
FROM [nt:unstructured]
76+
WHERE [nt:unstructured].foo = "bar"
77+
AND ISDESCENDANTNODE([/tests_general_base])
78+
',
79+
QueryInterface::JCR_SQL2
80+
);
81+
82+
$this->assertInstanceOf('\PHPCR\Query\QueryInterface', $query);
83+
$result = $query->execute();
84+
$this->assertInstanceOf('\PHPCR\Query\QueryResultInterface', $result);
85+
$vals = array();
86+
foreach ($result->getRows() as $row) {
87+
$vals[] = $row->getValue('foo');
88+
}
89+
$this->assertEquals(array('bar'), $vals);
90+
}
91+
92+
public function testQueryFieldSelectorWithAlias()
7193
{
7294
/** @var $query QueryInterface */
7395
$query = $this->sharedFixture['qm']->createQuery('
@@ -90,6 +112,31 @@ public function testQueryFieldSelector()
90112
}
91113

92114
public function testQueryJoin()
115+
{
116+
/** @var $query QueryInterface */
117+
$query = $this->sharedFixture['qm']->createQuery('
118+
SELECT [nt:unstructured].longNumber
119+
FROM [nt:file]
120+
INNER JOIN [nt:unstructured]
121+
ON ISDESCENDANTNODE([nt:unstructured], [nt:file])
122+
WHERE [nt:unstructured].longNumber = 999
123+
AND ISDESCENDANTNODE([nt:file], [/tests_general_base])
124+
',
125+
QueryInterface::JCR_SQL2
126+
);
127+
128+
$this->assertInstanceOf('\PHPCR\Query\QueryInterface', $query);
129+
$result = $query->execute();
130+
$this->assertInstanceOf('\PHPCR\Query\QueryResultInterface', $result);
131+
$vals = array();
132+
133+
foreach($result->getRows() as $row) {
134+
$vals[] = $row->getValue('nt:unstructured.longNumber');
135+
}
136+
$this->assertEquals(array(999), $vals);
137+
}
138+
139+
public function testQueryJoinWithAlias()
93140
{
94141
/** @var $query QueryInterface */
95142
$query = $this->sharedFixture['qm']->createQuery('

0 commit comments

Comments
 (0)