Skip to content

more tests for multivalue binary operations #168

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion fixtures/10_Writing/copy.xml
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>nt:unstructured</sv:value>
</sv:property>
<sv:node sv:name="data.bin">
<sv:node sv:name="single">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>nt:unstructured</sv:value>
</sv:property>
Expand All @@ -502,4 +502,22 @@
</sv:node>
</sv:node>
</sv:node>

<sv:node sv:name="testCopyChildrenBinaryDataMultivalue">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>nt:unstructured</sv:value>
</sv:property>
<sv:node sv:name="srcNode">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>nt:unstructured</sv:value>
</sv:property>
<sv:node sv:name="multiple">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>nt:unstructured</sv:value>
</sv:property>
<sv:property sv:name="jcr:data" sv:type="Binary" sv:multiple="true"><sv:value>RnVzY2UgZmVybWVudHVtLiBBbGlxdWFtIGxvYm9ydGlzLiBNYXVyaXMgdHVycGlzIG51bmMsIGJsYW5kaXQgZXQsIHZvbHV0cGF0IG1vbGVzdGllLCBwb3J0YSB1dCwgbGlndWxhLiBQZWxsZW50ZXNxdWUgYXVjdG9yIG5lcXVlIG5lYyB1cm5hLiBQcm9pbiBtYWduYS4gQ3VyYWJpdHVyIHVsbGFtY29ycGVyIHVsdHJpY2llcyBuaXNpLiBQcmFlc2VudCBjb25ndWUgZXJhdCBhdCBtYXNzYS4gTmFtIGFkaXBpc2NpbmcuIE51bGxhIHBvcnRhIGRvbG9yLiBGdXNjZSBjb21tb2RvIGFsaXF1YW0gYXJjdS4=</sv:value><sv:value>RnVzY2UgZmVybWVudHVtLiBBbGlxdWFtIGxvYm9ydGlzLiBNYXVyaXMgdHVycGlzIG51bmMsIGJsYW5kaXQgZXQsIHZvbHV0cGF0IG1vbGVzdGllLCBwb3J0YSB1dCwgbGlndWxhLiBQZWxsZW50ZXNxdWUgYXVjdG9yIG5lcXVlIG5lYyB1cm5hLiBQcm9pbiBtYWduYS4gQ3VyYWJpdHVyIHVsbGFtY29ycGVyIHVsdHJpY2llcyBuaXNpLiBQcmFlc2VudCBjb25ndWUgZXJhdCBhdCBtYXNzYS4gTmFtIGFkaXBpc2NpbmcuIE51bGxhIHBvcnRhIGRvbG9yLiBGdXNjZSBjb21tb2RvIGFsaXF1YW0gYXJjdS4=</sv:value>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you just add two values here to make sure jackrabbit gets it correctly? lets put one <sv:value> per line.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a sorry, its 2 already. can you just reformat to make it readable please?

</sv:property>
</sv:node>
</sv:node>
</sv:node>
</sv:node>
5 changes: 5 additions & 0 deletions fixtures/general/base.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@
<sv:value>aDEuIENoYXB0ZXIgMSBUaXRsZQoKKiBmb28KKiBiYXIKKiogZm9vMgoqKiBmb28zCiogZm9vMAoKfHwgaGVhZGVyIHx8IGJhciB8fAp8IGggfCBqIHwKCntjb2RlfQpoZWxsbyB3b3JsZAp7Y29kZX0KCiMgZm9vCg==</sv:value>
<sv:value>aDEuIENoYXB0ZXIgMSBUaXRsZQoKKiBmb28KKiBiYXIKKiogZm9vMgoqKiBmb28zCiogZm9vMAoKfHwgaGVhZGVyIHx8IGJhciB8fAp8IGggfCBqIHwKCntjb2RlfQpoZWxsbyB3b3JsZAp7Y29kZX0KCiMgZm9vCg==</sv:value>
</sv:property>
<sv:property sv:name="single_multidata" sv:type="Binary" sv:multiple="true">
<sv:value></sv:value>
</sv:property>
<sv:property sv:name="empty_multidata" sv:type="Binary" sv:multiple="true">
</sv:property>
<sv:property sv:name="jcr:lastModified" sv:type="Date">
<sv:value>2009-04-27T13:01:07.472+02:00</sv:value>
</sv:property>
Expand Down
29 changes: 29 additions & 0 deletions tests/Reading/BinaryReadMethodsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,33 @@ public function testReadBinaryPathTrailingQuestionmark()
$this->assertInternalType('string', $value);
$this->assertEquals($this->decodedstring, $value);
}

