Skip to content

Commit 4440573

Browse files
bitpetrdbu
authored andcommitted
added test for testing binary data of children nodes
1 parent 287c2a9 commit 4440573

File tree

2 files changed

+46
-0
lines changed

2 files changed

+46
-0
lines changed

fixtures/10_Writing/copy.xml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,4 +484,22 @@
484484
</sv:node>
485485
</sv:node>
486486
</sv:node>
487+
488+
<sv:node sv:name="testCopyChildrenBinaryData">
489+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
490+
<sv:value>nt:unstructured</sv:value>
491+
</sv:property>
492+
<sv:node sv:name="srcNode">
493+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
494+
<sv:value>nt:unstructured</sv:value>
495+
</sv:property>
496+
<sv:node sv:name="data.bin">
497+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
498+
<sv:value>nt:unstructured</sv:value>
499+
</sv:property>
500+
<sv:property sv:name="jcr:data" sv:type="Binary"><sv:value>RnVzY2UgZmVybWVudHVtLiBBbGlxdWFtIGxvYm9ydGlzLiBNYXVyaXMgdHVycGlzIG51bmMsIGJsYW5kaXQgZXQsIHZvbHV0cGF0IG1vbGVzdGllLCBwb3J0YSB1dCwgbGlndWxhLiBQZWxsZW50ZXNxdWUgYXVjdG9yIG5lcXVlIG5lYyB1cm5hLiBQcm9pbiBtYWduYS4gQ3VyYWJpdHVyIHVsbGFtY29ycGVyIHVsdHJpY2llcyBuaXNpLiBQcmFlc2VudCBjb25ndWUgZXJhdCBhdCBtYXNzYS4gTmFtIGFkaXBpc2NpbmcuIE51bGxhIHBvcnRhIGRvbG9yLiBGdXNjZSBjb21tb2RvIGFsaXF1YW0gYXJjdS4=</sv:value>
501+
</sv:property>
502+
</sv:node>
503+
</sv:node>
504+
</sv:node>
487505
</sv:node>

tests/Writing/CopyMethodsTest.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,4 +239,32 @@ public function testCopyUpdateReferencesMultiValue()
239239

240240
$this->assertCount(2, $references);
241241
}
242+
243+
/**
244+
* Verifies that transport::copy actually copies binary data of children nodes
245+
*/
246+
public function testCopyChildrenBinaryData()
247+
{
248+
$src = '/tests_write_manipulation_copy/testCopyChildrenBinaryData/srcNode';
249+
$dst = '/tests_write_manipulation_copy/testCopyChildrenBinaryData/dstNode';
250+
251+
$this->ws->copy($src, $dst);
252+
$this->session->refresh(true);
253+
$srcChild = $this->session->getNode($src.'/data.bin');
254+
$dstChild = $this->session->getNode($dst.'/data.bin');
255+
256+
$srcProp = $srcChild->getProperty('jcr:data');
257+
$dstProp = $dstChild->getProperty('jcr:data');
258+
259+
$this->assertEquals(\PHPCR\PropertyType::BINARY, $srcProp->getType());
260+
$this->assertEquals(\PHPCR\PropertyType::BINARY, $dstProp->getType());
261+
262+
$srcBin = $srcProp->getBinary();
263+
$dstBin = $dstProp->getBinary();
264+
265+
$this->assertTrue(is_resource($srcBin), 'Failed to get src binary stream');
266+
$this->assertTrue(is_resource($dstBin), 'Failed to get dst binary stream');
267+
268+
$this->assertEquals(stream_get_contents($srcBin), stream_get_contents($dstBin));
269+
}
242270
}

0 commit comments

Comments
 (0)