Skip to content

Commit

Permalink
Merge pull request #143 from phpcr/binary-path-encoding
Browse files Browse the repository at this point in the history
Add some tests for encoding issues in binary paths
  • Loading branch information
lsmith77 committed Dec 12, 2014
2 parents fb0faeb + ab7a83e commit 73ff499
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
10 changes: 10 additions & 0 deletions fixtures/05_Reading/encoding.xml
Expand Up @@ -58,5 +58,15 @@
<sv:value>nt:unstructured</sv:value>
</sv:property>
</sv:node>
<sv:node sv:name="node?">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>nt:unstructured</sv:value>
</sv:property>
</sv:node>
<sv:node sv:name="node-¢">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>nt:unstructured</sv:value>
</sv:property>
</sv:node>
</sv:node>
</sv:node>
6 changes: 6 additions & 0 deletions fixtures/general/base.xml
Expand Up @@ -43,6 +43,12 @@
<sv:property sv:name="jcr:data" sv:type="Binary">
<sv:value>aDEuIENoYXB0ZXIgMSBUaXRsZQoKKiBmb28KKiBiYXIKKiogZm9vMgoqKiBmb28zCiogZm9vMAoKfHwgaGVhZGVyIHx8IGJhciB8fAp8IGggfCBqIHwKCntjb2RlfQpoZWxsbyB3b3JsZAp7Y29kZX0KCiMgZm9vCg==</sv:value>
</sv:property>
<sv:property sv:name="encoding?%$-test" sv:type="Binary">
<sv:value>aDEuIENoYXB0ZXIgMSBUaXRsZQoKKiBmb28KKiBiYXIKKiogZm9vMgoqKiBmb28zCiogZm9vMAoKfHwgaGVhZGVyIHx8IGJhciB8fAp8IGggfCBqIHwKCntjb2RlfQpoZWxsbyB3b3JsZAp7Y29kZX0KCiMgZm9vCg==</sv:value>
</sv:property>
<sv:property sv:name="encoding?" sv:type="Binary">
<sv:value>aDEuIENoYXB0ZXIgMSBUaXRsZQoKKiBmb28KKiBiYXIKKiogZm9vMgoqKiBmb28zCiogZm9vMAoKfHwgaGVhZGVyIHx8IGJhciB8fAp8IGggfCBqIHwKCntjb2RlfQpoZWxsbyB3b3JsZAp7Y29kZX0KCiMgZm9vCg==</sv:value>
</sv:property>
<sv:property sv:name="multidata" sv:type="Binary" sv:multiple="true">
<sv:value>aDEuIENoYXB0ZXIgMSBUaXRsZQoKKiBmb28KKiBiYXIKKiogZm9vMgoqKiBmb28zCiogZm9vMAoKfHwgaGVhZGVyIHx8IGJhciB8fAp8IGggfCBqIHwKCntjb2RlfQpoZWxsbyB3b3JsZAp7Y29kZX0KCiMgZm9vCg==</sv:value>
<sv:value>aDEuIENoYXB0ZXIgMSBUaXRsZQoKKiBmb28KKiBiYXIKKiogZm9vMgoqKiBmb28zCiogZm9vMAoKfHwgaGVhZGVyIHx8IGJhciB8fAp8IGggfCBqIHwKCntjb2RlfQpoZWxsbyB3b3JsZAp7Y29kZX0KCiMgZm9vCg==</sv:value>
Expand Down
20 changes: 20 additions & 0 deletions tests/05_Reading/BinaryReadMethodsTest.php
Expand Up @@ -116,4 +116,24 @@ public function testGetLengthMultivalue()
$this->assertEquals(strlen($this->decodedstring), $size);
}
}

public function testReadBinaryPathEncoding()
{
$node = $this->session->getRootNode()->getNode('tests_general_base/index.txt/jcr:content');
$binary = $node->getProperty('encoding?%$-test');
$this->assertEquals(\PHPCR\PropertyType::BINARY, $binary->getType());
$value = $binary->getString();
$this->assertInternalType('string', $value);
$this->assertEquals($this->decodedstring, $value);
}

public function testReadBinaryPathTrailingQuestionmark()
{
$node = $this->session->getRootNode()->getNode('tests_general_base/index.txt/jcr:content');
$binary = $node->getProperty('encoding?');
$this->assertEquals(\PHPCR\PropertyType::BINARY, $binary->getType());
$value = $binary->getString();
$this->assertInternalType('string', $value);
$this->assertEquals($this->decodedstring, $value);
}
}
2 changes: 2 additions & 0 deletions tests/05_Reading/EncodingTest.php
Expand Up @@ -45,6 +45,8 @@ public static function getNodeNames()
array("node- -x"),
array("node-ç-x"),
array("node-&-x"),
array("node?"),
array("node-¢"),
);
}
}

0 comments on commit 73ff499

Please sign in to comment.