]> git.mxchange.org Git - friendica-addons.git/blob - dav/SabreDAV/tests/Sabre/DAV/ServerFinderBlockTest.php
Merge branch 'master' of git://github.com/friendica/friendica-addons
[friendica-addons.git] / dav / SabreDAV / tests / Sabre / DAV / ServerFinderBlockTest.php
1 <?php
2
3 require_once 'Sabre/HTTP/ResponseMock.php';
4 require_once 'Sabre/DAV/AbstractServer.php';
5 require_once 'Sabre/DAV/Exception.php';
6
7 class Sabre_DAV_ServerFinderBlockTest extends Sabre_DAV_AbstractServer{
8
9     function testPut() {
10
11         $serverVars = array(
12             'REQUEST_URI'    => '/testput.txt',
13             'REQUEST_METHOD' => 'PUT',
14             'HTTP_X_EXPECTED_ENTITY_LENGTH' => '20',
15         );
16
17         $request = new Sabre_HTTP_Request($serverVars);
18         $request->setBody('Testing finder');
19         $this->server->httpRequest = $request;
20         $this->server->exec();
21
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']);
25
26         $this->assertEquals('Testing finder',file_get_contents(SABRE_TEMPDIR . '/testput.txt'));
27
28     }
29
30     function testPutFail() {
31
32         $serverVars = array(
33             'REQUEST_URI'    => '/testput.txt',
34             'REQUEST_METHOD' => 'PUT',
35             'HTTP_X_EXPECTED_ENTITY_LENGTH' => '20',
36         );
37
38         $request = new Sabre_HTTP_Request($serverVars);
39         $request->setBody('');
40         $this->server->httpRequest = $request;
41         $this->server->exec();
42
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);
47
48         $this->assertFalse(file_exists(SABRE_TEMPDIR . '/testput.txt'));
49     }
50 }