/**
* Verifies that we still can read empty data from multivalue binary properties
* @group multitest
*/
public function testReadEmptyBinaryMultivalue()
{
$node = $this->session->getRootNode()->getNode('tests_general_base/index.txt/jcr:content');
$empty = $node->getProperty('empty_multidata');
$this->assertEquals(\PHPCR\PropertyType::BINARY, $empty->getType());
$emptyValue = $empty->getBinary();
$this->assertTrue(is_array($emptyValue));
$this->assertTrue(count($emptyValue) === 0);
}

/**
* Verifies that we still can read empty data from multivalue binary properties
*/
public function testReadSingleBinaryMultivalue()
{
$node = $this->session->getRootNode()->getNode('tests_general_base/index.txt/jcr:content');
$single = $node->getProperty('single_multidata');
$this->assertEquals(\PHPCR\PropertyType::BINARY, $single->getType());
$singleValue = $single->getBinary();
$this->assertTrue(is_array($singleValue));
$this->assertTrue(is_resource($singleValue[0]));
$contents = stream_get_contents($singleValue[0]);
$this->assertEquals('', $contents);
}
}
51 changes: 42 additions & 9 deletions tests/Writing/CopyMethodsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -250,21 +250,54 @@ public function testCopyChildrenBinaryData()

$this->ws->copy($src, $dst);
$this->session->refresh(true);
$srcChild = $this->session->getNode($src.'/data.bin');
$dstChild = $this->session->getNode($dst.'/data.bin');

$srcProp = $srcChild->getProperty('jcr:data');
$dstProp = $dstChild->getProperty('jcr:data');
//Single value
$srcProp = $this->session->getNode($src . '/single')->getProperty('jcr:data');
$dstProp = $this->session->getNode($dst . '/single')->getProperty('jcr:data');

$this->assertEquals(\PHPCR\PropertyType::BINARY, $srcProp->getType());
$this->assertEquals(\PHPCR\PropertyType::BINARY, $dstProp->getType());

$srcBin = $srcProp->getBinary();
$dstBin = $dstProp->getBinary();
$srcVal = $srcProp->getBinary();
$dstVal = $dstProp->getBinary();

$this->assertTrue(is_resource($srcBin), 'Failed to get src binary stream');
$this->assertTrue(is_resource($dstBin), 'Failed to get dst binary stream');
$this->assertTrue(is_resource($srcVal), 'Failed to get src binary stream');
$this->assertTrue(is_resource($dstVal), 'Failed to get dst binary stream');

$this->assertEquals(stream_get_contents($srcBin), stream_get_contents($dstBin));
$this->assertEquals(stream_get_contents($srcVal), stream_get_contents($dstVal));
}

/**
* Verifies that transport::copy actually copies binary data of children nodes
* Multivalue test
*/
public function testCopyChildrenBinaryDataMultivalue()
{
$src = '/tests_write_manipulation_copy/testCopyChildrenBinaryDataMultivalue/srcNode';
$dst = '/tests_write_manipulation_copy/testCopyChildrenBinaryDataMultivalue/dstNode';

$this->ws->copy($src, $dst);
$this->session->refresh(true);

//Multivalue
$srcProp = $this->session->getNode($src.'/multiple')->getProperty('jcr:data');
$dstProp = $this->session->getNode($dst.'/multiple')->getProperty('jcr:data');

$this->assertEquals(\PHPCR\PropertyType::BINARY, $srcProp->getType());
$this->assertEquals(\PHPCR\PropertyType::BINARY, $dstProp->getType());

$srcVal = $srcProp->getValue();
$dstVal = $dstProp->getValue();

$this->assertTrue(is_array($srcVal), 'Failed to get src value');
$this->assertTrue(is_array($dstVal), 'Failed to get dst value');

$this->assertTrue(is_resource($srcVal[0]));
$this->assertTrue(is_resource($srcVal[1]));
$this->assertTrue(is_resource($dstVal[0]));
$this->assertTrue(is_resource($dstVal[1]));

$this->assertEquals(stream_get_contents($srcVal[0]), stream_get_contents($dstVal[0]));
$this->assertEquals(stream_get_contents($srcVal[1]), stream_get_contents($dstVal[1]));
}
}