ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Sabre\DAV\Browser\PluginTest Class Reference
+ Inheritance diagram for Sabre\DAV\Browser\PluginTest:
+ Collaboration diagram for Sabre\DAV\Browser\PluginTest:

Public Member Functions

 setUp ()
 
 testCollectionGet ()
 
 testCollectionGetIfNoneMatch ()
 Adding the If-None-Match should have 0 effect, but it threw an error. More...
 
 testCollectionGetRoot ()
 
 testGETPassthru ()
 
 testPostOtherContentType ()
 
 testPostNoSabreAction ()
 
 testPostMkCol ()
 
 testGetAsset ()
 
 testGetAsset404 ()
 
 testGetAssetEscapeBasePath ()
 
- Public Member Functions inherited from Sabre\DAV\AbstractServer
 setUp ()
 
 tearDown ()
 

Protected Attributes

 $plugin
 
- Protected Attributes inherited from Sabre\DAV\AbstractServer
 $response
 
 $request
 
 $server
 
 $tempDir = SABRE_TEMPDIR
 

Additional Inherited Members

- Protected Member Functions inherited from Sabre\DAV\AbstractServer
 getRootNode ()
 

Detailed Description

Definition at line 10 of file PluginTest.php.

Member Function Documentation

◆ setUp()

Sabre\DAV\Browser\PluginTest::setUp ( )

Definition at line 14 of file PluginTest.php.

14  {
15 
16  parent::setUp();
17  $this->server->addPlugin($this->plugin = new Plugin());
18  $this->server->tree->getNodeForPath('')->createDirectory('dir2');
19 
20  }

◆ testCollectionGet()

Sabre\DAV\Browser\PluginTest::testCollectionGet ( )

Definition at line 22 of file PluginTest.php.

References Sabre\DAV\AbstractServer\$request, and Sabre\DAV\Version\VERSION.

22  {
23 
24  $request = new HTTP\Request('GET', '/dir');
25  $this->server->httpRequest = $request;
26  $this->server->exec();
27 
28  $this->assertEquals(200, $this->response->getStatus(), "Incorrect status received. Full response body: " . $this->response->getBodyAsString());
29  $this->assertEquals(
30  [
31  'X-Sabre-Version' => [DAV\Version::VERSION],
32  'Content-Type' => ['text/html; charset=utf-8'],
33  'Content-Security-Policy' => ["default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"]
34  ],
35  $this->response->getHeaders()
36  );
37 
38  $body = $this->response->getBodyAsString();
39  $this->assertTrue(strpos($body, '<title>dir') !== false, $body);
40  $this->assertTrue(strpos($body, '<a href="/dir/child.txt">') !== false);
41 
42  }
const VERSION
Full version number.
Definition: Version.php:17

◆ testCollectionGetIfNoneMatch()

Sabre\DAV\Browser\PluginTest::testCollectionGetIfNoneMatch ( )

Adding the If-None-Match should have 0 effect, but it threw an error.

Definition at line 47 of file PluginTest.php.

References Sabre\DAV\AbstractServer\$request, and Sabre\DAV\Version\VERSION.

47  {
48 
49  $request = new HTTP\Request('GET', '/dir');
50  $request->setHeader('If-None-Match', '"foo-bar"');
51  $this->server->httpRequest = $request;
52  $this->server->exec();
53 
54  $this->assertEquals(200, $this->response->getStatus(), "Incorrect status received. Full response body: " . $this->response->getBodyAsString());
55  $this->assertEquals(
56  [
57  'X-Sabre-Version' => [DAV\Version::VERSION],
58  'Content-Type' => ['text/html; charset=utf-8'],
59  'Content-Security-Policy' => ["default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"]
60  ],
61  $this->response->getHeaders()
62  );
63 
64  $body = $this->response->getBodyAsString();
65  $this->assertTrue(strpos($body, '<title>dir') !== false, $body);
66  $this->assertTrue(strpos($body, '<a href="/dir/child.txt">') !== false);
67 
68  }
const VERSION
Full version number.
Definition: Version.php:17

◆ testCollectionGetRoot()

Sabre\DAV\Browser\PluginTest::testCollectionGetRoot ( )

Definition at line 69 of file PluginTest.php.

References Sabre\DAV\AbstractServer\$request, and Sabre\DAV\Version\VERSION.

69  {
70 
71  $request = new HTTP\Request('GET', '/');
72  $this->server->httpRequest = ($request);
73  $this->server->exec();
74 
75  $this->assertEquals(200, $this->response->status, "Incorrect status received. Full response body: " . $this->response->getBodyAsString());
76  $this->assertEquals(
77  [
78  'X-Sabre-Version' => [DAV\Version::VERSION],
79  'Content-Type' => ['text/html; charset=utf-8'],
80  'Content-Security-Policy' => ["default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"]
81  ],
82  $this->response->getHeaders()
83  );
84 
85  $body = $this->response->getBodyAsString();
86  $this->assertTrue(strpos($body, '<title>/') !== false, $body);
87  $this->assertTrue(strpos($body, '<a href="/dir/">') !== false);
88  $this->assertTrue(strpos($body, '<span class="btn disabled">') !== false);
89 
90  }
const VERSION
Full version number.
Definition: Version.php:17

