8 require_once
'Sabre/HTTP/ResponseMock.php';
9 require_once
'Sabre/DAV/AbstractServer.php';
17 'REQUEST_METHOD' =>
'PROPFIND',
24 $this->server->httpRequest = (
$request);
25 $this->server->exec();
33 $xml =
'<?xml version="1.0"?> 34 <d:propfind xmlns:d="DAV:"> 36 <d:supported-report-set /> 42 $this->assertEquals(207, $this->response->status,
'We expected a multi-status response. Full response body: ' . $this->response->body);
44 $body = preg_replace(
"/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/",
"xmlns\\1=\"urn:DAV\"", $this->response->body);
45 $xml = simplexml_load_string($body);
46 $xml->registerXPathNamespace(
'd',
'urn:DAV');
48 $data =
$xml->xpath(
'/d:multistatus/d:response/d:propstat/d:prop');
49 $this->assertEquals(1, count(
$data),
'We expected 1 \'d:prop\' element');
51 $data =
$xml->xpath(
'/d:multistatus/d:response/d:propstat/d:prop/d:supported-report-set');
52 $this->assertEquals(1, count(
$data),
'We expected 1 \'d:supported-report-set\' element');
54 $data =
$xml->xpath(
'/d:multistatus/d:response/d:propstat/d:status');
55 $this->assertEquals(1, count(
$data),
'We expected 1 \'d:status\' element');
57 $this->assertEquals(
'HTTP/1.1 200 OK', (
string)
$data[0],
'The status for this property should have been 200');
67 $this->server->on(
'propFind',
function(DAV\
PropFind $propFind, DAV\
INode $node) {
68 if ($prop = $propFind->get(
'{DAV:}supported-report-set')) {
69 $prop->addReport(
'{http://www.rooftopsolutions.nl/testnamespace}myreport');
70 $prop->addReport(
'{DAV:}anotherreport');
74 $xml =
'<?xml version="1.0"?> 75 <d:propfind xmlns:d="DAV:"> 77 <d:supported-report-set /> 83 $this->assertEquals(207, $this->response->status,
'We expected a multi-status response. Full response body: ' . $this->response->body);
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 $xml->registerXPathNamespace(
'x',
'http://www.rooftopsolutions.nl/testnamespace');
90 $data =
$xml->xpath(
'/d:multistatus/d:response/d:propstat/d:prop');
91 $this->assertEquals(1, count(
$data),
'We expected 1 \'d:prop\' element');
93 $data =
$xml->xpath(
'/d:multistatus/d:response/d:propstat/d:prop/d:supported-report-set');
94 $this->assertEquals(1, count(
$data),
'We expected 1 \'d:supported-report-set\' element');
96 $data =
$xml->xpath(
'/d:multistatus/d:response/d:propstat/d:prop/d:supported-report-set/d:supported-report');
97 $this->assertEquals(2, count(
$data),
'We expected 2 \'d:supported-report\' elements');
99 $data =
$xml->xpath(
'/d:multistatus/d:response/d:propstat/d:prop/d:supported-report-set/d:supported-report/d:report');
100 $this->assertEquals(2, count(
$data),
'We expected 2 \'d:report\' elements');
102 $data =
$xml->xpath(
'/d:multistatus/d:response/d:propstat/d:prop/d:supported-report-set/d:supported-report/d:report/x:myreport');
103 $this->assertEquals(1, count(
$data),
'We expected 1 \'x:myreport\' element. Full body: ' . $this->response->body);
105 $data =
$xml->xpath(
'/d:multistatus/d:response/d:propstat/d:prop/d:supported-report-set/d:supported-report/d:report/d:anotherreport');
106 $this->assertEquals(1, count(
$data),
'We expected 1 \'d:anotherreport\' element. Full body: ' . $this->response->body);
108 $data =
$xml->xpath(
'/d:multistatus/d:response/d:propstat/d:status');
109 $this->assertEquals(1, count(
$data),
'We expected 1 \'d:status\' element');
111 $this->assertEquals(
'HTTP/1.1 200 OK', (
string)
$data[0],
'The status for this property should have been 200');
This class holds all the information about a PROPFIND request.
testCustomReport()
testNoReports
The INode interface is the base interface, and the parent class of both ICollection and IFile...
static createFromServerArray(array $serverArray)
This static method will create a new Request object, based on a PHP $_SERVER array.