Skip to content

Commit 4b01ef8

Browse files
author
Willem-Jan Zijderveld
committed
Moved to new testcase + moved fixtures
Not sure about the naming
1 parent 022ce50 commit 4b01ef8

File tree

4 files changed

+116
-81
lines changed

4 files changed

+116
-81
lines changed

fixtures/06_Query/characters.xml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<sv:node
3+
xmlns:mix="http://www.jcp.org/jcr/mix/1.0"
4+
xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
5+
xmlns:jcr="http://www.jcp.org/jcr/1.0"
6+
xmlns:sv="http://www.jcp.org/jcr/sv/1.0"
7+
8+
sv:name="tests_query_characters">
9+
10+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
11+
<sv:value>nt:unstructured</sv:value>
12+
</sv:property>
13+
14+
<sv:node sv:name="testCharacters">
15+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
16+
<sv:value>nt:unstructured</sv:value>
17+
</sv:property>
18+
19+
<sv:node sv:name="propertyCharacterComparison">
20+
21+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
22+
<sv:value>nt:file</sv:value>
23+
</sv:property>
24+
25+
<sv:property sv:name="jcr:created" sv:type="Date">
26+
<sv:value>2011-03-21T14:34:20.452+01:00</sv:value>
27+
</sv:property>
28+
29+
<sv:property sv:name="jcr:createdBy" sv:type="String">
30+
<sv:value>admin</sv:value>
31+
</sv:property>
32+
33+
<sv:node sv:name="jcr:content">
34+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
35+
<sv:value>nt:unstructured</sv:value>
36+
</sv:property>
37+
38+
<sv:property sv:name="jcr:lastModified" sv:type="Date">
39+
<sv:value>2009-04-27T13:01:07.472+02:00</sv:value>
40+
</sv:property>
41+
42+
<sv:property sv:name="jcr:mimeType" sv:type="String">
43+
<sv:value>text/plain</sv:value>
44+
</sv:property>
45+
46+
<sv:property sv:name="class" sv:type="String">
47+
<sv:value>PHPCR\Query\QueryInterface</sv:value>
48+
</sv:property>
49+
50+
<sv:property sv:name="quotes" sv:type="String">
51+
<sv:value>"'</sv:value>
52+
</sv:property>
53+
</sv:node>
54+
</sv:node>
55+
</sv:node>
56+
</sv:node>

fixtures/general/base.xml

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -376,41 +376,4 @@
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-
416379
</sv:node>

tests/06_Query/CharacterTest.php

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
<?php
2+
3+
namespace PHPCR\Tests\Query;
4+
5+
use PHPCR\Query\QueryInterface;
6+
7+
require_once(__DIR__ . '/../../inc/BaseCase.php');
8+
9+
10+
class CharacterTest extends \PHPCR\Test\BaseCase
11+
{
12+
public static function setupBeforeClass($fixtures = '06_Query/characters')
13+
{
14+
parent::setupBeforeClass($fixtures);
15+
self::$staticSharedFixture['qm'] = self::$staticSharedFixture['session']->getWorkspace()->getQueryManager();
16+
}
17+
18+
/**
19+
* Using /tests_general_base/propertyCharacterComparison/jcr:content
20+
*/
21+
public function testPropertyWithBackslash()
22+
{
23+
/** @var QueryManager $queryManager */
24+
$queryManager = $this->sharedFixture['qm'];
25+
$query = $queryManager->createQuery('
26+
SELECT data.class
27+
FROM [nt:unstructured] AS data
28+
WHERE data.class = "PHPCR\Query\QueryInterface"',
29+
QueryInterface::JCR_SQL2
30+
);
31+
32+
$result = $query->execute();
33+
34+
$rows = $result->getRows();
35+
$this->assertCount(1, $rows);
36+
$this->assertEquals('PHPCR\\Query\\QueryInterface', $rows->current()->getValue('class'));
37+
}
38+
39+
/**
40+
* Using /tests_general_base/propertyCharacterComparison/jcr:content
41+
*/
42+
public function testPropertyWithQuotes()
43+
{
44+
/** @var QueryManager $queryManager */
45+
$queryManager = $this->sharedFixture['qm'];
46+
$query = $queryManager->createQuery('
47+
SELECT data.quotes
48+
FROM [nt:unstructured] AS data
49+
WHERE data.quotes = "\\"\'"
50+
',
51+
QueryInterface::JCR_SQL2
52+
);
53+
54+
$result = $query->execute();
55+
56+
$rows = $result->getRows();
57+
$this->assertCount(1, $rows);
58+
$this->assertEquals('"\'', $rows->current()->getValue('quotes'));
59+
}
60+
}

tests/06_Query/QuerySql2OperationsTest.php

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

4-
use Jackalope\Query\QueryManager;
54
use PHPCR\Query\QueryInterface;
65

76
require_once('QueryBaseCase.php');
@@ -293,47 +292,4 @@ public function testQueryMultiValuedProperty()
293292
$this->assertSame('foo bar', $rows->current()->getValue('tags'));
294293
}
295294

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-
339295
}

0 commit comments

Comments
 (0)