27
27
use OCA \DAV \Connector \Sabre \Directory ;
28
28
use OCA \DAV \Upload \ChunkingPlugin ;
29
29
use OCA \DAV \Upload \FutureFile ;
30
+ use Sabre \DAV \Exception \NotFound ;
30
31
use Sabre \HTTP \RequestInterface ;
31
32
use Sabre \HTTP \ResponseInterface ;
32
33
use Test \TestCase ;
@@ -87,16 +88,41 @@ public function testBeforeMoveFutureFileSkip() {
87
88
$ this ->assertNull ($ this ->plugin ->beforeMove ('source ' , 'target ' ));
88
89
}
89
90
91
+ public function testBeforeMoveDestinationIsDirectory () {
92
+ $ this ->expectException (\Sabre \DAV \Exception \BadRequest::class);
93
+ $ this ->expectExceptionMessage ('The given destination target is a directory. ' );
94
+
95
+ $ sourceNode = $ this ->createMock (FutureFile::class);
96
+ $ targetNode = $ this ->createMock (Directory::class);
97
+
98
+ $ this ->tree ->expects ($ this ->at (0 ))
99
+ ->method ('getNodeForPath ' )
100
+ ->with ('source ' )
101
+ ->willReturn ($ sourceNode );
102
+ $ this ->tree ->expects ($ this ->at (1 ))
103
+ ->method ('getNodeForPath ' )
104
+ ->with ('target ' )
105
+ ->willReturn ($ targetNode );
106
+ $ this ->response ->expects ($ this ->never ())
107
+ ->method ('setStatus ' );
108
+
109
+ $ this ->assertNull ($ this ->plugin ->beforeMove ('source ' , 'target ' ));
110
+ }
111
+
90
112
public function testBeforeMoveFutureFileSkipNonExisting () {
91
113
$ sourceNode = $ this ->createMock (FutureFile::class);
92
114
$ sourceNode ->expects ($ this ->once ())
93
115
->method ('getSize ' )
94
116
->willReturn (4 );
95
117
96
- $ this ->tree ->expects ($ this ->any ( ))
118
+ $ this ->tree ->expects ($ this ->at ( 0 ))
97
119
->method ('getNodeForPath ' )
98
120
->with ('source ' )
99
121
->willReturn ($ sourceNode );
122
+ $ this ->tree ->expects ($ this ->at (1 ))
123
+ ->method ('getNodeForPath ' )
124
+ ->with ('target ' )
125
+ ->willThrowException (new NotFound ());
100
126
$ this ->tree ->expects ($ this ->any ())
101
127
->method ('nodeExists ' )
102
128
->with ('target ' )
@@ -117,10 +143,14 @@ public function testBeforeMoveFutureFileMoveIt() {
117
143
->method ('getSize ' )
118
144
->willReturn (4 );
119
145
120
- $ this ->tree ->expects ($ this ->any ( ))
146
+ $ this ->tree ->expects ($ this ->at ( 0 ))
121
147
->method ('getNodeForPath ' )
122
148
->with ('source ' )
123
149
->willReturn ($ sourceNode );
150
+ $ this ->tree ->expects ($ this ->at (1 ))
151
+ ->method ('getNodeForPath ' )
152
+ ->with ('target ' )
153
+ ->willThrowException (new NotFound ());
124
154
$ this ->tree ->expects ($ this ->any ())
125
155
->method ('nodeExists ' )
126
156
->with ('target ' )
@@ -143,7 +173,7 @@ public function testBeforeMoveFutureFileMoveIt() {
143
173
$ this ->assertFalse ($ this ->plugin ->beforeMove ('source ' , 'target ' ));
144
174
}
145
175
146
-
176
+
147
177
public function testBeforeMoveSizeIsWrong () {
148
178
$ this ->expectException (\Sabre \DAV \Exception \BadRequest::class);
149
179
$ this ->expectExceptionMessage ('Chunks on server do not sum up to 4 but to 3 bytes ' );
@@ -153,10 +183,14 @@ public function testBeforeMoveSizeIsWrong() {
153
183
->method ('getSize ' )
154
184
->willReturn (3 );
155
185
156
- $ this ->tree ->expects ($ this ->any ( ))
186
+ $ this ->tree ->expects ($ this ->at ( 0 ))
157
187
->method ('getNodeForPath ' )
158
188
->with ('source ' )
159
189
->willReturn ($ sourceNode );
190
+ $ this ->tree ->expects ($ this ->at (1 ))
191
+ ->method ('getNodeForPath ' )
192
+ ->with ('target ' )
193
+ ->willThrowException (new NotFound ());
160
194
$ this ->request ->expects ($ this ->once ())
161
195
->method ('getHeader ' )
162
196
->with ('OC-Total-Length ' )
0 commit comments