3 require_once 'Sabre/DAV/AbstractServer.php';
5 class Sabre_DAV_Browser_PluginTest extends Sabre_DAV_AbstractServer{
10 $this->server->addPlugin(new Sabre_DAV_Browser_Plugin());
14 function testCollectionGet() {
17 'REQUEST_URI' => '/dir',
18 'REQUEST_METHOD' => 'GET',
21 $request = new Sabre_HTTP_Request($serverVars);
22 $this->server->httpRequest = ($request);
23 $this->server->exec();
25 $this->assertEquals('HTTP/1.1 200 OK',$this->response->status);
26 $this->assertEquals(array(
27 'Content-Type' => 'text/html; charset=utf-8',
29 $this->response->headers
32 $this->assertTrue(strpos($this->response->body, 'Index for dir/') !== false);
36 function testNotFound() {
39 'REQUEST_URI' => '/random',
40 'REQUEST_METHOD' => 'GET',
43 $request = new Sabre_HTTP_Request($serverVars);
44 $this->server->httpRequest = ($request);
45 $this->server->exec();
47 $this->assertEquals('HTTP/1.1 404 Not Found',$this->response->status);
51 function testPostOtherContentType() {
55 'REQUEST_METHOD' => 'POST',
56 'CONTENT_TYPE' => 'text/xml',
58 $request = new Sabre_HTTP_Request($serverVars);
59 $this->server->httpRequest = $request;
60 $this->server->exec();
62 $this->assertEquals('HTTP/1.1 501 Not Implemented', $this->response->status);
66 function testPostNoSabreAction() {
70 'REQUEST_METHOD' => 'POST',
71 'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
75 $request = new Sabre_HTTP_Request($serverVars,$postVars);
76 $this->server->httpRequest = $request;
77 $this->server->exec();
79 $this->assertEquals('HTTP/1.1 501 Not Implemented', $this->response->status);
83 function testPostMkCol() {
87 'REQUEST_METHOD' => 'POST',
88 'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
91 'sabreAction' => 'mkcol',
92 'name' => 'new_collection',
95 $request = new Sabre_HTTP_Request($serverVars,$postVars);
96 $this->server->httpRequest = $request;
97 $this->server->exec();
99 $this->assertEquals('HTTP/1.1 302 Found', $this->response->status);
100 $this->assertEquals(array(
102 ), $this->response->headers);
104 $this->assertTrue(is_dir(SABRE_TEMPDIR . '/new_collection'));