Skip to content

Commit ba30e9f

Browse files
committed
Merge branch 'master' into cnd-parser
2 parents a431df5 + 5ce38c9 commit ba30e9f

File tree

10 files changed

+462
-130
lines changed

10 files changed

+462
-130
lines changed

fixtures/general/base.xml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,9 @@
280280
<sv:property sv:name="thisIsNo" sv:type="Boolean">
281281
<sv:value>false</sv:value>
282282
</sv:property>
283+
<sv:property sv:name="thisIsYes" sv:type="Boolean">
284+
<sv:value>true</sv:value>
285+
</sv:property>
283286
<sv:property sv:name="multiBoolean" sv:type="Boolean" sv:multiple="true">
284287
<sv:value>false</sv:value>
285288
<sv:value>true</sv:value>
@@ -291,4 +294,83 @@
291294

292295
</sv:node>
293296
</sv:node>
297+
298+
<sv:node sv:name="NumberPropertyNodeToCompare1">
299+
300+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
301+
<sv:value>nt:file</sv:value>
302+
</sv:property>
303+
304+
<sv:property sv:name="jcr:created" sv:type="Date">
305+
<sv:value>2011-03-21T14:34:20.452+01:00</sv:value>
306+
</sv:property>
307+
308+
<sv:property sv:name="jcr:createdBy" sv:type="String">
309+
<sv:value>admin</sv:value>
310+
</sv:property>
311+
312+
<sv:node sv:name="jcr:content">
313+
314+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
315+
<sv:value>nt:unstructured</sv:value>
316+
</sv:property>
317+
318+
<sv:property sv:name="jcr:lastModified" sv:type="Date">
319+
<sv:value>2009-04-27T13:01:07.472+02:00</sv:value>
320+
</sv:property>
321+
322+
<sv:property sv:name="jcr:mimeType" sv:type="String">
323+
<sv:value>text/plain</sv:value>
324+
</sv:property>
325+
326+
<sv:property sv:name="longNumberToCompare" sv:type="Long">
327+
<sv:value>2</sv:value>
328+
</sv:property>
329+
330+
<sv:property sv:name="stringToCompare" sv:type="String">
331+
<sv:value>2</sv:value>
332+
</sv:property>
333+
334+
</sv:node>
335+
</sv:node>
336+
337+
<sv:node sv:name="NumberPropertyNodeToCompare2">
338+
339+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
340+
<sv:value>nt:file</sv:value>
341+
</sv:property>
342+
343+
<sv:property sv:name="jcr:created" sv:type="Date">
344+
<sv:value>2011-03-21T14:34:20.452+01:00</sv:value>
345+
</sv:property>
346+
347+
<sv:property sv:name="jcr:createdBy" sv:type="String">
348+
<sv:value>admin</sv:value>
349+
</sv:property>
350+
351+
<sv:node sv:name="jcr:content">
352+
353+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
354+
<sv:value>nt:unstructured</sv:value>
355+
</sv:property>
356+
357+
<sv:property sv:name="jcr:lastModified" sv:type="Date">
358+
<sv:value>2009-04-27T13:01:07.472+02:00</sv:value>
359+
</sv:property>
360+
361+
<sv:property sv:name="jcr:mimeType" sv:type="String">
362+
<sv:value>text/plain</sv:value>
363+
</sv:property>
364+
365+
<sv:property sv:name="longNumberToCompare" sv:type="Long">
366+
<sv:value>10</sv:value>
367+
</sv:property>
368+
369+
<sv:property sv:name="stringToCompare" sv:type="String">
370+
<sv:value>10</sv:value>
371+
</sv:property>
372+
373+
</sv:node>
374+
</sv:node>
375+
294376
</sv:node>

inc/BaseCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ protected function setUp()
113113
$test = "$case::".$this->getName();
114114

115115
if (! self::$loader->getTestSupported($chapter, $case, $test)) {
116-
$this->markTestSkipped('Feature not supported by this implementation');
116+
$this->markTestSkipped('Test ' . $this->getName() . ' not supported by this implementation');
117117
}
118118

