ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ServerPluginTest.php
Go to the documentation of this file.
1<?php
2
3namespace Sabre\DAV;
4
5use Sabre\HTTP;
6
7require_once 'Sabre/DAV/AbstractServer.php';
8require_once 'Sabre/DAV/TestPlugin.php';
9
11
15 protected $testPlugin;
16
17 function setUp() {
18
19 parent::setUp();
20
21 $testPlugin = new TestPlugin();
22 $this->server->addPlugin($testPlugin);
23 $this->testPlugin = $testPlugin;
24
25 }
26
29 function testBaseClass() {
30
31 $p = new ServerPluginMock();
32 $this->assertEquals([], $p->getFeatures());
33 $this->assertEquals([], $p->getHTTPMethods(''));
34 $this->assertEquals(
35 [
36 'name' => 'Sabre\DAV\ServerPluginMock',
37 'description' => null,
38 'link' => null
39 ], $p->getPluginInfo()
40 );
41
42 }
43
44 function testOptions() {
45
46 $serverVars = [
47 'REQUEST_URI' => '/',
48 'REQUEST_METHOD' => 'OPTIONS',
49 ];
50
52 $this->server->httpRequest = ($request);
53 $this->server->exec();
54
55 $this->assertEquals([
56 'DAV' => ['1, 3, extended-mkcol, drinking'],
57 'MS-Author-Via' => ['DAV'],
58 'Allow' => ['OPTIONS, GET, HEAD, DELETE, PROPFIND, PUT, PROPPATCH, COPY, MOVE, REPORT, BEER, WINE'],
59 'Accept-Ranges' => ['bytes'],
60 'Content-Length' => ['0'],
61 'X-Sabre-Version' => [Version::VERSION],
62 ], $this->response->getHeaders());
63
64 $this->assertEquals(200, $this->response->status);
65 $this->assertEquals('', $this->response->body);
66 $this->assertEquals('OPTIONS', $this->testPlugin->beforeMethod);
67
68
69 }
70
71 function testGetPlugin() {
72
73 $this->assertEquals($this->testPlugin, $this->server->getPlugin(get_class($this->testPlugin)));
74
75 }
76
77 function testUnknownPlugin() {
78
79 $this->assertNull($this->server->getPlugin('SomeRandomClassName'));
80
81 }
82
84
85 $this->assertEquals([], $this->testPlugin->getSupportedReportSet('/'));
86
87 }
88
89 function testGetPlugins() {
90
91 $this->assertEquals(
92 [
93 get_class($this->testPlugin) => $this->testPlugin,
94 'core' => $this->server->getPlugin('core'),
95 ],
96 $this->server->getPlugins()
97 );
98
99 }
100
101
102}
103
105
106 function initialize(Server $s) { }
107
108}
An exception for terminatinating execution or to throw for unit testing.
initialize(Server $s)
This initializes the plugin.
The baseclass for all server plugins.
Main DAV server class.
Definition: Server.php:23
const VERSION
Full version number.
Definition: Version.php:17
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
$s
Definition: pwgen.php:45