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

Public Member Functions

 setUp ()
 
 tearDown ()
 
 testPropFindEmptyBody ()
 
 testPropFindEmptyBodyFile ()
 
 testSupportedLocks ()
 
 testLockDiscovery ()
 
 testUnknownProperty ()
 
 testParsePropPatchRequest ()
 
- Public Member Functions inherited from Sabre\DAV\AbstractServer
 setUp ()
 
 tearDown ()
 

Protected Member Functions

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

Private Member Functions

 sendRequest ($body, $path='/', $headers=['Depth'=> '0'])
 

Additional Inherited Members

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

Detailed Description

Definition at line 10 of file ServerPropsTest.php.

Member Function Documentation

◆ getRootNode()

Sabre\DAV\ServerPropsTest::getRootNode ( )
protected

Definition at line 12 of file ServerPropsTest.php.

12  {
13 
14  return new FSExt\Directory(SABRE_TEMPDIR);
15 
16  }

◆ sendRequest()

Sabre\DAV\ServerPropsTest::sendRequest (   $body,
  $path = '/',
  $headers = ['Depth' =,
'0']   
)
private

Definition at line 36 of file ServerPropsTest.php.

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

Referenced by Sabre\DAV\ServerPropsTest\testLockDiscovery(), Sabre\DAV\ServerPropsTest\testPropFindEmptyBody(), Sabre\DAV\ServerPropsTest\testPropFindEmptyBodyFile(), Sabre\DAV\ServerPropsTest\testSupportedLocks(), and Sabre\DAV\ServerPropsTest\testUnknownProperty().

36  {
37 
38  $request = new HTTP\Request('PROPFIND', $path, $headers, $body);
39 
40  $this->server->httpRequest = $request;
41  $this->server->exec();
42 
43  }
$path
Definition: aliased.php:25
+ Here is the caller graph for this function:

◆ setUp()

Sabre\DAV\ServerPropsTest::setUp ( )

Definition at line 18 of file ServerPropsTest.php.

18  {
19 
20  if (file_exists(SABRE_TEMPDIR . '../.sabredav')) unlink(SABRE_TEMPDIR . '../.sabredav');
21  parent::setUp();
22  file_put_contents(SABRE_TEMPDIR . '/test2.txt', 'Test contents2');
23  mkdir(SABRE_TEMPDIR . '/col');
24  file_put_contents(SABRE_TEMPDIR . 'col/test.txt', 'Test contents');
25  $this->server->addPlugin(new Locks\Plugin(new Locks\Backend\File(SABRE_TEMPDIR . '/.locksdb')));
26 
27  }

◆ tearDown()

Sabre\DAV\ServerPropsTest::tearDown ( )

Definition at line 29 of file ServerPropsTest.php.

References Sabre\DAV\tearDown().

29  {
30 
32  if (file_exists(SABRE_TEMPDIR . '../.locksdb')) unlink(SABRE_TEMPDIR . '../.locksdb');
33 
34  }
+ Here is the call graph for this function:

◆ testLockDiscovery()

Sabre\DAV\ServerPropsTest::testLockDiscovery ( )

Definition at line 131 of file ServerPropsTest.php.

References $data, $xml, and Sabre\DAV\ServerPropsTest\sendRequest().

131  {
132 
133  $xml = '<?xml version="1.0"?>
134 <d:propfind xmlns:d="DAV:">
135  <d:prop>
136  <d:lockdiscovery />
137  </d:prop>
138 </d:propfind>';
139 
140  $this->sendRequest($xml);
141 
142  $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", "xmlns\\1=\"urn:DAV\"", $this->response->body);
143  $xml = simplexml_load_string($body);
144  $xml->registerXPathNamespace('d', 'urn:DAV');
145 
146  $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:lockdiscovery');
147  $this->assertEquals(1, count($data), 'We expected a \'d:lockdiscovery\' tag');
148 
149  }
sendRequest($body, $path='/', $headers=['Depth'=> '0'])
$data
Definition: bench.php:6
+ Here is the call graph for this function:

