From 5eab2915436782015e71197e36b243f05d536e1d Mon Sep 17 00:00:00 2001 From: dantleech Date: Tue, 24 Mar 2015 15:00:29 +0000 Subject: [PATCH 1/2] Added test for maintaining references after copying --- fixtures/10_Writing/copy.xml | 63 ++++++++++++++++++++++++++++ tests/10_Writing/CopyMethodsTest.php | 40 ++++++++++++++---- 2 files changed, 96 insertions(+), 7 deletions(-) diff --git a/fixtures/10_Writing/copy.xml b/fixtures/10_Writing/copy.xml index f62bd253..ff5152ca 100644 --- a/fixtures/10_Writing/copy.xml +++ b/fixtures/10_Writing/copy.xml @@ -276,6 +276,69 @@ + + + + nt:unstructured + + + + nt:unstructured + + + mix:referenceable + + + 00000000-0000-0000-0000-000000000010 + + + + + nt:unstructured + + + 00000000-0000-0000-0000-000000000010 + + + + + + + nt:unstructured + + + + nt:unstructured + + + mix:referenceable + + + 00000000-0000-0000-0000-000000000012 + + + + + nt:unstructured + + + mix:referenceable + + + 00000000-0000-0000-0000-000000000013 + + + + + nt:unstructured + + + 00000000-0000-0000-0000-000000000012 + 00000000-0000-0000-0000-000000000013 + + + + nt:unstructured diff --git a/tests/10_Writing/CopyMethodsTest.php b/tests/10_Writing/CopyMethodsTest.php index 9fdd2ae4..c053e901 100644 --- a/tests/10_Writing/CopyMethodsTest.php +++ b/tests/10_Writing/CopyMethodsTest.php @@ -186,16 +186,42 @@ public function testCopyNoUpdateOnCopy() $this->ws->copy($src, $dst); } - public function testCopyUpdateOnCopy() + /** + * Copied nodes which reference other nodes should be shown in the referrers list of references + * Single value + */ + public function testCopyUpdateReferencesSingleValue() { - $src = '/tests_write_manipulation_copy/testCopyUpdateOnCopy/srcNode'; - $dst = '/tests_write_manipulation_copy/testCopyUpdateOnCopy/dstNode/srcNode'; + $src = '/tests_write_manipulation_copy/testCopyUpdateReferrersSingleValue/srcNode'; + $dst = '/tests_write_manipulation_copy/testCopyUpdateReferrersSingleValue/dstNode'; + $ref = '/tests_write_manipulation_copy/testCopyUpdateReferrersSingleValue/referencedNode'; + $this->ws->copy($src, $dst); + $this->session->refresh(true ); - // make sure child node was copied - $this->assertTrue($this->session->nodeExists($dst.'/srcFile')); - // make sure things were updated - $this->assertEquals('123', $this->session->getProperty($dst.'/updateFile/jcr:data')->getValue()); + $node = $this->session->getNode($ref); + $references = $node->getReferences(); + + $this->assertCount(2, $references); } + /** + * Copied nodes which reference other nodes should be shown in the referrers list of references + * Multi-value + */ + public function testCopyUpdateReferencesMultiValue() + { + $src = '/tests_write_manipulation_copy/testCopyUpdateReferrersMultiValue/srcNode'; + $dst = '/tests_write_manipulation_copy/testCopyUpdateReferrersMultiValue/dstNode'; + $ref1 = '/tests_write_manipulation_copy/testCopyUpdateReferrersMultiValue/referencedNode1'; + $ref2 = '/tests_write_manipulation_copy/testCopyUpdateReferrersMultiValue/referencedNode2'; + + $this->ws->copy($src, $dst); + $this->session->refresh(true); + + $node = $this->session->getNode($ref1); + $references = $node->getReferences(); + + $this->assertCount(2, $references); + } } From a1c72fc5fdae71c8ff19e72941e42ff739e8fe98 Mon Sep 17 00:00:00 2001 From: dantleech Date: Sun, 12 Apr 2015 07:22:16 +0200 Subject: [PATCH 2/2] Updated test --- tests/10_Writing/CopyMethodsTest.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/tests/10_Writing/CopyMethodsTest.php b/tests/10_Writing/CopyMethodsTest.php index c053e901..9febb4e8 100644 --- a/tests/10_Writing/CopyMethodsTest.php +++ b/tests/10_Writing/CopyMethodsTest.php @@ -187,8 +187,7 @@ public function testCopyNoUpdateOnCopy() } /** - * Copied nodes which reference other nodes should be shown in the referrers list of references - * Single value + * When a node is copied, any nodes to which it refers should show the copied node in its list of references. */ public function testCopyUpdateReferencesSingleValue() { @@ -196,7 +195,15 @@ public function testCopyUpdateReferencesSingleValue() $dst = '/tests_write_manipulation_copy/testCopyUpdateReferrersSingleValue/dstNode'; $ref = '/tests_write_manipulation_copy/testCopyUpdateReferrersSingleValue/referencedNode'; + $node = $this->session->getNode($ref); + $references = $node->getReferences(); + $this->assertCount(1, $references); + $this->ws->copy($src, $dst); + + $references = $node->getReferences(); + $this->assertCount(2, $references); + $this->session->refresh(true ); $node = $this->session->getNode($ref);