Skip to content

Commit 22eb61e

Browse files
committed
Merge pull request #135 from phpcr/copy_node_from_another_workspace
Copy node from another workspace
2 parents 763d63e + 453857a commit 22eb61e

File tree

3 files changed

+37
-12
lines changed

3 files changed

+37
-12
lines changed

fixtures/10_Writing/copy.xml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,11 @@
6464
</sv:property>
6565
</sv:node>
6666
</sv:node>
67+
<sv:node sv:name="testWorkspaceCopyOther">
68+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
69+
<sv:value>nt:unstructured</sv:value>
70+
</sv:property>
71+
</sv:node>
6772
<sv:node sv:name="testCopyProperty">
6873
<sv:property sv:name="jcr:primaryType" sv:type="Name">
6974
<sv:value>nt:folder</sv:value>

fixtures/general/additionalWorkspace.xml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,4 +61,17 @@
6161
</sv:property>
6262
</sv:node>
6363
</sv:node>
64+
<sv:node sv:name="testWorkspaceCopyOther">
65+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
66+
<sv:value>nt:unstructured</sv:value>
67+
</sv:property>
68+
<sv:node sv:name="node">
69+
<sv:property sv:name="jcr:primaryType" sv:type="Name">
70+
<sv:value>nt:unstructured</sv:value>
71+
</sv:property>
72+
<sv:property sv:name="x" sv:type="String">
73+
<sv:value>y</sv:value>
74+
</sv:property>
75+
</sv:node>
76+
</sv:node>
6477
</sv:node>

tests/10_Writing/CopyMethodsTest.php

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,20 @@ public function testWorkspaceCopy()
7171
$this->assertNotEquals($sfile->getPropertyValue('jcr:data'), $dfile->getPropertyValue('jcr:data'));
7272
}
7373

74+
public function testWorkspaceCopyOther()
75+
{
76+
self::$staticSharedFixture['ie']->import('general/additionalWorkspace', 'testsAdditional');
77+
$src = '/tests_additional_workspace/testWorkspaceCopyOther/node';
78+
$dst = '/tests_write_manipulation_copy/testWorkspaceCopyOther/foobar';
79+
80+
$this->ws->copy($src, $dst, self::$loader->getOtherWorkspaceName());
81+
$node = $this->session->getNode($dst);
82+
$this->assertTrue($node->hasProperty('x'));
83+
$this->assertEquals('y', $node->getPropertyValue('x'));
84+
}
85+
7486
/**
75-
* @expectedException \PHPCR\NoSuchWorkspaceException
87+
* @expectedException \PHPCR\NoSuchWorkspaceException
7688
*/
7789
public function testCopyNoSuchWorkspace()
7890
{
@@ -81,21 +93,16 @@ public function testCopyNoSuchWorkspace()
8193
$this->ws->copy($src, $dst, 'inexistentworkspace');
8294
}
8395

84-
public function testWorkspaceCopyBackend()
85-
{
86-
$this->markTestIncomplete('TODO: just do');
87-
}
88-
8996
/**
90-
* @expectedException \PHPCR\RepositoryException
97+
* @expectedException \PHPCR\RepositoryException
9198
*/
9299
public function testCopyRelativePaths()
93100
{
94101
$this->ws->copy('foo/moo', 'bar/mar');
95102
}
96103

97104
/**
98-
* @expectedException \PHPCR\RepositoryException
105+
* @expectedException \PHPCR\RepositoryException
99106
*/
100107
public function testCopyInvalidDstPath()
101108
{
@@ -105,7 +112,7 @@ public function testCopyInvalidDstPath()
105112
}
106113

107114
/**
108-
* @expectedException \PHPCR\RepositoryException
115+
* @expectedException \PHPCR\RepositoryException
109116
*/
110117
public function testCopyProperty()
111118
{
@@ -115,7 +122,7 @@ public function testCopyProperty()
115122
}
116123

117124
/**
118-
* @expectedException \PHPCR\PathNotFoundException
125+
* @expectedException \PHPCR\PathNotFoundException
119126
*/
120127
public function testCopySrcNotFound()
121128
{
@@ -125,7 +132,7 @@ public function testCopySrcNotFound()
125132
}
126133

127134
/**
128-
* @expectedException \PHPCR\PathNotFoundException
135+
* @expectedException \PHPCR\PathNotFoundException
129136
*/
130137
public function testCopyDstParentNotFound()
131138
{
@@ -137,7 +144,7 @@ public function testCopyDstParentNotFound()
137144
/**
138145
* Verifies that there is no update-on-copy if the target node already exists
139146
*
140-
* @expectedException \PHPCR\ItemExistsException
147+
* @expectedException \PHPCR\ItemExistsException
141148
*/
142149
public function testCopyNoUpdateOnCopy()
143150
{

0 commit comments

Comments
 (0)