119119
$this->sharedFixture = self::$staticSharedFixture;

tests/06_Query/QueryResultsTest.php

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,18 @@
11
<?php
22
namespace PHPCR\Tests\Query;
33

4+
use PHPCR\Query\QueryResultInterface;
5+
46
require_once('QueryBaseCase.php');
57

68
/**
79
* $ 6.11 QueryResult - Test the query result object
810
*/
911
class QueryResultsTest extends QueryBaseCase
1012
{
13+
/** @var QueryResultInterface */
14+
protected $qr;
15+
1116
public static $expect = array("jcr:createdBy","jcr:created","jcr:primaryType","jcr:path","jcr:score");
1217

1318
public function setUp()
@@ -109,4 +114,69 @@ public function testReadPropertyContentFromResults()
109114
$this->assertEquals('jcr:uuid', $prop->getName());
110115
$this->assertEquals('14e18ef3-be20-4985-bee9-7bb4763b31de', $prop->getString());
111116
}
117+
118+
public function testCompareNumberFields()
119+
{
120+
$query = $this->sharedFixture['qm']->createQuery(
121+
'SELECT data.longNumberToCompare FROM [nt:unstructured] AS data WHERE data.longNumberToCompare > 2',
122+
\PHPCR\Query\QueryInterface::JCR_SQL2
123+
);
124+
$result = $query->execute();
125+
126+
$rows = array();
127+
foreach ($result->getRows() as $row) {
128+
$rows[] = $row;
129+
}
130+
131+
$this->assertEquals(1, count($rows));
132+
$this->assertEquals(10, $rows[0]->getValue('data.longNumberToCompare'));
133+
}
134+
135+
public function testCompareStringFields()
136+
{
137+
$query = $this->sharedFixture['qm']->createQuery(
138+
'SELECT data.stringToCompare FROM [nt:unstructured] AS data WHERE data.stringToCompare > "10"',
139+
\PHPCR\Query\QueryInterface::JCR_SQL2
140+
);
141+
$result = $query->execute();
142+
143+
$rows = array();
144+
foreach ($result->getRows() as $row) {
145+
$rows[] = $row;
146+
}
147+
148+
$this->assertEquals(1, count($rows));
149+
$this->assertEquals(2, $rows[0]->getValue('data.stringToCompare'));
150+
}
151+
152+
public function testBooleanField()
153+
{
154+
$query = $this->sharedFixture['qm']->createQuery(
155+
'SELECT data.thisIsNo FROM [nt:unstructured] as data WHERE data.thisIsNo = false',
156+
\PHPCR\Query\QueryInterface::JCR_SQL2
157+
);
158+
$result = $query->execute();
159+
160+
$rows = array();
161+
foreach ($result->getRows() as $row) {
162+
$rows[] = $row;
163+
}
164+
165+
$this->assertEquals(1, count($rows));
166+
$this->assertEquals(false, $rows[0]->getValue('data.thisIsNo'));
167+
168+
$query = $this->sharedFixture['qm']->createQuery(
169+
'SELECT data.thisIsYes FROM [nt:unstructured] as data WHERE data.thisIsYes = true',
170+
\PHPCR\Query\QueryInterface::JCR_SQL2
171+
);
172+
$result = $query->execute();
173+
174+
$rows = array();
175+
foreach ($result->getRows() as $row) {
176+
$rows[] = $row;
177+
}
178+
179+
$this->assertEquals(1, count($rows));
180+
$this->assertEquals(true, $rows[0]->getValue('data.thisIsYes'));
181+
}
112182
}

tests/06_Query/QuerySql2OperationsTest.php

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22
namespace PHPCR\Tests\Query;
33

4+
use PHPCR\Query\QueryInterface;
5+
46
require_once('QueryBaseCase.php');
57

68
/**
@@ -10,9 +12,10 @@ class QuerySql2OperationsTest extends QueryBaseCase
1012
{
1113
public function testQueryField()
1214
{
15+
/** @var $query QueryInterface */
1316
$query = $this->sharedFixture['qm']->createQuery(
1417
'SELECT foo FROM [nt:unstructured] WHERE foo = "bar"',
15-
\PHPCR\Query\QueryInterface::JCR_SQL2
18+
QueryInterface::JCR_SQL2
1619
);
1720

