Skip to content

Commit dcf379a

Browse files
committed
added multivalue copy test
1 parent 4440573 commit dcf379a

File tree

2 files changed

+61
-10
lines changed

2 files changed

+61
-10
lines changed

fixtures/10_Writing/copy.xml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@
493493
<sv:property sv:name="jcr:primaryType" sv:type="Name">
494494
<sv:value>nt:unstructured</sv:value>
495495
</sv:property>
496-
<sv:node sv:name="data.bin">
496+
<sv:node sv:name="single">
497497
<sv:property sv:name="jcr:primaryType" sv:type="Name">
498498
<sv:value>nt:unstructured</sv:value>
499499
</sv:property>
@@ -502,4 +502,22 @@
502502
</sv:node>
503503
</sv:node>
504504
</sv:node>
505+
506+
<sv:node sv:name="testCopyChildrenBinaryDataMultivalue">
507+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
508+
<sv:value>nt:unstructured</sv:value>
509+
</sv:property>
510+
<sv:node sv:name="srcNode">
511+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
512+
<sv:value>nt:unstructured</sv:value>
513+
</sv:property>
514+
<sv:node sv:name="multiple">
515+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
516+
<sv:value>nt:unstructured</sv:value>
517+
</sv:property>
518+
<sv:property sv:name="jcr:data" sv:type="Binary" sv:multiple="true"><sv:value>RnVzY2UgZmVybWVudHVtLiBBbGlxdWFtIGxvYm9ydGlzLiBNYXVyaXMgdHVycGlzIG51bmMsIGJsYW5kaXQgZXQsIHZvbHV0cGF0IG1vbGVzdGllLCBwb3J0YSB1dCwgbGlndWxhLiBQZWxsZW50ZXNxdWUgYXVjdG9yIG5lcXVlIG5lYyB1cm5hLiBQcm9pbiBtYWduYS4gQ3VyYWJpdHVyIHVsbGFtY29ycGVyIHVsdHJpY2llcyBuaXNpLiBQcmFlc2VudCBjb25ndWUgZXJhdCBhdCBtYXNzYS4gTmFtIGFkaXBpc2NpbmcuIE51bGxhIHBvcnRhIGRvbG9yLiBGdXNjZSBjb21tb2RvIGFsaXF1YW0gYXJjdS4=</sv:value><sv:value>RnVzY2UgZmVybWVudHVtLiBBbGlxdWFtIGxvYm9ydGlzLiBNYXVyaXMgdHVycGlzIG51bmMsIGJsYW5kaXQgZXQsIHZvbHV0cGF0IG1vbGVzdGllLCBwb3J0YSB1dCwgbGlndWxhLiBQZWxsZW50ZXNxdWUgYXVjdG9yIG5lcXVlIG5lYyB1cm5hLiBQcm9pbiBtYWduYS4gQ3VyYWJpdHVyIHVsbGFtY29ycGVyIHVsdHJpY2llcyBuaXNpLiBQcmFlc2VudCBjb25ndWUgZXJhdCBhdCBtYXNzYS4gTmFtIGFkaXBpc2NpbmcuIE51bGxhIHBvcnRhIGRvbG9yLiBGdXNjZSBjb21tb2RvIGFsaXF1YW0gYXJjdS4=</sv:value>
519+
</sv:property>
520+
</sv:node>
521+
</sv:node>
522+
</sv:node>
505523
</sv:node>

tests/Writing/CopyMethodsTest.php

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -250,21 +250,54 @@ public function testCopyChildrenBinaryData()
250250

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

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

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

262-
$srcBin = $srcProp->getBinary();
263-
$dstBin = $dstProp->getBinary();
261+
$srcVal = $srcProp->getBinary();
262+
$dstVal = $dstProp->getBinary();
264263

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

268-
$this->assertEquals(stream_get_contents($srcBin), stream_get_contents($dstBin));
267+
$this->assertEquals(stream_get_contents($srcVal), stream_get_contents($dstVal));
268+
}
269+
270+
/**
271+
* Verifies that transport::copy actually copies binary data of children nodes
272+
* Multivalue test
273+
*/
274+
public function testCopyChildrenBinaryDataMultivalue()
275+
{
276+
$src = '/tests_write_manipulation_copy/testCopyChildrenBinaryDataMultivalue/srcNode';
277+
$dst = '/tests_write_manipulation_copy/testCopyChildrenBinaryDataMultivalue/dstNode';
278+
279+
$this->ws->copy($src, $dst);
280+
$this->session->refresh(true);
281+
282+
//Multivalue
283+
$srcProp = $this->session->getNode($src.'/multiple')->getProperty('jcr:data');
284+
$dstProp = $this->session->getNode($dst.'/multiple')->getProperty('jcr:data');
285+
286+
$this->assertEquals(\PHPCR\PropertyType::BINARY, $srcProp->getType());
287+
$this->assertEquals(\PHPCR\PropertyType::BINARY, $dstProp->getType());
288+
289+
$srcVal = $srcProp->getValue();
290+
$dstVal = $dstProp->getValue();
291+
292+
$this->assertTrue(is_array($srcVal), 'Failed to get src value');
293+
$this->assertTrue(is_array($dstVal), 'Failed to get dst value');
294+
295+
$this->assertTrue(is_resource($srcVal[0]));
296+
$this->assertTrue(is_resource($srcVal[1]));
297+
$this->assertTrue(is_resource($dstVal[0]));
298+
$this->assertTrue(is_resource($dstVal[1]));
299+
300+
$this->assertEquals(stream_get_contents($srcVal[0]), stream_get_contents($dstVal[0]));
301+
$this->assertEquals(stream_get_contents($srcVal[1]), stream_get_contents($dstVal[1]));
269302
}
270303
}

0 commit comments

Comments
 (0)