xref: /plugin/davcal/vendor/sabre/dav/tests/Sabre/DAV/Mount/PluginTest.php (revision a1a3b6794e0e143a4a8b51d3185ce2d339be61ab)
1*a1a3b679SAndreas Boehler<?php
2*a1a3b679SAndreas Boehler
3*a1a3b679SAndreas Boehlernamespace Sabre\DAV\Mount;
4*a1a3b679SAndreas Boehler
5*a1a3b679SAndreas Boehleruse Sabre\DAV;
6*a1a3b679SAndreas Boehleruse Sabre\HTTP;
7*a1a3b679SAndreas Boehler
8*a1a3b679SAndreas Boehlerrequire_once 'Sabre/DAV/AbstractServer.php';
9*a1a3b679SAndreas Boehler
10*a1a3b679SAndreas Boehlerclass PluginTest extends DAV\AbstractServer {
11*a1a3b679SAndreas Boehler
12*a1a3b679SAndreas Boehler    function setUp() {
13*a1a3b679SAndreas Boehler
14*a1a3b679SAndreas Boehler        parent::setUp();
15*a1a3b679SAndreas Boehler        $this->server->addPlugin(new Plugin());
16*a1a3b679SAndreas Boehler
17*a1a3b679SAndreas Boehler    }
18*a1a3b679SAndreas Boehler
19*a1a3b679SAndreas Boehler    function testPassThrough() {
20*a1a3b679SAndreas Boehler
21*a1a3b679SAndreas Boehler        $serverVars = array(
22*a1a3b679SAndreas Boehler            'REQUEST_URI'    => '/',
23*a1a3b679SAndreas Boehler            'REQUEST_METHOD' => 'GET',
24*a1a3b679SAndreas Boehler        );
25*a1a3b679SAndreas Boehler
26*a1a3b679SAndreas Boehler        $request = HTTP\Sapi::createFromServerArray($serverVars);
27*a1a3b679SAndreas Boehler        $this->server->httpRequest = ($request);
28*a1a3b679SAndreas Boehler        $this->server->exec();
29*a1a3b679SAndreas Boehler
30*a1a3b679SAndreas Boehler        $this->assertEquals(501, $this->response->status,'We expected GET to not be implemented for Directories. Response body: ' . $this->response->body);
31*a1a3b679SAndreas Boehler
32*a1a3b679SAndreas Boehler    }
33*a1a3b679SAndreas Boehler
34*a1a3b679SAndreas Boehler    function testMountResponse() {
35*a1a3b679SAndreas Boehler
36*a1a3b679SAndreas Boehler        $serverVars = array(
37*a1a3b679SAndreas Boehler            'REQUEST_URI'    => '/?mount',
38*a1a3b679SAndreas Boehler            'REQUEST_METHOD' => 'GET',
39*a1a3b679SAndreas Boehler            'QUERY_STRING'   => 'mount',
40*a1a3b679SAndreas Boehler            'HTTP_HOST'      => 'example.org',
41*a1a3b679SAndreas Boehler        );
42*a1a3b679SAndreas Boehler
43*a1a3b679SAndreas Boehler        $request = HTTP\Sapi::createFromServerArray($serverVars);
44*a1a3b679SAndreas Boehler        $this->server->httpRequest = ($request);
45*a1a3b679SAndreas Boehler        $this->server->exec();
46*a1a3b679SAndreas Boehler
47*a1a3b679SAndreas Boehler        $this->assertEquals(200, $this->response->status);
48*a1a3b679SAndreas Boehler
49*a1a3b679SAndreas Boehler        $xml = simplexml_load_string($this->response->body);
50*a1a3b679SAndreas Boehler        $this->assertInstanceOf('SimpleXMLElement',$xml, 'Response was not a valid xml document. The list of errors:' . print_r(libxml_get_errors(),true) . '. xml body: ' . $this->response->body . '. What type we got: ' . gettype($xml) . ' class, if object: ' . get_class($xml));
51*a1a3b679SAndreas Boehler
52*a1a3b679SAndreas Boehler        $xml->registerXPathNamespace('dm','http://purl.org/NET/webdav/mount');
53*a1a3b679SAndreas Boehler        $url = $xml->xpath('//dm:url');
54*a1a3b679SAndreas Boehler        $this->assertEquals('http://example.org/',(string)$url[0]);
55*a1a3b679SAndreas Boehler
56*a1a3b679SAndreas Boehler    }
57*a1a3b679SAndreas Boehler
58*a1a3b679SAndreas Boehler}
59