Skip to content

Commit ddb3de3

Browse files
committed
test with a couple of non-ascii characters
1 parent 5e005c5 commit ddb3de3

File tree

4 files changed

+176
-0
lines changed

4 files changed

+176
-0
lines changed

fixtures/05_Reading/encoding.xml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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_read_encoding">
9+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
10+
<sv:value>nt:unstructured</sv:value>
11+
</sv:property>
12+
<sv:node sv:name="testEncoding">
13+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
14+
<sv:value>nt:unstructured</sv:value>
15+
</sv:property>
16+
<sv:node sv:name="node-ä-x">
17+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
18+
<sv:value>nt:unstructured</sv:value>
19+
</sv:property>
20+
</sv:node>
21+
<sv:node sv:name="node-è-x">
22+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
23+
<sv:value>nt:unstructured</sv:value>
24+
</sv:property>
25+
</sv:node>
26+
<sv:node sv:name="node-ï-x">
27+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
28+
<sv:value>nt:unstructured</sv:value>
29+
</sv:property>
30+
</sv:node>
31+
<sv:node sv:name="node-%-x">
32+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
33+
<sv:value>nt:unstructured</sv:value>
34+
</sv:property>
35+
</sv:node>
36+
<sv:node sv:name="node-%2F-x">
37+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
38+
<sv:value>nt:unstructured</sv:value>
39+
</sv:property>
40+
</sv:node>
41+
<sv:node sv:name="node- -x">
42+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
43+
<sv:value>nt:unstructured</sv:value>
44+
</sv:property>
45+
</sv:node>
46+
<sv:node sv:name="node-ç-x">
47+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
48+
<sv:value>nt:unstructured</sv:value>
49+
</sv:property>
50+
</sv:node>
51+
<sv:node sv:name="node-&amp;-x">
52+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
53+
<sv:value>nt:unstructured</sv:value>
54+
</sv:property>
55+
</sv:node>
56+
</sv:node>
57+
</sv:node>

fixtures/10_Writing/encoding.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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_write_encoding">
9+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
10+
<sv:value>nt:unstructured</sv:value>
11+
</sv:property>
12+
<sv:node sv:name="testEncoding">
13+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
14+
<sv:value>nt:unstructured</sv:value>
15+
</sv:property>
16+
</sv:node>
17+
</sv:node>

tests/05_Reading/EncodingTest.php

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
namespace PHPCR\Tests\Reading;
3+
4+
require_once(__DIR__ . '/../../inc/BaseCase.php');
5+
6+
/**
7+
* Test javax.jcr.Node read methods (read) §5.6
8+
* With special characters.
9+
*/
10+
class EncodingTest extends \PHPCR\Test\BaseCase
11+
{
12+
13+
static public function setupBeforeClass($fixtures = '05_Reading/encoding')
14+
{
15+
parent::setupBeforeClass($fixtures);
16+
}
17+
18+
public function setUp()
19+
{
20+
parent::setUp();
21+
22+
// because of the data provider the signature will not match
23+
$this->node = $this->rootNode->getNode('tests_read_encoding')->getNode('testEncoding');
24+
}
25+
26+
/**
27+
* @dataProvider getNodeNames
28+
*/
29+
public function testEncoding($name)
30+
{
31+
$this->assertTrue($this->node->hasNode($name));
32+
$node = $this->node->getNode($name);
33+
$this->assertInstanceOf('PHPCR\NodeInterface', $node);
34+
}
35+
36+
public static function getNodeNames()
37+
{
38+
return array(
39+
array("node-ä-x"),
40+
array("node-è-x"),
41+
array("node-ï-x"),
42+
array("node-%-x"),
43+
array("node-%2F-x"),
44+
array("node- -x"),
45+
array("node-ç-x"),
46+
array("node-&-x"),
47+
);
48+
}
49+
}

tests/10_Writing/EncodingTest.php

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?php
2+
namespace PHPCR\Tests\Writing;
3+
4+
require_once(__DIR__ . '/../../inc/BaseCase.php');
5+
6+
/**
7+
* Test javax.jcr.Node read methods (read) §5.6
8+
* With special characters.
9+
*/
10+
class EncodingTest extends \PHPCR\Test\BaseCase
11+
{
12+
13+
static public function setupBeforeClass($fixtures = '10_Writing/encoding')
14+
{
15+
parent::setupBeforeClass($fixtures);
16+
}
17+
18+
public function setUp()
19+
{
20+
parent::setUp();
21+
22+
// because of the data provider the signature will not match
23+
$this->node = $this->rootNode->getNode('tests_write_encoding')->getNode('testEncoding');
24+
}
25+
26+
/**
27+
* @dataProvider getNodeNames
28+
*/
29+
public function testEncoding($name)
30+
{
31+
$node = $this->node->addNode($name);
32+
$this->assertInstanceOf('PHPCR\NodeInterface', $node);
33+
34+
$session = $this->saveAndRenewSession();
35+
$node = $session->getNode('/tests_write_encoding/testEncoding');
36+
$this->assertTrue($node->hasNode($name));
37+
$this->assertInstanceOf('PHPCR\NodeInterface', $node->getNode($name));
38+
}
39+
40+
public static function getNodeNames()
41+
{
42+
return array(
43+
array("node-ä-x"),
44+
array("node-è-x"),
45+
array("node-ï-x"),
46+
array("node-%-x"),
47+
array("node-%2F-x"),
48+
array("node- -x"),
49+
array("node-ç-x"),
50+
array("node-&-x"),
51+
);
52+
}
53+
}

0 commit comments

Comments
 (0)