]> git.mxchange.org Git - friendica-addons.git/blob - dav/SabreDAV/tests/Sabre/DAV/Browser/PluginTest.php
Merge branch 'master' of git://github.com/friendica/friendica-addons
[friendica-addons.git] / dav / SabreDAV / tests / Sabre / DAV / Browser / PluginTest.php
1 <?php
2
3 require_once 'Sabre/DAV/AbstractServer.php';
4
5 class Sabre_DAV_Browser_PluginTest extends Sabre_DAV_AbstractServer{
6
7     function setUp() {
8
9         parent::setUp();
10         $this->server->addPlugin(new Sabre_DAV_Browser_Plugin());
11
12     }
13
14     function testCollectionGet() {
15
16         $serverVars = array(
17             'REQUEST_URI'    => '/dir',
18             'REQUEST_METHOD' => 'GET',
19         );
20
21         $request = new Sabre_HTTP_Request($serverVars);
22         $this->server->httpRequest = ($request);
23         $this->server->exec();
24
25         $this->assertEquals('HTTP/1.1 200 OK',$this->response->status);
26         $this->assertEquals(array(
27             'Content-Type' => 'text/html; charset=utf-8',
28             ),
29             $this->response->headers
30         );
31
32         $this->assertTrue(strpos($this->response->body, 'Index for dir/') !== false);
33
34     }
35
36     function testNotFound() {
37
38         $serverVars = array(
39             'REQUEST_URI'    => '/random',
40             'REQUEST_METHOD' => 'GET',
41         );
42
43         $request = new Sabre_HTTP_Request($serverVars);
44         $this->server->httpRequest = ($request);
45         $this->server->exec();
46
47         $this->assertEquals('HTTP/1.1 404 Not Found',$this->response->status);
48
49     }
50
51     function testPostOtherContentType() {
52
53         $serverVars = array(
54             'REQUEST_URI'    => '/',
55             'REQUEST_METHOD' => 'POST',
56             'CONTENT_TYPE' => 'text/xml',
57         );
58         $request = new Sabre_HTTP_Request($serverVars);
59         $this->server->httpRequest = $request;
60         $this->server->exec();
61
62         $this->assertEquals('HTTP/1.1 501 Not Implemented', $this->response->status);
63
64     }
65
66     function testPostNoSabreAction() {
67
68         $serverVars = array(
69             'REQUEST_URI'    => '/',
70             'REQUEST_METHOD' => 'POST',
71             'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
72         );
73         $postVars = array();
74
75         $request = new Sabre_HTTP_Request($serverVars,$postVars);
76         $this->server->httpRequest = $request;
77         $this->server->exec();
78
79         $this->assertEquals('HTTP/1.1 501 Not Implemented', $this->response->status);
80
81     }
82
83     function testPostMkCol() {
84
85         $serverVars = array(
86             'REQUEST_URI'    => '/',
87             'REQUEST_METHOD' => 'POST',
88             'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
89         );
90         $postVars = array(
91             'sabreAction' => 'mkcol',
92             'name' => 'new_collection',
93         );
94
95         $request = new Sabre_HTTP_Request($serverVars,$postVars);
96         $this->server->httpRequest = $request;
97         $this->server->exec();
98
99         $this->assertEquals('HTTP/1.1 302 Found', $this->response->status);
100         $this->assertEquals(array(
101             'Location' => '/',
102         ), $this->response->headers);
103
104         $this->assertTrue(is_dir(SABRE_TEMPDIR . '/new_collection'));
105
106     }
107
108 }