ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
MSWordTest.php
Go to the documentation of this file.
1<?php
2
3namespace Sabre\DAV\Locks;
4
5use Sabre\DAV;
6use Sabre\HTTP;
7
8require_once 'Sabre/HTTP/ResponseMock.php';
9require_once 'Sabre/TestUtil.php';
10
12
13 function tearDown() {
14
16
17 }
18
19 function testLockEtc() {
20
21 mkdir(SABRE_TEMPDIR . '/mstest');
22 $tree = new DAV\FS\Directory(SABRE_TEMPDIR . '/mstest');
23
25 $server->debugExceptions = true;
26 $locksBackend = new Backend\File(SABRE_TEMPDIR . '/locksdb');
27 $locksPlugin = new Plugin($locksBackend);
28 $server->addPlugin($locksPlugin);
29
30 $response1 = new HTTP\ResponseMock();
31
32 $server->httpRequest = $this->getLockRequest();
33 $server->httpResponse = $response1;
34 $server->sapi = new HTTP\SapiMock();
35 $server->exec();
36
37 $this->assertEquals(201, $server->httpResponse->getStatus(), 'Full response body:' . $response1->getBodyAsString());
38 $this->assertTrue(!!$server->httpResponse->getHeaders('Lock-Token'));
39 $lockToken = $server->httpResponse->getHeader('Lock-Token');
40
41 //sleep(10);
42
43 $response2 = new HTTP\ResponseMock();
44
45 $server->httpRequest = $this->getLockRequest2();
46 $server->httpResponse = $response2;
47 $server->exec();
48
49 $this->assertEquals(201, $server->httpResponse->status);
50 $this->assertTrue(!!$server->httpResponse->getHeaders('Lock-Token'));
51
52 //sleep(10);
53
54 $response3 = new HTTP\ResponseMock();
55 $server->httpRequest = $this->getPutRequest($lockToken);
56 $server->httpResponse = $response3;
57 $server->exec();
58
59 $this->assertEquals(204, $server->httpResponse->status);
60
61 }
62
63 function getLockRequest() {
64
66 'REQUEST_METHOD' => 'LOCK',
67 'HTTP_CONTENT_TYPE' => 'application/xml',
68 'HTTP_TIMEOUT' => 'Second-3600',
69 'REQUEST_URI' => '/Nouveau%20Microsoft%20Office%20Excel%20Worksheet.xlsx',
70 ]);
71
72 $request->setBody('<D:lockinfo xmlns:D="DAV:">
73 <D:lockscope>
74 <D:exclusive />
75 </D:lockscope>
76 <D:locktype>
77 <D:write />
78 </D:locktype>
79 <D:owner>
80 <D:href>PC-Vista\User</D:href>
81 </D:owner>
82</D:lockinfo>');
83
84 return $request;
85
86 }
87 function getLockRequest2() {
88
90 'REQUEST_METHOD' => 'LOCK',
91 'HTTP_CONTENT_TYPE' => 'application/xml',
92 'HTTP_TIMEOUT' => 'Second-3600',
93 'REQUEST_URI' => '/~$Nouveau%20Microsoft%20Office%20Excel%20Worksheet.xlsx',
94 ]);
95
96 $request->setBody('<D:lockinfo xmlns:D="DAV:">
97 <D:lockscope>
98 <D:exclusive />
99 </D:lockscope>
100 <D:locktype>
101 <D:write />
102 </D:locktype>
103 <D:owner>
104 <D:href>PC-Vista\User</D:href>
105 </D:owner>
106</D:lockinfo>');
107
108 return $request;
109
110 }
111
112 function getPutRequest($lockToken) {
113
115 'REQUEST_METHOD' => 'PUT',
116 'REQUEST_URI' => '/Nouveau%20Microsoft%20Office%20Excel%20Worksheet.xlsx',
117 'HTTP_IF' => 'If: (' . $lockToken . ')',
118 ]);
119 $request->setBody('FAKE BODY');
120 return $request;
121
122 }
123
124}
foreach($paths as $path) $request
Definition: asyncclient.php:32
An exception for terminatinating execution or to throw for unit testing.
Directory class.
Definition: Directory.php:14
File class.
Definition: File.php:15
Locking plugin.
Definition: Plugin.php:23
Main DAV server class.
Definition: Server.php:23
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.
Definition: Sapi.php:107
static clearTempDir()
This function deletes all the contents of the temporary directory.
Definition: TestUtil.php:12
$server
Definition: sabredav.php:48