ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
HttpHeadTest.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Sabre\DAV;
4 
6 use Sabre\HTTP;
7 
15 class HttpHeadTest extends DAVServerTest {
16 
22  function setUpTree() {
23 
24  $this->tree = new Mock\Collection('root', [
25  'file1' => 'foo',
26  new Mock\Collection('dir', []),
27  new Mock\StreamingFile('streaming', 'stream')
28  ]);
29 
30  }
31 
32  function testHEAD() {
33 
34  $request = new HTTP\Request('HEAD', '//file1');
35  $response = $this->request($request);
36 
37  $this->assertEquals(200, $response->getStatus());
38 
39  // Removing Last-Modified because it keeps changing.
40  $response->removeHeader('Last-Modified');
41 
42  $this->assertEquals(
43  [
44  'X-Sabre-Version' => [Version::VERSION],
45  'Content-Type' => ['application/octet-stream'],
46  'Content-Length' => [3],
47  'ETag' => ['"' . md5('foo') . '"'],
48  ],
49  $response->getHeaders()
50  );
51 
52  $this->assertEquals('', $response->getBodyAsString());
53 
54  }
55 
61  function testHEADCollection() {
62 
63  $request = new HTTP\Request('HEAD', '/dir');
64  $response = $this->request($request);
65 
66  $this->assertEquals(200, $response->getStatus());
67 
68  }
69 
75  function testDoubleAuth() {
76 
77  $count = 0;
78 
79  $authBackend = new Auth\Backend\BasicCallBack(function($userName, $password) use (&$count) {
80  $count++;
81  return true;
82  });
83  $this->server->addPlugin(
84  new Auth\Plugin(
86  )
87  );
88  $request = new HTTP\Request('HEAD', '/file1', ['Authorization' => 'Basic ' . base64_encode('user:pass')]);
89  $response = $this->request($request);
90 
91  $this->assertEquals(200, $response->getStatus());
92 
93  $this->assertEquals(1, $count, 'Auth was triggered twice :(');
94 
95  }
96 
97 }
foreach($paths as $path) $request
Definition: asyncclient.php:32
setUpTree()
Sets up the DAV tree.
Extremely simply HTTP Basic auth backend.
const VERSION
Full version number.
Definition: Version.php:17
Collection class.
Definition: Collection.php:15
This class may be used as a basis for other webdav-related unittests.
Tests related to the HEAD request.
$authBackend
$password
Definition: cron.php:14
testHEADCollection()
According to the specs, HEAD should behave identical to GET.
request($request, $expectedStatus=null)
Makes a request, and returns a response object.
testDoubleAuth()
HEAD automatically internally maps to GET via a sub-request.
$response