3 require_once 'Sabre/HTTP/ResponseMock.php';
4 require_once 'Sabre/DAV/AbstractServer.php';
5 require_once 'Sabre/DAV/Exception.php';
7 class Sabre_DAV_ServerFinderBlockTest extends Sabre_DAV_AbstractServer{
12 'REQUEST_URI' => '/testput.txt',
13 'REQUEST_METHOD' => 'PUT',
14 'HTTP_X_EXPECTED_ENTITY_LENGTH' => '20',
17 $request = new Sabre_HTTP_Request($serverVars);
18 $request->setBody('Testing finder');
19 $this->server->httpRequest = $request;
20 $this->server->exec();
22 $this->assertEquals('', $this->response->body);
23 $this->assertEquals('HTTP/1.1 201 Created',$this->response->status);
24 $this->assertEquals('0', $this->response->headers['Content-Length']);
26 $this->assertEquals('Testing finder',file_get_contents(SABRE_TEMPDIR . '/testput.txt'));
30 function testPutFail() {
33 'REQUEST_URI' => '/testput.txt',
34 'REQUEST_METHOD' => 'PUT',
35 'HTTP_X_EXPECTED_ENTITY_LENGTH' => '20',
38 $request = new Sabre_HTTP_Request($serverVars);
39 $request->setBody('');
40 $this->server->httpRequest = $request;
41 $this->server->exec();
43 $this->assertEquals('HTTP/1.1 403 Forbidden',$this->response->status);
44 $this->assertEquals(array(
45 'Content-Type' => 'application/xml; charset=utf-8',
46 ),$this->response->headers);
48 $this->assertFalse(file_exists(SABRE_TEMPDIR . '/testput.txt'));