1<?php 2 3namespace Sabre\DAV\Xml\Property; 4 5use Sabre\DAV; 6use Sabre\HTTP; 7 8require_once 'Sabre/HTTP/ResponseMock.php'; 9require_once 'Sabre/DAV/AbstractServer.php'; 10 11class SupportedMethodSetTest extends DAV\AbstractServer { 12 13 function sendPROPFIND($body) { 14 15 $request = new HTTP\Request('PROPFIND', '/', ['Depth' => '0' ]); 16 $request->setBody($body); 17 18 $this->server->httpRequest = $request; 19 $this->server->exec(); 20 21 } 22 23 /** 24 */ 25 function testMethods() { 26 27 $xml = '<?xml version="1.0"?> 28<d:propfind xmlns:d="DAV:"> 29 <d:prop> 30 <d:supported-method-set /> 31 </d:prop> 32</d:propfind>'; 33 34 $this->sendPROPFIND($xml); 35 36 $this->assertEquals(207, $this->response->status, 'We expected a multi-status response. Full response body: ' . $this->response->body); 37 38 $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", "xmlns\\1=\"urn:DAV\"", $this->response->body); 39 $xml = simplexml_load_string($body); 40 $xml->registerXPathNamespace('d', 'urn:DAV'); 41 42 $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop'); 43 $this->assertEquals(1, count($data), 'We expected 1 \'d:prop\' element'); 44 45 $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:supported-method-set'); 46 $this->assertEquals(1, count($data), 'We expected 1 \'d:supported-method-set\' element'); 47 48 $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:status'); 49 $this->assertEquals(1, count($data), 'We expected 1 \'d:status\' element'); 50 51 $this->assertEquals('HTTP/1.1 200 OK', (string)$data[0], 'The status for this property should have been 200'); 52 53 } 54 55 function testGetObj() { 56 57 $result = $this->server->getProperties('/', ['{DAV:}supported-method-set']); 58 $this->assertTrue($result['{DAV:}supported-method-set']->has('PROPFIND')); 59 60 } 61 62} 63