1821
$this->assertInstanceOf('\PHPCR\Query\QueryInterface', $query);
@@ -33,9 +36,10 @@ public function testQueryField()
3336

3437
public function testQueryFieldSomenull()
3538
{
39+
/** @var $query QueryInterface */
3640
$query = $this->sharedFixture['qm']->createQuery(
3741
'SELECT foo FROM [nt:unstructured]',
38-
\PHPCR\Query\QueryInterface::JCR_SQL2
42+
QueryInterface::JCR_SQL2
3943
);
4044

4145
$this->assertInstanceOf('\PHPCR\Query\QueryInterface', $query);
@@ -46,21 +50,22 @@ public function testQueryFieldSomenull()
4650
$vals[] = ($node->hasProperty('foo') ? $node->getPropertyValue('foo') : null);
4751
}
4852
$this->assertContains('bar', $vals);
49-
$this->assertEquals(8, count($vals));
53+
$this->assertEquals(10, count($vals));
5054

5155
$vals = array();
5256
foreach ($result->getRows() as $row) {
5357
$vals[] = $row->getValue('foo');
5458
}
5559
$this->assertContains('bar', $vals);
56-
$this->assertEquals(8, count($vals));
60+
$this->assertEquals(10, count($vals));
5761
}
5862

5963
public function testQueryFieldSelector()
6064
{
65+
/** @var $query QueryInterface */
6166
$query = $this->sharedFixture['qm']->createQuery(
6267
'SELECT data.foo FROM [nt:unstructured] AS data WHERE data.foo = "bar"',
63-
\PHPCR\Query\QueryInterface::JCR_SQL2
68+
QueryInterface::JCR_SQL2
6469
);
6570

6671
$this->assertInstanceOf('\PHPCR\Query\QueryInterface', $query);
@@ -75,14 +80,15 @@ public function testQueryFieldSelector()
7580

7681
public function testQueryJoin()
7782
{
83+
/** @var $query QueryInterface */
7884
$query = $this->sharedFixture['qm']->createQuery(
7985
'SELECT content.longNumber
8086
FROM [nt:file] AS file
8187
INNER JOIN [nt:unstructured] AS content
8288
ON ISDESCENDANTNODE(content, file)
8389
8490
WHERE content.longNumber = 999',
85-
\PHPCR\Query\QueryInterface::JCR_SQL2
91+
QueryInterface::JCR_SQL2
8692
);
8793

8894
$this->assertInstanceOf('\PHPCR\Query\QueryInterface', $query);
@@ -98,14 +104,15 @@ public function testQueryJoin()
98104

99105
public function testQueryJoinReference()
100106
{
107+
/** @var $query QueryInterface */
101108
$query = $this->sharedFixture['qm']->createQuery(
102109
'SELECT source.ref1, target.[jcr:uuid]
103110
FROM [nt:unstructured] AS source
104111
INNER JOIN [nt:unstructured] AS target
105112
ON source.ref1 = target.[jcr:uuid]
106113
WHERE ISCHILDNODE(source, "/tests_general_base/idExample/jcr:content")
107114
',
108-
\PHPCR\Query\QueryInterface::JCR_SQL2
115+
QueryInterface::JCR_SQL2
109116
);
110117

111118
$this->assertInstanceOf('\PHPCR\Query\QueryInterface', $query);
@@ -120,11 +127,12 @@ public function testQueryJoinReference()
120127

121128
public function testQueryOrder()
122129
{
130+
/** @var $query QueryInterface */
123131
$query = $this->sharedFixture['qm']->createQuery(
124132
'SELECT data.zeronumber
125133
FROM [nt:unstructured] AS data
126134
ORDER BY data.zeronumber',
127-
\PHPCR\Query\QueryInterface::JCR_SQL2
135+
QueryInterface::JCR_SQL2
128136
);
129137

130138
$this->assertInstanceOf('\PHPCR\Query\QueryInterface', $query);
@@ -135,19 +143,19 @@ public function testQueryOrder()
135143
$vals[] = $row->getValue('data.zeronumber');
136144
}
137145
// rows that do not have that field are null. empty is before fields with values
138-
$this->assertEquals(array(null, null, null, null, null, null, null, 0), $vals);
146+
$this->assertEquals(array(null, null, null, null, null, null, null, null, null, 0), $vals);
139147
}
140148

141149
public function testQueryMultiValuedProperty()
142150
{
143-
/** @var $query \PHPCR\Query\QueryInterface */
151+
/** @var $query QueryInterface */
144152
$query = $this->sharedFixture['qm']->createQuery(
145153
'SELECT data.tags
146154
FROM [nt:unstructured] AS data
147155
WHERE data.tags = "foo"
148156
AND data.tags = "bar"
149157
',
150-
\PHPCR\Query\QueryInterface::JCR_SQL2
158+
QueryInterface::JCR_SQL2
151159
);
152160

153161
$this->assertInstanceOf('\PHPCR\Query\QueryInterface', $query);

tests/06_Query/Sql1/QueryOperationsTest.php

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
<?php
22
namespace PHPCR\Tests\Query\Sql1;
33

4+
use PHPCR\Query\QueryInterface;
5+
46
require_once('QueryBaseCase.php');
57

68
/**
@@ -10,9 +12,10 @@ class QueryOperationsTest extends QueryBaseCase
1012
{
1113
public function testQueryField()
1214
{
15+
/** @var $query QueryInterface */
1316
$query = $this->sharedFixture['qm']->createQuery(
1417
"SELECT foo FROM nt:unstructured WHERE foo = 'bar'",
15-
\PHPCR\Query\QueryInterface::SQL
18+
QueryInterface::SQL
1619
);
1720

1821
$this->assertInstanceOf('\PHPCR\Query\QueryInterface', $query);
@@ -33,9 +36,10 @@ public function testQueryField()
3336

3437
public function testQueryFieldSomenull()
3538
{
39+
/** @var $query QueryInterface */
3640
$query = $this->sharedFixture['qm']->createQuery(
3741
'SELECT foo FROM nt:unstructured',
38-
\PHPCR\Query\QueryInterface::SQL
42+
QueryInterface::SQL
3943
);
4044

4145
$this->assertInstanceOf('\PHPCR\Query\QueryInterface', $query);
@@ -46,23 +50,24 @@ public function testQueryFieldSomenull()
4650
$vals[] = ($node->hasProperty('foo') ? $node->getPropertyValue('foo') : null);
4751
}
4852
$this->assertContains('bar', $vals);
49-
$this->assertEquals(8, count($vals));
53+
$this->assertEquals(10, count($vals));
5054

5155
$vals = array();
5256
foreach ($result->getRows() as $row) {
5357
$vals[] = $row->getValue('foo');
5458
}
5559
$this->assertContains('bar', $vals);
56-
$this->assertEquals(8, count($vals));
60+
$this->assertEquals(10, count($vals));
5761
}
5862

5963
public function testQueryOrder()
6064
{
65+
/** @var $query QueryInterface */
6166
$query = $this->sharedFixture['qm']->createQuery(
6267
'SELECT zeronumber
6368
FROM nt:unstructured
6469
ORDER BY zeronumber',
65-
\PHPCR\Query\QueryInterface::SQL
70+
QueryInterface::SQL
6671
);
6772

6873
$this->assertInstanceOf('\PHPCR\Query\QueryInterface', $query);
@@ -73,7 +78,7 @@ public function testQueryOrder()
7378
$vals[] = $row->getValue('zeronumber');
7479
}
7580
// rows that do not have that field are null. empty is before fields with values
76-
$this->assertEquals(array(null, null, null, null, null, null, null, 0), $vals);
81+
$this->assertEquals(array(null, null, null, null, null, null, null, null, null, 0), $vals);
7782
}
7883

7984
}

0 commit comments

Comments
 (0)