◆ testParsePropPatchRequest()

Sabre\DAV\ServerPropsTest::testParsePropPatchRequest ( )

Definition at line 182 of file ServerPropsTest.php.

References $result.

182  {
183 
184  $body = '<?xml version="1.0"?>
185 <d:propertyupdate xmlns:d="DAV:" xmlns:s="http://sabredav.org/NS/test">
186  <d:set><d:prop><s:someprop>somevalue</s:someprop></d:prop></d:set>
187  <d:remove><d:prop><s:someprop2 /></d:prop></d:remove>
188  <d:set><d:prop><s:someprop3>removeme</s:someprop3></d:prop></d:set>
189  <d:remove><d:prop><s:someprop3 /></d:prop></d:remove>
190 </d:propertyupdate>';
191 
192  $result = $this->server->xml->parse($body);
193  $this->assertEquals([
194  '{http://sabredav.org/NS/test}someprop' => 'somevalue',
195  '{http://sabredav.org/NS/test}someprop2' => null,
196  '{http://sabredav.org/NS/test}someprop3' => null,
197  ], $result->properties);
198 
199  }
$result

◆ testPropFindEmptyBody()

Sabre\DAV\ServerPropsTest::testPropFindEmptyBody ( )

Definition at line 45 of file ServerPropsTest.php.

References $data, $xml, Sabre\DAV\ServerPropsTest\sendRequest(), and Sabre\DAV\Version\VERSION.

45  {
46 
47  $this->sendRequest("");
48  $this->assertEquals(207, $this->response->status);
49 
50  $this->assertEquals([
51  'X-Sabre-Version' => [Version::VERSION],
52  'Content-Type' => ['application/xml; charset=utf-8'],
53  'DAV' => ['1, 3, extended-mkcol, 2'],
54  'Vary' => ['Brief,Prefer'],
55  ],
56  $this->response->getHeaders()
57  );
58 
59  $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", "xmlns\\1=\"urn:DAV\"", $this->response->body);
60  $xml = simplexml_load_string($body);
61  $xml->registerXPathNamespace('d', 'urn:DAV');
62 
63  list($data) = $xml->xpath('/d:multistatus/d:response/d:href');
64  $this->assertEquals('/', (string)$data, 'href element should have been /');
65 
66  $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:resourcetype');
67  $this->assertEquals(1, count($data));
68 
69  }
const VERSION
Full version number.
Definition: Version.php:17
sendRequest($body, $path='/', $headers=['Depth'=> '0'])
$data
Definition: bench.php:6
+ Here is the call graph for this function:

◆ testPropFindEmptyBodyFile()

Sabre\DAV\ServerPropsTest::testPropFindEmptyBodyFile ( )

Definition at line 71 of file ServerPropsTest.php.

References $data, $xml, Sabre\DAV\ServerPropsTest\sendRequest(), and Sabre\DAV\Version\VERSION.

71  {
72 
73  $this->sendRequest("", '/test2.txt', []);
74  $this->assertEquals(207, $this->response->status);
75 
76  $this->assertEquals([
77  'X-Sabre-Version' => [Version::VERSION],
78  'Content-Type' => ['application/xml; charset=utf-8'],
79  'DAV' => ['1, 3, extended-mkcol, 2'],
80  'Vary' => ['Brief,Prefer'],
81  ],
82  $this->response->getHeaders()
83  );
84 
85  $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", "xmlns\\1=\"urn:DAV\"", $this->response->body);
86  $xml = simplexml_load_string($body);
87  $xml->registerXPathNamespace('d', 'urn:DAV');
88 
89  list($data) = $xml->xpath('/d:multistatus/d:response/d:href');
90  $this->assertEquals('/test2.txt', (string)$data, 'href element should have been /test2.txt');
91 
92  $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:getcontentlength');
93  $this->assertEquals(1, count($data));
94 
95  }
const VERSION
Full version number.
Definition: Version.php:17
sendRequest($body, $path='/', $headers=['Depth'=> '0'])
$data
Definition: bench.php:6
+ Here is the call graph for this function:

