Skip to content

Commit ca986fe

Browse files
committed
add tests about QOM with spaces in paths
1 parent 95c7e7f commit ca986fe

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

tests/06_Query/QOM/QomToSql2ConverterTest.php

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,20 @@ public function testSameNodeJoin()
8686
$condition = new QOM\SameNodeJoinCondition('sel1', 'sel2');
8787
$this->assertQuery($this->queries['6.7.9.SameNodeJoinCondition.Simple'], $this->factory->join($left, $right, Constants::JCR_JOIN_TYPE_INNER, $condition));
8888

89-
//TODO: should path be surronded by quotes?
9089
$condition = new QOM\SameNodeJoinCondition('sel1', 'sel2', '/home');
9190
$this->assertQuery($this->queries['6.7.9.SameNodeJoinCondition.Path'], $this->factory->join($left, $right, Constants::JCR_JOIN_TYPE_INNER, $condition));
91+
}
92+
93+
/**
94+
* 6.7.9. SameNodeJoinCondition with space in path
95+
*/
96+
public function testSameNodeJoinSpace()
97+
{
98+
$left = $this->factory->selector('nt:file');
99+
$right = $this->factory->selector('nt:folder');
92100

101+
$condition = new QOM\SameNodeJoinCondition('sel1', 'sel2', '/home node');
102+
$this->assertQuery($this->queries['6.7.9.SameNodeJoinCondition.Path_Space'], $this->factory->join($left, $right, Constants::JCR_JOIN_TYPE_INNER, $condition));
93103
}
94104

95105
/**
@@ -188,6 +198,16 @@ public function testSameNode()
188198
$this->assertQuery($this->queries['6.7.20.SameNode.Selector'], $selector, array(), $this->factory->sameNode('/home', 'sel1'), array());
189199
}
190200

201+
/**
202+
* 6.7.20. SameNode with space in path
203+
*/
204+
public function testSameNodeSpace()
205+
{
206+
$selector = $this->factory->selector('nt:file');
207+
$this->assertQuery($this->queries['6.7.20.SameNode.Simple_Space'], $selector, array(), $this->factory->sameNode('/home node'), array());
208+
$this->assertQuery($this->queries['6.7.20.SameNode.Selector_Space'], $selector, array(), $this->factory->sameNode('/home node', 'sel1'), array());
209+
}
210+
191211
/**
192212
* 6.7.21. ChildNode
193213
*/
@@ -198,6 +218,16 @@ public function testChildNode()
198218
$this->assertQuery($this->queries['6.7.21.ChildNode.Selector'], $selector, array(), $this->factory->childNode('/home', 'sel1'), array());
199219
}
200220

221+
/**
222+
* 6.7.21. ChildNode with space in path
223+
*/
224+
public function testChildNodeSpace()
225+
{
226+
$selector = $this->factory->selector('nt:file');
227+
$this->assertQuery($this->queries['6.7.21.ChildNode.Simple_Space'], $selector, array(), $this->factory->childNode('/home node'), array());
228+
$this->assertQuery($this->queries['6.7.21.ChildNode.Selector_Space'], $selector, array(), $this->factory->childNode('/home node', 'sel1'), array());
229+
}
230+
201231
/**
202232
* 6.7.22. DescendantNode
203233
*/
@@ -208,6 +238,16 @@ public function testDescendantNode()
208238
$this->assertQuery($this->queries['6.7.22.DescendantNode.Selector'], $selector, array(), $this->factory->descendantNode('/home', 'sel1'), array());
209239
}
210240

241+
/**
242+
* 6.7.22. DescendantNode with space in path
243+
*/
244+
public function testDescendantNodeSpace()
245+
{
246+
$selector = $this->factory->selector('nt:file');
247+
$this->assertQuery($this->queries['6.7.22.DescendantNode.Simple_Space'], $selector, array(), $this->factory->descendantNode('/home node'), array());
248+
$this->assertQuery($this->queries['6.7.22.DescendantNode.Selector_Space'], $selector, array(), $this->factory->descendantNode('/home node', 'sel1'), array());
249+
}
250+
211251
/**
212252
* 6.7.23. Path
213253
*/

tests/06_Query/QOM/Sql2TestQueries.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public static function getQueries() {
3131
*/
3232
$queries['6.7.9.SameNodeJoinCondition.Simple'] = 'SELECT * FROM [nt:file] INNER JOIN [nt:folder] ON ISSAMENODE(sel1, sel2)';
3333
$queries['6.7.9.SameNodeJoinCondition.Path'] = 'SELECT * FROM [nt:file] INNER JOIN [nt:folder] ON ISSAMENODE(sel1, sel2, [/home])';
34+
$queries['6.7.9.SameNodeJoinCondition.Path_Space'] = 'SELECT * FROM [nt:file] INNER JOIN [nt:folder] ON ISSAMENODE(sel1, sel2, ["/home node"])';
3435

3536
/**
3637
* 6.7.10 ChildNodeJoinCondition
@@ -77,18 +78,24 @@ public static function getQueries() {
7778
*/
7879
$queries['6.7.20.SameNode.Simple'] = 'SELECT * FROM [nt:file] WHERE ISSAMENODE([/home])';
7980
$queries['6.7.20.SameNode.Selector'] = 'SELECT * FROM [nt:file] WHERE ISSAMENODE(sel1, [/home])';
81+
$queries['6.7.20.SameNode.Simple_Space'] = 'SELECT * FROM [nt:file] WHERE ISSAMENODE(["/home node"])';
82+
$queries['6.7.20.SameNode.Selector_Space'] = 'SELECT * FROM [nt:file] WHERE ISSAMENODE(sel1, ["/home node"])';
8083

8184
/**
8285
* 6.7.21. ChildNode
8386
*/
8487
$queries['6.7.21.ChildNode.Simple'] = 'SELECT * FROM [nt:file] WHERE ISCHILDNODE([/home])';
8588
$queries['6.7.21.ChildNode.Selector'] = 'SELECT * FROM [nt:file] WHERE ISCHILDNODE(sel1, [/home])';
89+
$queries['6.7.21.ChildNode.Simple_Space'] = 'SELECT * FROM [nt:file] WHERE ISCHILDNODE(["/home node"])';
90+
$queries['6.7.21.ChildNode.Selector_Space'] = 'SELECT * FROM [nt:file] WHERE ISCHILDNODE(sel1, ["/home node"])';
8691

8792
/**
8893
* 6.7.22. DescendantNode
8994
*/
9095
$queries['6.7.22.DescendantNode.Simple'] = 'SELECT * FROM [nt:file] WHERE ISDESCENDANTNODE([/home])';
9196
$queries['6.7.22.DescendantNode.Selector'] = 'SELECT * FROM [nt:file] WHERE ISDESCENDANTNODE(sel1, [/home])';
97+
$queries['6.7.22.DescendantNode.Simple_Space'] = 'SELECT * FROM [nt:file] WHERE ISDESCENDANTNODE(["/home node"])';
98+
$queries['6.7.22.DescendantNode.Selector_Space'] = 'SELECT * FROM [nt:file] WHERE ISDESCENDANTNODE(sel1, ["/home node"])';
9299

93100
/**
94101
* 6.7.27. ProperyValue

0 commit comments

Comments
 (0)