1*a1a3b679SAndreas Boehler<?php 2*a1a3b679SAndreas Boehler 3*a1a3b679SAndreas Boehlernamespace Sabre\DAVACL; 4*a1a3b679SAndreas Boehler 5*a1a3b679SAndreas Boehleruse Sabre\DAV; 6*a1a3b679SAndreas Boehleruse Sabre\HTTP; 7*a1a3b679SAndreas Boehler 8*a1a3b679SAndreas Boehlerrequire_once 'Sabre/HTTP/ResponseMock.php'; 9*a1a3b679SAndreas Boehler 10*a1a3b679SAndreas Boehlerclass PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { 11*a1a3b679SAndreas Boehler 12*a1a3b679SAndreas Boehler function getServer() { 13*a1a3b679SAndreas Boehler 14*a1a3b679SAndreas Boehler $backend = new PrincipalBackend\Mock(); 15*a1a3b679SAndreas Boehler 16*a1a3b679SAndreas Boehler $dir = new DAV\SimpleCollection('root'); 17*a1a3b679SAndreas Boehler $principals = new PrincipalCollection($backend); 18*a1a3b679SAndreas Boehler $dir->addChild($principals); 19*a1a3b679SAndreas Boehler 20*a1a3b679SAndreas Boehler $fakeServer = new DAV\Server($dir); 21*a1a3b679SAndreas Boehler $fakeServer->sapi = new HTTP\SapiMock(); 22*a1a3b679SAndreas Boehler $fakeServer->httpResponse = new HTTP\ResponseMock(); 23*a1a3b679SAndreas Boehler $fakeServer->debugExceptions = true; 24*a1a3b679SAndreas Boehler $plugin = new MockPlugin($backend,'realm'); 25*a1a3b679SAndreas Boehler $plugin->allowAccessToNodesWithoutACL = true; 26*a1a3b679SAndreas Boehler 27*a1a3b679SAndreas Boehler $this->assertTrue($plugin instanceof Plugin); 28*a1a3b679SAndreas Boehler $fakeServer->addPlugin($plugin); 29*a1a3b679SAndreas Boehler $this->assertEquals($plugin, $fakeServer->getPlugin('acl')); 30*a1a3b679SAndreas Boehler 31*a1a3b679SAndreas Boehler return $fakeServer; 32*a1a3b679SAndreas Boehler 33*a1a3b679SAndreas Boehler } 34*a1a3b679SAndreas Boehler 35*a1a3b679SAndreas Boehler function testDepth1() { 36*a1a3b679SAndreas Boehler 37*a1a3b679SAndreas Boehler $xml = '<?xml version="1.0"?> 38*a1a3b679SAndreas Boehler<d:principal-property-search xmlns:d="DAV:"> 39*a1a3b679SAndreas Boehler <d:property-search> 40*a1a3b679SAndreas Boehler <d:prop> 41*a1a3b679SAndreas Boehler <d:displayname /> 42*a1a3b679SAndreas Boehler </d:prop> 43*a1a3b679SAndreas Boehler <d:match>user</d:match> 44*a1a3b679SAndreas Boehler </d:property-search> 45*a1a3b679SAndreas Boehler <d:prop> 46*a1a3b679SAndreas Boehler <d:displayname /> 47*a1a3b679SAndreas Boehler <d:getcontentlength /> 48*a1a3b679SAndreas Boehler </d:prop> 49*a1a3b679SAndreas Boehler</d:principal-property-search>'; 50*a1a3b679SAndreas Boehler 51*a1a3b679SAndreas Boehler $serverVars = array( 52*a1a3b679SAndreas Boehler 'REQUEST_METHOD' => 'REPORT', 53*a1a3b679SAndreas Boehler 'HTTP_DEPTH' => '1', 54*a1a3b679SAndreas Boehler 'REQUEST_URI' => '/principals', 55*a1a3b679SAndreas Boehler ); 56*a1a3b679SAndreas Boehler 57*a1a3b679SAndreas Boehler $request = HTTP\Sapi::createFromServerArray($serverVars); 58*a1a3b679SAndreas Boehler $request->setBody($xml); 59*a1a3b679SAndreas Boehler 60*a1a3b679SAndreas Boehler $server = $this->getServer(); 61*a1a3b679SAndreas Boehler $server->httpRequest = $request; 62*a1a3b679SAndreas Boehler 63*a1a3b679SAndreas Boehler $server->exec(); 64*a1a3b679SAndreas Boehler 65*a1a3b679SAndreas Boehler $this->assertEquals(400, $server->httpResponse->getStatus(), $server->httpResponse->getBodyAsString()); 66*a1a3b679SAndreas Boehler $this->assertEquals(array( 67*a1a3b679SAndreas Boehler 'X-Sabre-Version' => [DAV\Version::VERSION], 68*a1a3b679SAndreas Boehler 'Content-Type' => ['application/xml; charset=utf-8'], 69*a1a3b679SAndreas Boehler ), $server->httpResponse->getHeaders()); 70*a1a3b679SAndreas Boehler 71*a1a3b679SAndreas Boehler } 72*a1a3b679SAndreas Boehler 73*a1a3b679SAndreas Boehler 74*a1a3b679SAndreas Boehler function testUnknownSearchField() { 75*a1a3b679SAndreas Boehler 76*a1a3b679SAndreas Boehler $xml = '<?xml version="1.0"?> 77*a1a3b679SAndreas Boehler<d:principal-property-search xmlns:d="DAV:"> 78*a1a3b679SAndreas Boehler <d:property-search> 79*a1a3b679SAndreas Boehler <d:prop> 80*a1a3b679SAndreas Boehler <d:yourmom /> 81*a1a3b679SAndreas Boehler </d:prop> 82*a1a3b679SAndreas Boehler <d:match>user</d:match> 83*a1a3b679SAndreas Boehler </d:property-search> 84*a1a3b679SAndreas Boehler <d:prop> 85*a1a3b679SAndreas Boehler <d:displayname /> 86*a1a3b679SAndreas Boehler <d:getcontentlength /> 87*a1a3b679SAndreas Boehler </d:prop> 88*a1a3b679SAndreas Boehler</d:principal-property-search>'; 89*a1a3b679SAndreas Boehler 90*a1a3b679SAndreas Boehler $serverVars = array( 91*a1a3b679SAndreas Boehler 'REQUEST_METHOD' => 'REPORT', 92*a1a3b679SAndreas Boehler 'HTTP_DEPTH' => '0', 93*a1a3b679SAndreas Boehler 'REQUEST_URI' => '/principals', 94*a1a3b679SAndreas Boehler ); 95*a1a3b679SAndreas Boehler 96*a1a3b679SAndreas Boehler $request = HTTP\Sapi::createFromServerArray($serverVars); 97*a1a3b679SAndreas Boehler $request->setBody($xml); 98*a1a3b679SAndreas Boehler 99*a1a3b679SAndreas Boehler $server = $this->getServer(); 100*a1a3b679SAndreas Boehler $server->httpRequest = $request; 101*a1a3b679SAndreas Boehler 102*a1a3b679SAndreas Boehler $server->exec(); 103*a1a3b679SAndreas Boehler 104*a1a3b679SAndreas Boehler $this->assertEquals(207, $server->httpResponse->getStatus(), "Full body: " . $server->httpResponse->getBodyAsString()); 105*a1a3b679SAndreas Boehler $this->assertEquals(array( 106*a1a3b679SAndreas Boehler 'X-Sabre-Version' => [DAV\Version::VERSION], 107*a1a3b679SAndreas Boehler 'Content-Type' => ['application/xml; charset=utf-8'], 108*a1a3b679SAndreas Boehler 'Vary' => ['Brief,Prefer'], 109*a1a3b679SAndreas Boehler ), $server->httpResponse->getHeaders()); 110*a1a3b679SAndreas Boehler 111*a1a3b679SAndreas Boehler } 112*a1a3b679SAndreas Boehler 113*a1a3b679SAndreas Boehler function testCorrect() { 114*a1a3b679SAndreas Boehler 115*a1a3b679SAndreas Boehler $xml = '<?xml version="1.0"?> 116*a1a3b679SAndreas Boehler<d:principal-property-search xmlns:d="DAV:"> 117*a1a3b679SAndreas Boehler <d:apply-to-principal-collection-set /> 118*a1a3b679SAndreas Boehler <d:property-search> 119*a1a3b679SAndreas Boehler <d:prop> 120*a1a3b679SAndreas Boehler <d:displayname /> 121*a1a3b679SAndreas Boehler </d:prop> 122*a1a3b679SAndreas Boehler <d:match>user</d:match> 123*a1a3b679SAndreas Boehler </d:property-search> 124*a1a3b679SAndreas Boehler <d:prop> 125*a1a3b679SAndreas Boehler <d:displayname /> 126*a1a3b679SAndreas Boehler <d:getcontentlength /> 127*a1a3b679SAndreas Boehler </d:prop> 128*a1a3b679SAndreas Boehler</d:principal-property-search>'; 129*a1a3b679SAndreas Boehler 130*a1a3b679SAndreas Boehler $serverVars = array( 131*a1a3b679SAndreas Boehler 'REQUEST_METHOD' => 'REPORT', 132*a1a3b679SAndreas Boehler 'HTTP_DEPTH' => '0', 133*a1a3b679SAndreas Boehler 'REQUEST_URI' => '/', 134*a1a3b679SAndreas Boehler ); 135*a1a3b679SAndreas Boehler 136*a1a3b679SAndreas Boehler $request = HTTP\Sapi::createFromServerArray($serverVars); 137*a1a3b679SAndreas Boehler $request->setBody($xml); 138*a1a3b679SAndreas Boehler 139*a1a3b679SAndreas Boehler $server = $this->getServer(); 140*a1a3b679SAndreas Boehler $server->httpRequest = $request; 141*a1a3b679SAndreas Boehler 142*a1a3b679SAndreas Boehler $server->exec(); 143*a1a3b679SAndreas Boehler 144*a1a3b679SAndreas Boehler $this->assertEquals(207, $server->httpResponse->status, $server->httpResponse->body); 145*a1a3b679SAndreas Boehler $this->assertEquals(array( 146*a1a3b679SAndreas Boehler 'X-Sabre-Version' => [DAV\Version::VERSION], 147*a1a3b679SAndreas Boehler 'Content-Type' => ['application/xml; charset=utf-8'], 148*a1a3b679SAndreas Boehler 'Vary' => ['Brief,Prefer'], 149*a1a3b679SAndreas Boehler ), $server->httpResponse->getHeaders()); 150*a1a3b679SAndreas Boehler 151*a1a3b679SAndreas Boehler 152*a1a3b679SAndreas Boehler $check = array( 153*a1a3b679SAndreas Boehler '/d:multistatus', 154*a1a3b679SAndreas Boehler '/d:multistatus/d:response' => 2, 155*a1a3b679SAndreas Boehler '/d:multistatus/d:response/d:href' => 2, 156*a1a3b679SAndreas Boehler '/d:multistatus/d:response/d:propstat' => 4, 157*a1a3b679SAndreas Boehler '/d:multistatus/d:response/d:propstat/d:prop' => 4, 158*a1a3b679SAndreas Boehler '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 2, 159*a1a3b679SAndreas Boehler '/d:multistatus/d:response/d:propstat/d:prop/d:getcontentlength' => 2, 160*a1a3b679SAndreas Boehler '/d:multistatus/d:response/d:propstat/d:status' => 4, 161*a1a3b679SAndreas Boehler ); 162*a1a3b679SAndreas Boehler 163*a1a3b679SAndreas Boehler $xml = simplexml_load_string($server->httpResponse->body); 164*a1a3b679SAndreas Boehler $xml->registerXPathNamespace('d','DAV:'); 165*a1a3b679SAndreas Boehler foreach($check as $v1=>$v2) { 166*a1a3b679SAndreas Boehler 167*a1a3b679SAndreas Boehler $xpath = is_int($v1)?$v2:$v1; 168*a1a3b679SAndreas Boehler 169*a1a3b679SAndreas Boehler $result = $xml->xpath($xpath); 170*a1a3b679SAndreas Boehler 171*a1a3b679SAndreas Boehler $count = 1; 172*a1a3b679SAndreas Boehler if (!is_int($v1)) $count = $v2; 173*a1a3b679SAndreas Boehler 174*a1a3b679SAndreas Boehler $this->assertEquals($count,count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body); 175*a1a3b679SAndreas Boehler 176*a1a3b679SAndreas Boehler } 177*a1a3b679SAndreas Boehler 178*a1a3b679SAndreas Boehler } 179*a1a3b679SAndreas Boehler 180*a1a3b679SAndreas Boehler function testAND() { 181*a1a3b679SAndreas Boehler 182*a1a3b679SAndreas Boehler $xml = '<?xml version="1.0"?> 183*a1a3b679SAndreas Boehler<d:principal-property-search xmlns:d="DAV:"> 184*a1a3b679SAndreas Boehler <d:apply-to-principal-collection-set /> 185*a1a3b679SAndreas Boehler <d:property-search> 186*a1a3b679SAndreas Boehler <d:prop> 187*a1a3b679SAndreas Boehler <d:displayname /> 188*a1a3b679SAndreas Boehler </d:prop> 189*a1a3b679SAndreas Boehler <d:match>user</d:match> 190*a1a3b679SAndreas Boehler </d:property-search> 191*a1a3b679SAndreas Boehler <d:property-search> 192*a1a3b679SAndreas Boehler <d:prop> 193*a1a3b679SAndreas Boehler <d:foo /> 194*a1a3b679SAndreas Boehler </d:prop> 195*a1a3b679SAndreas Boehler <d:match>bar</d:match> 196*a1a3b679SAndreas Boehler </d:property-search> 197*a1a3b679SAndreas Boehler <d:prop> 198*a1a3b679SAndreas Boehler <d:displayname /> 199*a1a3b679SAndreas Boehler <d:getcontentlength /> 200*a1a3b679SAndreas Boehler </d:prop> 201*a1a3b679SAndreas Boehler</d:principal-property-search>'; 202*a1a3b679SAndreas Boehler 203*a1a3b679SAndreas Boehler $serverVars = array( 204*a1a3b679SAndreas Boehler 'REQUEST_METHOD' => 'REPORT', 205*a1a3b679SAndreas Boehler 'HTTP_DEPTH' => '0', 206*a1a3b679SAndreas Boehler 'REQUEST_URI' => '/', 207*a1a3b679SAndreas Boehler ); 208*a1a3b679SAndreas Boehler 209*a1a3b679SAndreas Boehler $request = HTTP\Sapi::createFromServerArray($serverVars); 210*a1a3b679SAndreas Boehler $request->setBody($xml); 211*a1a3b679SAndreas Boehler 212*a1a3b679SAndreas Boehler $server = $this->getServer(); 213*a1a3b679SAndreas Boehler $server->httpRequest = $request; 214*a1a3b679SAndreas Boehler 215*a1a3b679SAndreas Boehler $server->exec(); 216*a1a3b679SAndreas Boehler 217*a1a3b679SAndreas Boehler $this->assertEquals(207, $server->httpResponse->status, $server->httpResponse->body); 218*a1a3b679SAndreas Boehler $this->assertEquals(array( 219*a1a3b679SAndreas Boehler 'X-Sabre-Version' => [DAV\Version::VERSION], 220*a1a3b679SAndreas Boehler 'Content-Type' => ['application/xml; charset=utf-8'], 221*a1a3b679SAndreas Boehler 'Vary' => ['Brief,Prefer'], 222*a1a3b679SAndreas Boehler ), $server->httpResponse->getHeaders()); 223*a1a3b679SAndreas Boehler 224*a1a3b679SAndreas Boehler 225*a1a3b679SAndreas Boehler $check = array( 226*a1a3b679SAndreas Boehler '/d:multistatus', 227*a1a3b679SAndreas Boehler '/d:multistatus/d:response' => 0, 228*a1a3b679SAndreas Boehler '/d:multistatus/d:response/d:href' => 0, 229*a1a3b679SAndreas Boehler '/d:multistatus/d:response/d:propstat' => 0, 230*a1a3b679SAndreas Boehler '/d:multistatus/d:response/d:propstat/d:prop' => 0, 231*a1a3b679SAndreas Boehler '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 0, 232*a1a3b679SAndreas Boehler '/d:multistatus/d:response/d:propstat/d:prop/d:getcontentlength' => 0, 233*a1a3b679SAndreas Boehler '/d:multistatus/d:response/d:propstat/d:status' => 0, 234*a1a3b679SAndreas Boehler ); 235*a1a3b679SAndreas Boehler 236*a1a3b679SAndreas Boehler $xml = simplexml_load_string($server->httpResponse->body); 237*a1a3b679SAndreas Boehler $xml->registerXPathNamespace('d','DAV:'); 238*a1a3b679SAndreas Boehler foreach($check as $v1=>$v2) { 239*a1a3b679SAndreas Boehler 240*a1a3b679SAndreas Boehler $xpath = is_int($v1)?$v2:$v1; 241*a1a3b679SAndreas Boehler 242*a1a3b679SAndreas Boehler $result = $xml->xpath($xpath); 243*a1a3b679SAndreas Boehler 244*a1a3b679SAndreas Boehler $count = 1; 245*a1a3b679SAndreas Boehler if (!is_int($v1)) $count = $v2; 246*a1a3b679SAndreas Boehler 247*a1a3b679SAndreas Boehler $this->assertEquals($count,count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body); 248*a1a3b679SAndreas Boehler 249*a1a3b679SAndreas Boehler } 250*a1a3b679SAndreas Boehler 251*a1a3b679SAndreas Boehler } 252*a1a3b679SAndreas Boehler function testOR() { 253*a1a3b679SAndreas Boehler 254*a1a3b679SAndreas Boehler $xml = '<?xml version="1.0"?> 255*a1a3b679SAndreas Boehler<d:principal-property-search xmlns:d="DAV:" test="anyof"> 256*a1a3b679SAndreas Boehler <d:apply-to-principal-collection-set /> 257*a1a3b679SAndreas Boehler <d:property-search> 258*a1a3b679SAndreas Boehler <d:prop> 259*a1a3b679SAndreas Boehler <d:displayname /> 260*a1a3b679SAndreas Boehler </d:prop> 261*a1a3b679SAndreas Boehler <d:match>user</d:match> 262*a1a3b679SAndreas Boehler </d:property-search> 263*a1a3b679SAndreas Boehler <d:property-search> 264*a1a3b679SAndreas Boehler <d:prop> 265*a1a3b679SAndreas Boehler <d:foo /> 266*a1a3b679SAndreas Boehler </d:prop> 267*a1a3b679SAndreas Boehler <d:match>bar</d:match> 268*a1a3b679SAndreas Boehler </d:property-search> 269*a1a3b679SAndreas Boehler <d:prop> 270*a1a3b679SAndreas Boehler <d:displayname /> 271*a1a3b679SAndreas Boehler <d:getcontentlength /> 272*a1a3b679SAndreas Boehler </d:prop> 273*a1a3b679SAndreas Boehler</d:principal-property-search>'; 274*a1a3b679SAndreas Boehler 275*a1a3b679SAndreas Boehler $serverVars = array( 276*a1a3b679SAndreas Boehler 'REQUEST_METHOD' => 'REPORT', 277*a1a3b679SAndreas Boehler 'HTTP_DEPTH' => '0', 278*a1a3b679SAndreas Boehler 'REQUEST_URI' => '/', 279*a1a3b679SAndreas Boehler ); 280*a1a3b679SAndreas Boehler 281*a1a3b679SAndreas Boehler $request = HTTP\Sapi::createFromServerArray($serverVars); 282*a1a3b679SAndreas Boehler $request->setBody($xml); 283*a1a3b679SAndreas Boehler 284*a1a3b679SAndreas Boehler $server = $this->getServer(); 285*a1a3b679SAndreas Boehler $server->httpRequest = $request; 286*a1a3b679SAndreas Boehler 287*a1a3b679SAndreas Boehler $server->exec(); 288*a1a3b679SAndreas Boehler 289*a1a3b679SAndreas Boehler $this->assertEquals(207, $server->httpResponse->status, $server->httpResponse->body); 290*a1a3b679SAndreas Boehler $this->assertEquals(array( 291*a1a3b679SAndreas Boehler 'X-Sabre-Version' => [DAV\Version::VERSION], 292*a1a3b679SAndreas Boehler 'Content-Type' => ['application/xml; charset=utf-8'], 293*a1a3b679SAndreas Boehler 'Vary' => ['Brief,Prefer'], 294*a1a3b679SAndreas Boehler ), $server->httpResponse->getHeaders()); 295*a1a3b679SAndreas Boehler 296*a1a3b679SAndreas Boehler 297*a1a3b679SAndreas Boehler $check = array( 298*a1a3b679SAndreas Boehler '/d:multistatus', 299*a1a3b679SAndreas Boehler '/d:multistatus/d:response' => 2, 300*a1a3b679SAndreas Boehler '/d:multistatus/d:response/d:href' => 2, 301*a1a3b679SAndreas Boehler '/d:multistatus/d:response/d:propstat' => 4, 302*a1a3b679SAndreas Boehler '/d:multistatus/d:response/d:propstat/d:prop' => 4, 303*a1a3b679SAndreas Boehler '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 2, 304*a1a3b679SAndreas Boehler '/d:multistatus/d:response/d:propstat/d:prop/d:getcontentlength' => 2, 305*a1a3b679SAndreas Boehler '/d:multistatus/d:response/d:propstat/d:status' => 4, 306*a1a3b679SAndreas Boehler ); 307*a1a3b679SAndreas Boehler 308*a1a3b679SAndreas Boehler $xml = simplexml_load_string($server->httpResponse->body); 309*a1a3b679SAndreas Boehler $xml->registerXPathNamespace('d','DAV:'); 310*a1a3b679SAndreas Boehler foreach($check as $v1=>$v2) { 311*a1a3b679SAndreas Boehler 312*a1a3b679SAndreas Boehler $xpath = is_int($v1)?$v2:$v1; 313*a1a3b679SAndreas Boehler 314*a1a3b679SAndreas Boehler $result = $xml->xpath($xpath); 315*a1a3b679SAndreas Boehler 316*a1a3b679SAndreas Boehler $count = 1; 317*a1a3b679SAndreas Boehler if (!is_int($v1)) $count = $v2; 318*a1a3b679SAndreas Boehler 319*a1a3b679SAndreas Boehler $this->assertEquals($count,count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body); 320*a1a3b679SAndreas Boehler 321*a1a3b679SAndreas Boehler } 322*a1a3b679SAndreas Boehler 323*a1a3b679SAndreas Boehler } 324*a1a3b679SAndreas Boehler function testWrongUri() { 325*a1a3b679SAndreas Boehler 326*a1a3b679SAndreas Boehler $xml = '<?xml version="1.0"?> 327*a1a3b679SAndreas Boehler<d:principal-property-search xmlns:d="DAV:"> 328*a1a3b679SAndreas Boehler <d:property-search> 329*a1a3b679SAndreas Boehler <d:prop> 330*a1a3b679SAndreas Boehler <d:displayname /> 331*a1a3b679SAndreas Boehler </d:prop> 332*a1a3b679SAndreas Boehler <d:match>user</d:match> 333*a1a3b679SAndreas Boehler </d:property-search> 334*a1a3b679SAndreas Boehler <d:prop> 335*a1a3b679SAndreas Boehler <d:displayname /> 336*a1a3b679SAndreas Boehler <d:getcontentlength /> 337*a1a3b679SAndreas Boehler </d:prop> 338*a1a3b679SAndreas Boehler</d:principal-property-search>'; 339*a1a3b679SAndreas Boehler 340*a1a3b679SAndreas Boehler $serverVars = array( 341*a1a3b679SAndreas Boehler 'REQUEST_METHOD' => 'REPORT', 342*a1a3b679SAndreas Boehler 'HTTP_DEPTH' => '0', 343*a1a3b679SAndreas Boehler 'REQUEST_URI' => '/', 344*a1a3b679SAndreas Boehler ); 345*a1a3b679SAndreas Boehler 346*a1a3b679SAndreas Boehler $request = HTTP\Sapi::createFromServerArray($serverVars); 347*a1a3b679SAndreas Boehler $request->setBody($xml); 348*a1a3b679SAndreas Boehler 349*a1a3b679SAndreas Boehler $server = $this->getServer(); 350*a1a3b679SAndreas Boehler $server->httpRequest = $request; 351*a1a3b679SAndreas Boehler 352*a1a3b679SAndreas Boehler $server->exec(); 353*a1a3b679SAndreas Boehler 354*a1a3b679SAndreas Boehler $this->assertEquals(207, $server->httpResponse->status, $server->httpResponse->body); 355*a1a3b679SAndreas Boehler $this->assertEquals(array( 356*a1a3b679SAndreas Boehler 'X-Sabre-Version' => [DAV\Version::VERSION], 357*a1a3b679SAndreas Boehler 'Content-Type' => ['application/xml; charset=utf-8'], 358*a1a3b679SAndreas Boehler 'Vary' => ['Brief,Prefer'], 359*a1a3b679SAndreas Boehler ), $server->httpResponse->getHeaders()); 360*a1a3b679SAndreas Boehler 361*a1a3b679SAndreas Boehler 362*a1a3b679SAndreas Boehler $check = array( 363*a1a3b679SAndreas Boehler '/d:multistatus', 364*a1a3b679SAndreas Boehler '/d:multistatus/d:response' => 0, 365*a1a3b679SAndreas Boehler ); 366*a1a3b679SAndreas Boehler 367*a1a3b679SAndreas Boehler $xml = simplexml_load_string($server->httpResponse->body); 368*a1a3b679SAndreas Boehler $xml->registerXPathNamespace('d','DAV:'); 369*a1a3b679SAndreas Boehler foreach($check as $v1=>$v2) { 370*a1a3b679SAndreas Boehler 371*a1a3b679SAndreas Boehler $xpath = is_int($v1)?$v2:$v1; 372*a1a3b679SAndreas Boehler 373*a1a3b679SAndreas Boehler $result = $xml->xpath($xpath); 374*a1a3b679SAndreas Boehler 375*a1a3b679SAndreas Boehler $count = 1; 376*a1a3b679SAndreas Boehler if (!is_int($v1)) $count = $v2; 377*a1a3b679SAndreas Boehler 378*a1a3b679SAndreas Boehler $this->assertEquals($count,count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body); 379*a1a3b679SAndreas Boehler 380*a1a3b679SAndreas Boehler } 381*a1a3b679SAndreas Boehler 382*a1a3b679SAndreas Boehler } 383*a1a3b679SAndreas Boehler} 384*a1a3b679SAndreas Boehler 385*a1a3b679SAndreas Boehlerclass MockPlugin extends Plugin { 386*a1a3b679SAndreas Boehler 387*a1a3b679SAndreas Boehler function getCurrentUserPrivilegeSet($node) { 388*a1a3b679SAndreas Boehler 389*a1a3b679SAndreas Boehler return array( 390*a1a3b679SAndreas Boehler '{DAV:}read', 391*a1a3b679SAndreas Boehler '{DAV:}write', 392*a1a3b679SAndreas Boehler ); 393*a1a3b679SAndreas Boehler 394*a1a3b679SAndreas Boehler } 395*a1a3b679SAndreas Boehler 396*a1a3b679SAndreas Boehler} 397