Skip to content

Commit 022ce50

Browse files
author
Willem-Jan Zijderveld
committed
Added some tests to validate literals with backslashes and quotes
1 parent a381562 commit 022ce50

File tree

2 files changed

+81
-0
lines changed

2 files changed

+81
-0
lines changed

fixtures/general/base.xml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,4 +376,41 @@
376376
</sv:node>
377377
</sv:node>
378378

379+
<sv:node sv:name="propertyCharacterComparison">
380+
381+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
382+
<sv:value>nt:file</sv:value>
383+
</sv:property>
384+
385+
<sv:property sv:name="jcr:created" sv:type="Date">
386+
<sv:value>2011-03-21T14:34:20.452+01:00</sv:value>
387+
</sv:property>
388+
389+
<sv:property sv:name="jcr:createdBy" sv:type="String">
390+
<sv:value>admin</sv:value>
391+
</sv:property>
392+
393+
<sv:node sv:name="jcr:content">
394+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
395+
<sv:value>nt:unstructured</sv:value>
396+
</sv:property>
397+
398+
<sv:property sv:name="jcr:lastModified" sv:type="Date">
399+
<sv:value>2009-04-27T13:01:07.472+02:00</sv:value>
400+
</sv:property>
401+
402+
<sv:property sv:name="jcr:mimeType" sv:type="String">
403+
<sv:value>text/plain</sv:value>
404+
</sv:property>
405+
406+
<sv:property sv:name="class" sv:type="String">
407+
<sv:value>PHPCR\Query\QueryInterface</sv:value>
408+
</sv:property>
409+
410+
<sv:property sv:name="quotes" sv:type="String">
411+
<sv:value>"'</sv:value>
412+
</sv:property>
413+
</sv:node>
414+
</sv:node>
415+
379416
</sv:node>

tests/06_Query/QuerySql2OperationsTest.php

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

4+
use Jackalope\Query\QueryManager;
45
use PHPCR\Query\QueryInterface;
56

67
require_once('QueryBaseCase.php');
@@ -292,4 +293,47 @@ public function testQueryMultiValuedProperty()
292293
$this->assertSame('foo bar', $rows->current()->getValue('tags'));
293294
}
294295

296+
/**
297+
* Using /tests_general_base/propertyCharacterComparison/jcr:content
298+
*/
299+
public function testPropertyWithBackslash()
300+
{
301+
/** @var QueryManager $queryManager */
302+
$queryManager = $this->sharedFixture['qm'];
303+
$query = $queryManager->createQuery('
304+
SELECT data.class
305+
FROM [nt:unstructured] AS data
306+
WHERE data.class = "PHPCR\Query\QueryInterface"',
307+
QueryInterface::JCR_SQL2
308+
);
309+
310+
$result = $query->execute();
311+
312+
$rows = $result->getRows();
313+
$this->assertCount(1, $rows);
314+
$this->assertEquals('PHPCR\\Query\\QueryInterface', $rows->current()->getValue('class'));
315+
}
316+
317+
/**
318+
* Using /tests_general_base/propertyCharacterComparison/jcr:content
319+
*/
320+
public function testPropertyWithQuotes()
321+
{
322+
/** @var QueryManager $queryManager */
323+
$queryManager = $this->sharedFixture['qm'];
324+
$query = $queryManager->createQuery('
325+
SELECT data.quotes
326+
FROM [nt:unstructured] AS data
327+
WHERE data.quotes = "\\"\'"
328+
',
329+
QueryInterface::JCR_SQL2
330+
);
331+
332+
$result = $query->execute();
333+
334+
$rows = $result->getRows();
335+
$this->assertCount(1, $rows);
336+
$this->assertEquals('"\'', $rows->current()->getValue('quotes'));
337+
}
338+
295339
}

0 commit comments

Comments
 (0)