◆ testGetAsset()

Sabre\DAV\Browser\PluginTest::testGetAsset ( )

Definition at line 150 of file PluginTest.php.

References Sabre\DAV\AbstractServer\$request, and Sabre\DAV\Version\VERSION.

150  {
151 
152  $request = new HTTP\Request('GET', '/?sabreAction=asset&assetName=favicon.ico');
153  $this->server->httpRequest = $request;
154  $this->server->exec();
155 
156  $this->assertEquals(200, $this->response->getStatus(), 'Error: ' . $this->response->body);
157  $this->assertEquals([
158  'X-Sabre-Version' => [DAV\Version::VERSION],
159  'Content-Type' => ['image/vnd.microsoft.icon'],
160  'Content-Length' => ['4286'],
161  'Cache-Control' => ['public, max-age=1209600'],
162  'Content-Security-Policy' => ["default-src 'none'; img-src 'self'; style-src 'self'; font-src 'self';"]
163  ], $this->response->getHeaders());
164 
165  }
const VERSION
Full version number.
Definition: Version.php:17

◆ testGetAsset404()

Sabre\DAV\Browser\PluginTest::testGetAsset404 ( )

Definition at line 167 of file PluginTest.php.

References Sabre\DAV\AbstractServer\$request.

167  {
168 
169  $request = new HTTP\Request('GET', '/?sabreAction=asset&assetName=flavicon.ico');
170  $this->server->httpRequest = $request;
171  $this->server->exec();
172 
173  $this->assertEquals(404, $this->response->getStatus(), 'Error: ' . $this->response->body);
174 
175  }

◆ testGetAssetEscapeBasePath()

Sabre\DAV\Browser\PluginTest::testGetAssetEscapeBasePath ( )

Definition at line 177 of file PluginTest.php.

References Sabre\DAV\AbstractServer\$request.

177  {
178 
179  $request = new HTTP\Request('GET', '/?sabreAction=asset&assetName=./../assets/favicon.ico');
180  $this->server->httpRequest = $request;
181  $this->server->exec();
182 
183  $this->assertEquals(404, $this->response->getStatus(), 'Error: ' . $this->response->body);
184 
185  }

◆ testGETPassthru()

Sabre\DAV\Browser\PluginTest::testGETPassthru ( )

Definition at line 92 of file PluginTest.php.

References Sabre\DAV\AbstractServer\$request, and Sabre\DAV\AbstractServer\$response.

92  {
93 
94  $request = new HTTP\Request('GET', '/random');
95  $response = new HTTP\Response();
96  $this->assertNull(
97  $this->plugin->httpGet($request, $response)
98  );
99 
100  }

◆ testPostMkCol()

Sabre\DAV\Browser\PluginTest::testPostMkCol ( )

Definition at line 123 of file PluginTest.php.

References Sabre\DAV\AbstractServer\$request, Sabre\HTTP\Sapi\createFromServerArray(), and Sabre\DAV\Version\VERSION.

123  {
124 
125  $serverVars = [
126  'REQUEST_URI' => '/',
127  'REQUEST_METHOD' => 'POST',
128  'CONTENT_TYPE' => 'application/x-www-form-urlencoded',
129  ];
130  $postVars = [
131  'sabreAction' => 'mkcol',
132  'name' => 'new_collection',
133  ];
134 
136  $request->setPostData($postVars);
137  $this->server->httpRequest = $request;
138  $this->server->exec();
139 
140  $this->assertEquals(302, $this->response->status);
141  $this->assertEquals([
142  'X-Sabre-Version' => [DAV\Version::VERSION],
143  'Location' => ['/'],
144  ], $this->response->getHeaders());
145 
146  $this->assertTrue(is_dir(SABRE_TEMPDIR . '/new_collection'));
147 
148  }
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
+ Here is the call graph for this function:

◆ testPostNoSabreAction()

Sabre\DAV\Browser\PluginTest::testPostNoSabreAction ( )

Definition at line 112 of file PluginTest.php.

References Sabre\DAV\AbstractServer\$request.

112  {
113 
114  $request = new HTTP\Request('POST', '/', ['Content-Type' => 'application/x-www-form-urlencoded']);
115  $request->setPostData([]);
116  $this->server->httpRequest = $request;
117  $this->server->exec();
118 
119  $this->assertEquals(501, $this->response->status);
120 
121  }

◆ testPostOtherContentType()

Sabre\DAV\Browser\PluginTest::testPostOtherContentType ( )

Definition at line 102 of file PluginTest.php.

References Sabre\DAV\AbstractServer\$request.

102  {
103 
104  $request = new HTTP\Request('POST', '/', ['Content-Type' => 'text/xml']);
105  $this->server->httpRequest = $request;
106  $this->server->exec();
107 
108  $this->assertEquals(501, $this->response->status);
109 
110  }

Field Documentation

◆ $plugin

Sabre\DAV\Browser\PluginTest::$plugin
protected

Definition at line 12 of file PluginTest.php.


The documentation for this class was generated from the following file: