Skip to content

Commit 77122a3

Browse files
author
Willem-Jan Zijderveld
committed
Added more tests to test more edgecases
1 parent 562814f commit 77122a3

File tree

2 files changed

+52
-1
lines changed

2 files changed

+52
-1
lines changed

fixtures/06_Query/characters.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,17 @@
4747
<sv:value>PHPCR\Query\QueryInterface</sv:value>
4848
</sv:property>
4949

50+
<sv:property sv:name="doublebackslash" sv:type="String">
51+
<sv:value>PHPCR\\Query\\QueryInterface</sv:value>
52+
</sv:property>
53+
5054
<sv:property sv:name="quotes" sv:type="String">
5155
<sv:value>"'</sv:value>
5256
</sv:property>
57+
58+
<sv:property sv:name="quoteandbackslash" sv:type="String">
59+
<sv:value>"\'</sv:value>
60+
</sv:property>
5361
</sv:node>
5462
</sv:node>
5563
</sv:node>

tests/06_Query/CharacterTest.php

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,27 @@ public function testPropertyWithBackslash()
3636
$this->assertEquals('PHPCR\Query\QueryInterface', $rows->current()->getValue('class'));
3737
}
3838

39+
/**
40+
* Using /tests_general_base/propertyCharacterComparison/jcr:content
41+
*/
42+
public function testPropertyWithDoubleBackslash()
43+
{
44+
/** @var QueryManager $queryManager */
45+
$queryManager = $this->sharedFixture['qm'];
46+
$query = $queryManager->createQuery('
47+
SELECT data.doublebackslash
48+
FROM [nt:unstructured] AS data
49+
WHERE data.doublebackslash = "PHPCR\\\\Query\\\\QueryInterface"',
50+
QueryInterface::JCR_SQL2
51+
);
52+
53+
$result = $query->execute();
54+
55+
$rows = $result->getRows();
56+
$this->assertCount(1, $rows);
57+
$this->assertEquals('PHPCR\\\\Query\\\\QueryInterface', $rows->current()->getValue('doublebackslash'));
58+
}
59+
3960
/**
4061
* Using /tests_general_base/propertyCharacterComparison/jcr:content
4162
*/
@@ -46,7 +67,7 @@ public function testPropertyWithQuotes()
4667
$query = $queryManager->createQuery('
4768
SELECT data.quotes
4869
FROM [nt:unstructured] AS data
49-
WHERE data.quotes = "\\"\'"
70+
WHERE data.quotes = "\"\'"
5071
',
5172
QueryInterface::JCR_SQL2
5273
);
@@ -57,4 +78,26 @@ public function testPropertyWithQuotes()
5778
$this->assertCount(1, $rows);
5879
$this->assertEquals('"\'', $rows->current()->getValue('quotes'));
5980
}
81+
82+
/**
83+
* Using /tests_general_base/propertyCharacterComparison/jcr:content
84+
*/
85+
public function testPropertyWithQuotesAndBackslash()
86+
{
87+
/** @var QueryManager $queryManager */
88+
$queryManager = $this->sharedFixture['qm'];
89+
$query = $queryManager->createQuery('
90+
SELECT data.quoteandbackslash
91+
FROM [nt:unstructured] AS data
92+
WHERE data.quotes = "\\"\\\'"
93+
',
94+
QueryInterface::JCR_SQL2
95+
);
96+
97+
$result = $query->execute();
98+
99+
$rows = $result->getRows();
100+
$this->assertCount(1, $rows);
101+
$this->assertEquals('"\\\'', $rows->current()->getValue('quoteandbackslash'));
102+
}
60103
}

0 commit comments

Comments
 (0)