@@ -131,7 +131,7 @@ public function testCloneReferenceableRemoveExisting()
131131 * Clone a referenceable node, then clone again with removeExisting = false
132132 * This should cause an exception, even with a corresponding node (same UUID)
133133 *
134- * @expectedException \PHPCR\ItemExistsException
134+ * @expectedException \PHPCR\ItemExistsException
135135 */
136136 public function testCloneReferenceableNoRemoveExisting ()
137137 {
@@ -157,7 +157,7 @@ public function testCloneReferenceableNoRemoveExisting()
157157 * Even though the second clone is to a new location, because a corresponding node (same UUID)
158158 * already exists in the destination workspace, an exception should still be thrown.
159159 *
160- * @expectedException \PHPCR\ItemExistsException
160+ * @expectedException \PHPCR\ItemExistsException
161161 */
162162 public function testCloneNoRemoveExistingNewLocation ()
163163 {
@@ -179,12 +179,35 @@ public function testCloneNoRemoveExistingNewLocation()
179179 self ::$ destWs ->cloneFrom ($ this ->srcWsName , $ srcNode , $ secondDstNode , false );
180180 }
181181
182+ /**
183+ * When removing the existing corresponding target, this must work even
184+ * when the target is at the same path.
185+ */
186+ public function testExistingCorrespondingNodeRemoveExisting ()
187+ {
188+ $ this ->skipIfSameNameSiblingsSupported ();
189+
190+ $ srcNode = '/tests_write_manipulation_clone/testExistingCorrespondingNodeRemoveExisting/sourceRemoveExistingCorresponding ' ;
191+ $ dstNode = '/tests_additional_workspace/testWorkspaceCloneNonCorresponding/destRemoveExisting ' ;
192+
193+ self ::$ destWs ->cloneFrom ($ this ->srcWsName , $ srcNode , $ dstNode , true );
194+
195+ $ this ->renewDestinationSession ();
196+
197+ $ clonedReplacedNode = self ::$ destWs ->getSession ()->getNode ($ dstNode );
198+ $ this ->assertInstanceOf ('PHPCR\NodeInterface ' , $ clonedReplacedNode );
199+ $ this ->assertCount (3 , $ clonedReplacedNode ->getProperties ());
200+ $ this ->checkNodeProperty ($ clonedReplacedNode , 'jcr:uuid ' , 'f8019868-3533-4519-a077-9c8601950627 ' );
201+ $ this ->checkNodeProperty ($ clonedReplacedNode , 'jcr:primaryType ' , 'nt:unstructured ' );
202+ $ this ->checkNodeProperty ($ clonedReplacedNode , 'jcr:mixinTypes ' , array ('mix:referenceable ' ));
203+ }
204+
182205 /**
183206 * Check that we don't inadvertently create same name siblings (SNS) with removeExisting = true.
184207 * This can happen when cloning from one workspace to another, when a node already exists at the
185208 * destination but is not a corresponding node (the nodes have different UUIDs)
186209 *
187- * @expectedException \PHPCR\ItemExistsException
210+ * @expectedException \PHPCR\ItemExistsException
188211 */
189212 public function testExistingNonCorrespondingNodeRemoveExisting ()
190213 {
@@ -201,7 +224,7 @@ public function testExistingNonCorrespondingNodeRemoveExisting()
201224 * This can happen when cloning from one workspace to another, when a node already exists at the
202225 * destination but is not a corresponding node (the nodes have different UUIDs)
203226 *
204- * @expectedException \PHPCR\ItemExistsException
227+ * @expectedException \PHPCR\ItemExistsException
205228 */
206229 public function testExistingNonCorrespondingNodeNoRemoveExisting ()
207230 {
@@ -216,7 +239,7 @@ public function testExistingNonCorrespondingNodeNoRemoveExisting()
216239 /**
217240 * Test when source node is non-referenceable but a referenceable node exists at destination path
218241 *
219- * @expectedException \PHPCR\ItemExistsException
242+ * @expectedException \PHPCR\ItemExistsException
220243 */
221244 public function testReferenceableDestNodeWithNonReferenceableSourceNode ()
222245 {
@@ -229,7 +252,7 @@ public function testReferenceableDestNodeWithNonReferenceableSourceNode()
229252 }
230253
231254 /**
232- * @expectedException \PHPCR\NoSuchWorkspaceException
255+ * @expectedException \PHPCR\NoSuchWorkspaceException
233256 */
234257 public function testCloneNoSuchWorkspace ()
235258 {
@@ -240,7 +263,7 @@ public function testCloneNoSuchWorkspace()
240263 }
241264
242265 /**
243- * @expectedException \PHPCR\RepositoryException
266+ * @expectedException \PHPCR\RepositoryException
244267 */
245268 public function testCloneRelativePaths ()
246269 {
@@ -251,7 +274,7 @@ public function testCloneRelativePaths()
251274 }
252275
253276 /**
254- * @expectedException \PHPCR\RepositoryException
277+ * @expectedException \PHPCR\RepositoryException
255278 */
256279 public function testCloneInvalidDstPath ()
257280 {
@@ -262,7 +285,7 @@ public function testCloneInvalidDstPath()
262285 }
263286
264287 /**
265- * @expectedException \PHPCR\PathNotFoundException
288+ * @expectedException \PHPCR\PathNotFoundException
266289 */
267290 public function testCloneProperty ()
268291 {
@@ -273,7 +296,7 @@ public function testCloneProperty()
273296 }
274297
275298 /**
276- * @expectedException \PHPCR\PathNotFoundException
299+ * @expectedException \PHPCR\PathNotFoundException
277300 */
278301 public function testCloneSrcNotFound ()
279302 {
@@ -284,7 +307,7 @@ public function testCloneSrcNotFound()
284307 }
285308
286309 /**
287- * @expectedException \PHPCR\PathNotFoundException
310+ * @expectedException \PHPCR\PathNotFoundException
288311 */
289312 public function testCloneDstParentNotFound ()
290313 {
@@ -315,7 +338,7 @@ public function testCloneNonReferenceable()
315338 /**
316339 * Clone a non-referenceable node, then clone again with removeExisting = true
317340 *
318- * @expectedException \PHPCR\ItemExistsException
341+ * @expectedException \PHPCR\ItemExistsException
319342 */
320343 public function testCloneRemoveExistingNonReferenceable ()
321344 {
@@ -338,7 +361,7 @@ public function testCloneRemoveExistingNonReferenceable()
338361 }
339362
340363 /**
341- * @expectedException \PHPCR\ItemExistsException
364+ * @expectedException \PHPCR\ItemExistsException
342365 */
343366 public function testCloneNonReferenceableNoRemoveExisting ()
344367 {
@@ -383,7 +406,7 @@ public function testGetCorrespondingNode()
383406 }
384407
385408 /**
386- * @expectedException \PHPCR\NoSuchWorkspaceException
409+ * @expectedException \PHPCR\NoSuchWorkspaceException
387410 */
388411 public function testGetCorrespondingNodeNoSuchWorkspace ()
389412 {
@@ -397,7 +420,7 @@ public function testGetCorrespondingNodeNoSuchWorkspace()
397420 }
398421
399422 /**
400- * @expectedException \PHPCR\ItemNotFoundException
423+ * @expectedException \PHPCR\ItemNotFoundException
401424 */
402425 public function testGetCorrespondingNodeItemNotFound ()
403426 {
@@ -477,7 +500,7 @@ public function testUpdateNodeWithChildren()
477500 }
478501
479502 /**
480- * @expectedException \PHPCR\NoSuchWorkspaceException
503+ * @expectedException \PHPCR\NoSuchWorkspaceException
481504 */
482505 public function testUpdateNoSuchWorkspace ()
483506 {
0 commit comments