Skip to content

Commit cc66a3d

Browse files
committed
Merge branch 'delete-node-with-reference'
2 parents d8437ef + 96d65ab commit cc66a3d

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed

fixtures/10_Writing/delete.xml

+22
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,28 @@
209209
</sv:node>
210210
</sv:node>
211211

212+
<sv:node sv:name="testDeletePreviouslyReferencedNodeInMultipleProperty">
213+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
214+
<sv:value>nt:unstructured</sv:value>
215+
</sv:property>
216+
<sv:property sv:name="reference" sv:type="Reference" sv:multiple="true">
217+
<sv:value>7aa10003-0cba-4820-a3e4-f9b1ae8126de</sv:value>
218+
<sv:value>7aa10003-0cba-4820-a3e4-f9b1ae8126de</sv:value>
219+
</sv:property>
220+
221+
<sv:node sv:name="idExample">
222+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
223+
<sv:value>nt:unstructured</sv:value>
224+
</sv:property>
225+
<sv:property sv:name="jcr:mixinTypes" sv:type="Name">
226+
<sv:value>mix:referenceable</sv:value>
227+
</sv:property>
228+
<sv:property sv:name="jcr:uuid" sv:type="String">
229+
<sv:value>7aa10003-0cba-4820-a3e4-f9b1ae8126de</sv:value>
230+
</sv:property>
231+
</sv:node>
232+
</sv:node>
233+
212234
<sv:node sv:name="testDeleteWeakReferencedNode">
213235
<sv:property sv:name="jcr:primaryType" sv:type="Name">
214236
<sv:value>nt:unstructured</sv:value>

tests/Writing/DeleteMethodsTest.php

+22
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,28 @@ public function testDeletePreviouslyReferencedNode()
450450
$this->assertFalse($this->node->hasNode($this->getName()));
451451
}
452452

453+
/**
454+
* however, if the reference is first deleted, it must be possible to
455+
* delete the node, also if it is an multiple reference property
456+
*/
457+
public function testDeletePreviouslyReferencedNodeInMultipleProperty()
458+
{
459+
//relies on the base class setup trick to have the node populated from the fixtures
460+
$this->assertInstanceOf('PHPCR\NodeInterface', $this->node);
461+
462+
// 2) Get the referencing property and delete it
463+
$sourceprop = $this->node->getProperty('reference');
464+
$sourceprop->setValue(array());
465+
466+
// 4) Load the previously referenced node and remove it
467+
$destnode = $this->node->getNode('idExample');
468+
469+
$destnode->remove();
470+
$this->saveAndRenewSession();
471+
472+
$this->assertFalse($this->node->hasNode($this->getName()));
473+
}
474+
453475
/**
454476
* it must be possible to delete a weakly referenced node.
455477
*/

0 commit comments

Comments
 (0)