◆ testSupportedLocks()

Sabre\DAV\ServerPropsTest::testSupportedLocks ( )

Definition at line 97 of file ServerPropsTest.php.

References $data, $xml, and Sabre\DAV\ServerPropsTest\sendRequest().

97  {
98 
99  $xml = '<?xml version="1.0"?>
100 <d:propfind xmlns:d="DAV:">
101  <d:prop>
102  <d:supportedlock />
103  </d:prop>
104 </d:propfind>';
105 
106  $this->sendRequest($xml);
107 
108  $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", "xmlns\\1=\"urn:DAV\"", $this->response->body);
109  $xml = simplexml_load_string($body);
110  $xml->registerXPathNamespace('d', 'urn:DAV');
111 
112  $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supportedlock/d:lockentry');
113  $this->assertEquals(2, count($data), 'We expected two \'d:lockentry\' tags');
114 
115  $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supportedlock/d:lockentry/d:lockscope');
116  $this->assertEquals(2, count($data), 'We expected two \'d:lockscope\' tags');
117 
118  $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supportedlock/d:lockentry/d:locktype');
119  $this->assertEquals(2, count($data), 'We expected two \'d:locktype\' tags');
120 
121  $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supportedlock/d:lockentry/d:lockscope/d:shared');
122  $this->assertEquals(1, count($data), 'We expected a \'d:shared\' tag');
123 
124  $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supportedlock/d:lockentry/d:lockscope/d:exclusive');
125  $this->assertEquals(1, count($data), 'We expected a \'d:exclusive\' tag');
126 
127  $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supportedlock/d:lockentry/d:locktype/d:write');
128  $this->assertEquals(2, count($data), 'We expected two \'d:write\' tags');
129  }
sendRequest($body, $path='/', $headers=['Depth'=> '0'])
$data
Definition: bench.php:6
+ Here is the call graph for this function:

◆ testUnknownProperty()

Sabre\DAV\ServerPropsTest::testUnknownProperty ( )

Definition at line 151 of file ServerPropsTest.php.

References $test, $xml, and Sabre\DAV\ServerPropsTest\sendRequest().

151  {
152 
153  $xml = '<?xml version="1.0"?>
154 <d:propfind xmlns:d="DAV:">
155  <d:prop>
156  <d:macaroni />
157  </d:prop>
158 </d:propfind>';
159 
160  $this->sendRequest($xml);
161  $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", "xmlns\\1=\"urn:DAV\"", $this->response->body);
162  $xml = simplexml_load_string($body);
163  $xml->registerXPathNamespace('d', 'urn:DAV');
164  $pathTests = [
165  '/d:multistatus',
166  '/d:multistatus/d:response',
167  '/d:multistatus/d:response/d:propstat',
168  '/d:multistatus/d:response/d:propstat/d:status',
169  '/d:multistatus/d:response/d:propstat/d:prop',
170  '/d:multistatus/d:response/d:propstat/d:prop/d:macaroni',
171  ];
172  foreach ($pathTests as $test) {
173  $this->assertTrue(count($xml->xpath($test)) == true, 'We expected the ' . $test . ' element to appear in the response, we got: ' . $body);
174  }
175 
176  $val = $xml->xpath('/d:multistatus/d:response/d:propstat/d:status');
177  $this->assertEquals(1, count($val), $body);
178  $this->assertEquals('HTTP/1.1 404 Not Found', (string)$val[0]);
179 
180  }
sendRequest($body, $path='/', $headers=['Depth'=> '0'])
$test
Definition: Utf8Test.php:84
+ Here is the call graph for this function:

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