ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
HttpMoveTest.php
Go to the documentation of this file.
1<?php
2
3namespace Sabre\DAV;
4
6use Sabre\HTTP;
7
16
22 function setUpTree() {
23
24 $this->tree = new Mock\Collection('root', [
25 'file1' => 'content1',
26 'file2' => 'content2',
27 ]);
28
29 }
30
31 function testMoveToSelf() {
32
33 $request = new HTTP\Request('MOVE', '/file1', [
34 'Destination' => '/file1'
35 ]);
36 $response = $this->request($request);
37 $this->assertEquals(403, $response->getStatus());
38 $this->assertEquals('content1', $this->tree->getChild('file1')->get());
39
40 }
41
42 function testMove() {
43
44 $request = new HTTP\Request('MOVE', '/file1', [
45 'Destination' => '/file3'
46 ]);
47 $response = $this->request($request);
48 $this->assertEquals(201, $response->getStatus(), print_r($response, true));
49 $this->assertEquals('content1', $this->tree->getChild('file3')->get());
50 $this->assertFalse($this->tree->childExists('file1'));
51
52 }
53
54 function testMoveToExisting() {
55
56 $request = new HTTP\Request('MOVE', '/file1', [
57 'Destination' => '/file2'
58 ]);
59 $response = $this->request($request);
60 $this->assertEquals(204, $response->getStatus(), print_r($response, true));
61 $this->assertEquals('content1', $this->tree->getChild('file2')->get());
62 $this->assertFalse($this->tree->childExists('file1'));
63
64 }
65
67
68 $request = new HTTP\Request('MOVE', '/file1', [
69 'Destination' => '/file2',
70 'Overwrite' => 'T',
71 ]);
72 $response = $this->request($request);
73 $this->assertEquals(204, $response->getStatus(), print_r($response, true));
74 $this->assertEquals('content1', $this->tree->getChild('file2')->get());
75 $this->assertFalse($this->tree->childExists('file1'));
76
77 }
78
80
81 $request = new HTTP\Request('MOVE', '/file1', [
82 'Destination' => '/file2',
83 'Overwrite' => 'F',
84 ]);
85 $response = $this->request($request);
86 $this->assertEquals(412, $response->getStatus(), print_r($response, true));
87 $this->assertEquals('content1', $this->tree->getChild('file1')->get());
88 $this->assertEquals('content2', $this->tree->getChild('file2')->get());
89 $this->assertTrue($this->tree->childExists('file1'));
90 $this->assertTrue($this->tree->childExists('file2'));
91
92 }
93
100
101 $this->server->on('beforeUnbind', function($path) {
102
103 if ($path === 'file1') {
104 throw new \Sabre\DAV\Exception\Forbidden('uh oh');
105 }
106
107 });
108 $request = new HTTP\Request('MOVE', '/file1', [
109 'Destination' => '/file2'
110 ]);
111 $response = $this->request($request);
112 $this->assertEquals(403, $response->getStatus(), print_r($response, true));
113 $this->assertEquals('content1', $this->tree->getChild('file1')->get());
114 $this->assertEquals('content2', $this->tree->getChild('file2')->get());
115 $this->assertTrue($this->tree->childExists('file1'));
116 $this->assertTrue($this->tree->childExists('file2'));
117
118 }
119}
$path
Definition: aliased.php:25
foreach($paths as $path) $request
Definition: asyncclient.php:32
An exception for terminatinating execution or to throw for unit testing.
This class may be used as a basis for other webdav-related unittests.
request($request, $expectedStatus=null)
Makes a request, and returns a response object.
Collection class.
Definition: Collection.php:15
Tests related to the MOVE request.
setUpTree()
Sets up the DAV tree.
testMoveToExistingBlockedDeleteSource()
If we MOVE to an existing file, but a plugin prevents the original from being deleted,...
$response