Skip to content

Commit

Permalink
Merge branch 'delete-node-with-reference'
Browse files Browse the repository at this point in the history
  • Loading branch information
dbu committed Oct 9, 2015
2 parents d8437ef + 96d65ab commit cc66a3d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
22 changes: 22 additions & 0 deletions fixtures/10_Writing/delete.xml
Expand Up @@ -209,6 +209,28 @@
</sv:node>
</sv:node>

<sv:node sv:name="testDeletePreviouslyReferencedNodeInMultipleProperty">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>nt:unstructured</sv:value>
</sv:property>
<sv:property sv:name="reference" sv:type="Reference" sv:multiple="true">
<sv:value>7aa10003-0cba-4820-a3e4-f9b1ae8126de</sv:value>
<sv:value>7aa10003-0cba-4820-a3e4-f9b1ae8126de</sv:value>
</sv:property>

<sv:node sv:name="idExample">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>nt:unstructured</sv:value>
</sv:property>
<sv:property sv:name="jcr:mixinTypes" sv:type="Name">
<sv:value>mix:referenceable</sv:value>
</sv:property>
<sv:property sv:name="jcr:uuid" sv:type="String">
<sv:value>7aa10003-0cba-4820-a3e4-f9b1ae8126de</sv:value>
</sv:property>
</sv:node>
</sv:node>

<sv:node sv:name="testDeleteWeakReferencedNode">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
<sv:value>nt:unstructured</sv:value>
Expand Down
22 changes: 22 additions & 0 deletions tests/Writing/DeleteMethodsTest.php
Expand Up @@ -450,6 +450,28 @@ public function testDeletePreviouslyReferencedNode()
$this->assertFalse($this->node->hasNode($this->getName()));
}

/**
* however, if the reference is first deleted, it must be possible to
* delete the node, also if it is an multiple reference property
*/
public function testDeletePreviouslyReferencedNodeInMultipleProperty()
{
//relies on the base class setup trick to have the node populated from the fixtures
$this->assertInstanceOf('PHPCR\NodeInterface', $this->node);

// 2) Get the referencing property and delete it
$sourceprop = $this->node->getProperty('reference');
$sourceprop->setValue(array());

// 4) Load the previously referenced node and remove it
$destnode = $this->node->getNode('idExample');

$destnode->remove();
$this->saveAndRenewSession();

$this->assertFalse($this->node->hasNode($this->getName()));
}

/**
* it must be possible to delete a weakly referenced node.
*/
Expand Down

0 comments on commit cc66a3d

Please sign in to comment.