Skip to content

Commit 5eab291

Browse files
committed
Added test for maintaining references after copying
1 parent a8071d7 commit 5eab291

File tree

2 files changed

+96
-7
lines changed

2 files changed

+96
-7
lines changed

fixtures/10_Writing/copy.xml

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,69 @@
276276
</sv:property>
277277
</sv:node>
278278
</sv:node>
279+
280+
<sv:node sv:name="testCopyUpdateReferrersSingleValue">
281+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
282+
<sv:value>nt:unstructured</sv:value>
283+
</sv:property>
284+
<sv:node sv:name="referencedNode">
285+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
286+
<sv:value>nt:unstructured</sv:value>
287+
</sv:property>
288+
<sv:property sv:name="jcr:mixinTypes" sv:type="Name">
289+
<sv:value>mix:referenceable</sv:value>
290+
</sv:property>
291+
<sv:property sv:name="jcr:uuid" sv:type="String">
292+
<sv:value>00000000-0000-0000-0000-000000000010</sv:value>
293+
</sv:property>
294+
</sv:node>
295+
<sv:node sv:name="srcNode">
296+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
297+
<sv:value>nt:unstructured</sv:value>
298+
</sv:property>
299+
<sv:property sv:name="reference" sv:type="Reference">
300+
<sv:value>00000000-0000-0000-0000-000000000010</sv:value>
301+
</sv:property>
302+
</sv:node>
303+
</sv:node>
304+
305+
<sv:node sv:name="testCopyUpdateReferrersMultiValue">
306+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
307+
<sv:value>nt:unstructured</sv:value>
308+
</sv:property>
309+
<sv:node sv:name="referencedNode1">
310+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
311+
<sv:value>nt:unstructured</sv:value>
312+
</sv:property>
313+
<sv:property sv:name="jcr:mixinTypes" sv:type="Name">
314+
<sv:value>mix:referenceable</sv:value>
315+
</sv:property>
316+
<sv:property sv:name="jcr:uuid" sv:type="String">
317+
<sv:value>00000000-0000-0000-0000-000000000012</sv:value>
318+
</sv:property>
319+
</sv:node>
320+
<sv:node sv:name="referencedNode2">
321+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
322+
<sv:value>nt:unstructured</sv:value>
323+
</sv:property>
324+
<sv:property sv:name="jcr:mixinTypes" sv:type="Name">
325+
<sv:value>mix:referenceable</sv:value>
326+
</sv:property>
327+
<sv:property sv:name="jcr:uuid" sv:type="String">
328+
<sv:value>00000000-0000-0000-0000-000000000013</sv:value>
329+
</sv:property>
330+
</sv:node>
331+
<sv:node sv:name="srcNode">
332+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
333+
<sv:value>nt:unstructured</sv:value>
334+
</sv:property>
335+
<sv:property sv:name="reference" sv:type="Reference" sv:multiple="true">
336+
<sv:value>00000000-0000-0000-0000-000000000012</sv:value>
337+
<sv:value>00000000-0000-0000-0000-000000000013</sv:value>
338+
</sv:property>
339+
</sv:node>
340+
</sv:node>
341+
279342
<sv:node sv:name="testCopyNoUpdateOnCopy">
280343
<sv:property sv:name="jcr:primaryType" sv:type="Name">
281344
<sv:value>nt:unstructured</sv:value>

tests/10_Writing/CopyMethodsTest.php

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,16 +186,42 @@ public function testCopyNoUpdateOnCopy()
186186
$this->ws->copy($src, $dst);
187187
}
188188

189-
public function testCopyUpdateOnCopy()
189+
/**
190+
* Copied nodes which reference other nodes should be shown in the referrers list of references
191+
* Single value
192+
*/
193+
public function testCopyUpdateReferencesSingleValue()
190194
{
191-
$src = '/tests_write_manipulation_copy/testCopyUpdateOnCopy/srcNode';
192-
$dst = '/tests_write_manipulation_copy/testCopyUpdateOnCopy/dstNode/srcNode';
195+
$src = '/tests_write_manipulation_copy/testCopyUpdateReferrersSingleValue/srcNode';
196+
$dst = '/tests_write_manipulation_copy/testCopyUpdateReferrersSingleValue/dstNode';
197+
$ref = '/tests_write_manipulation_copy/testCopyUpdateReferrersSingleValue/referencedNode';
198+
193199
$this->ws->copy($src, $dst);
200+
$this->session->refresh(true );
194201

195-
// make sure child node was copied
196-
$this->assertTrue($this->session->nodeExists($dst.'/srcFile'));
197-
// make sure things were updated
198-
$this->assertEquals('123', $this->session->getProperty($dst.'/updateFile/jcr:data')->getValue());
202+
$node = $this->session->getNode($ref);
203+
$references = $node->getReferences();
204+
205+
$this->assertCount(2, $references);
199206
}
200207

208+
/**
209+
* Copied nodes which reference other nodes should be shown in the referrers list of references
210+
* Multi-value
211+
*/
212+
public function testCopyUpdateReferencesMultiValue()
213+
{
214+
$src = '/tests_write_manipulation_copy/testCopyUpdateReferrersMultiValue/srcNode';
215+
$dst = '/tests_write_manipulation_copy/testCopyUpdateReferrersMultiValue/dstNode';
216+
$ref1 = '/tests_write_manipulation_copy/testCopyUpdateReferrersMultiValue/referencedNode1';
217+
$ref2 = '/tests_write_manipulation_copy/testCopyUpdateReferrersMultiValue/referencedNode2';
218+
219+
$this->ws->copy($src, $dst);
220+
$this->session->refresh(true);
221+
222+
$node = $this->session->getNode($ref1);
223+
$references = $node->getReferences();
224+
225+
$this->assertCount(2, $references);
226+
}
201227
}

0 commit comments

Comments
 (0)