@@ -21,20 +21,29 @@ class HttpCopyTest extends DAVServerTest
2121     */ 
2222    public  function  setUpTree ()
2323    {
24-         $ this tree  = new  Mock \Collection ('root ' , [
24+         $ propsCollectionnew  Mock \PropertiesCollection ('propscoll ' , [
25+             'file3 '  => 'content3 ' ,
26+             'file4 '  => 'content4 ' ,
27+         ], [
28+             'my-prop '  => 'my-value ' ,
29+         ]);
30+         $ propsCollectionfailMode  = 'updatepropstrue ' ;
31+         $ this tree  = new  Mock \PropertiesCollection ('root ' , [
2532            'file1 '  => 'content1 ' ,
2633            'file2 '  => 'content2 ' ,
27-             'coll1 '  => [
34+             'coll1 '  => new   Mock \ Collection ( ' coll1 ' ,  [
2835                'file3 '  => 'content3 ' ,
2936                'file4 '  => 'content4 ' ,
30-             ],
37+             ]),
38+             'propscoll '  => $ propsCollection
3139        ]);
3240    }
3341
3442    public  function  testCopyFile ()
3543    {
3644        $ requestnew  HTTP \Request ('COPY ' , '/file1 ' , [
3745            'Destination '  => '/file5 ' ,
46+             'Depth '  => 'infinity ' ,
3847        ]);
3948        $ response$ this request ($ request
4049        self ::assertEquals (201 , $ responsegetStatus ());
@@ -54,6 +63,7 @@ public function testCopyFileToExisting()
5463    {
5564        $ requestnew  HTTP \Request ('COPY ' , '/file1 ' , [
5665            'Destination '  => '/file2 ' ,
66+             'Depth '  => 'infinity ' ,
5767        ]);
5868        $ response$ this request ($ request
5969        self ::assertEquals (204 , $ responsegetStatus ());
@@ -64,6 +74,7 @@ public function testCopyFileToExistingOverwriteT()
6474    {
6575        $ requestnew  HTTP \Request ('COPY ' , '/file1 ' , [
6676            'Destination '  => '/file2 ' ,
77+             'Depth '  => 'infinity ' ,
6778            'Overwrite '  => 'T ' ,
6879        ]);
6980        $ response$ this request ($ request
@@ -75,6 +86,7 @@ public function testCopyFileToExistingOverwriteBadValue()
7586    {
7687        $ requestnew  HTTP \Request ('COPY ' , '/file1 ' , [
7788            'Destination '  => '/file2 ' ,
89+             'Depth '  => 'infinity ' ,
7890            'Overwrite '  => 'B ' ,
7991        ]);
8092        $ response$ this request ($ request
@@ -85,6 +97,7 @@ public function testCopyFileNonExistantParent()
8597    {
8698        $ requestnew  HTTP \Request ('COPY ' , '/file1 ' , [
8799            'Destination '  => '/notfound/file2 ' ,
100+             'Depth '  => 'infinity ' ,
88101        ]);
89102        $ response$ this request ($ request
90103        self ::assertEquals (409 , $ responsegetStatus ());
@@ -94,6 +107,7 @@ public function testCopyFileToExistingOverwriteF()
94107    {
95108        $ requestnew  HTTP \Request ('COPY ' , '/file1 ' , [
96109            'Destination '  => '/file2 ' ,
110+             'Depth '  => 'infinity ' ,
97111            'Overwrite '  => 'F ' ,
98112        ]);
99113        $ response$ this request ($ request
@@ -110,6 +124,7 @@ public function testCopyFileToExistinBlockedCreateDestination()
110124        });
111125        $ requestnew  HTTP \Request ('COPY ' , '/file1 ' , [
112126            'Destination '  => '/file2 ' ,
127+             'Depth '  => 'infinity ' ,
113128            'Overwrite '  => 'T ' ,
114129        ]);
115130        $ response$ this request ($ request
@@ -122,16 +137,39 @@ public function testCopyColl()
122137    {
123138        $ requestnew  HTTP \Request ('COPY ' , '/coll1 ' , [
124139            'Destination '  => '/coll2 ' ,
140+             'Depth '  => 'infinity ' ,
125141        ]);
126142        $ response$ this request ($ request
127143        self ::assertEquals (201 , $ responsegetStatus ());
128144        self ::assertEquals ('content3 ' , $ this tree ->getChild ('coll2 ' )->getChild ('file3 ' )->get ());
129145    }
130146
147+     public  function  testShallowCopyColl ()
148+     {
149+         // Ensure proppatches are applied 
150+         $ this tree ->failMode  = 'updatepropstrue ' ;
151+         $ requestnew  HTTP \Request ('COPY ' , '/propscoll ' , [
152+             'Destination '  => '/shallow-coll ' ,
153+             'Depth '  => '0 ' ,
154+         ]);
155+         $ response$ this request ($ request
156+         // reset 
157+         $ this tree ->failMode  = false ;
158+ 
159+         self ::assertEquals (201 , $ responsegetStatus ());
160+         // The copied collection exists 
161+         self ::assertEquals (true , $ this tree ->childExists ('shallow-coll ' ));
162+         // But it does not contain children 
163+         self ::assertEquals ([], $ this tree ->getChild ('shallow-coll ' )->getChildren ());
164+         // But the properties are preserved 
165+         self ::assertEquals (['my-prop '  => 'my-value ' ], $ this tree ->getChild ('shallow-coll ' )->getProperties ([]));
166+     }
167+ 
131168    public  function  testCopyCollToSelf ()
132169    {
133170        $ requestnew  HTTP \Request ('COPY ' , '/coll1 ' , [
134171            'Destination '  => '/coll1 ' ,
172+             'Depth '  => 'infinity ' ,
135173        ]);
136174        $ response$ this request ($ request
137175        self ::assertEquals (403 , $ responsegetStatus ());
@@ -141,6 +179,7 @@ public function testCopyCollToExisting()
141179    {
142180        $ requestnew  HTTP \Request ('COPY ' , '/coll1 ' , [
143181            'Destination '  => '/file2 ' ,
182+             'Depth '  => 'infinity ' ,
144183        ]);
145184        $ response$ this request ($ request
146185        self ::assertEquals (204 , $ responsegetStatus ());
@@ -151,6 +190,7 @@ public function testCopyCollToExistingOverwriteT()
151190    {
152191        $ requestnew  HTTP \Request ('COPY ' , '/coll1 ' , [
153192            'Destination '  => '/file2 ' ,
193+             'Depth '  => 'infinity ' ,
154194            'Overwrite '  => 'T ' ,
155195        ]);
156196        $ response$ this request ($ request
@@ -162,6 +202,7 @@ public function testCopyCollToExistingOverwriteF()
162202    {
163203        $ requestnew  HTTP \Request ('COPY ' , '/coll1 ' , [
164204            'Destination '  => '/file2 ' ,
205+             'Depth '  => 'infinity ' ,
165206            'Overwrite '  => 'F ' ,
166207        ]);
167208        $ response$ this request ($ request
@@ -173,6 +214,7 @@ public function testCopyCollIntoSubtree()
173214    {
174215        $ requestnew  HTTP \Request ('COPY ' , '/coll1 ' , [
175216            'Destination '  => '/coll1/subcol ' ,
217+             'Depth '  => 'infinity ' ,
176218        ]);
177219        $ response$ this request ($ request
178220        self ::assertEquals (409 , $ responsegetStatus ());
0 commit comments