Skip to content

Commit 5449471

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

File tree

2 files changed

+38
-7
lines changed

2 files changed

+38
-7
lines changed

fixtures/10_Writing/copy.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,32 @@
276276
</sv:property>
277277
</sv:node>
278278
</sv:node>
279+
280+
<sv:node sv:name="testCopyUpdateReferrers">
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+
279305
<sv:node sv:name="testCopyNoUpdateOnCopy">
280306
<sv:property sv:name="jcr:primaryType" sv:type="Name">
281307
<sv:value>nt:unstructured</sv:value>

tests/10_Writing/CopyMethodsTest.php

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,16 +186,21 @@ 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+
*/
192+
public function testCopyUpdateReferences()
190193
{
191-
$src = '/tests_write_manipulation_copy/testCopyUpdateOnCopy/srcNode';
192-
$dst = '/tests_write_manipulation_copy/testCopyUpdateOnCopy/dstNode/srcNode';
194+
$src = '/tests_write_manipulation_copy/testCopyUpdateReferrers/srcNode';
195+
$dst = '/tests_write_manipulation_copy/testCopyUpdateReferrers/dstNode';
196+
$ref = '/tests_write_manipulation_copy/testCopyUpdateReferrers/referencedNode';
197+
193198
$this->ws->copy($src, $dst);
199+
$this->session->refresh(false);
200+
$node = $this->session->getNode($ref);
201+
$references = $node->getReferences();
194202

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());
203+
$this->assertCount(2, $references);
199204
}
200205

201206
}

0 commit comments

Comments
 (0)