diff options
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php')
-rw-r--r-- | vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php | 62 |
1 files changed, 29 insertions, 33 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php index fa1314d10..04f168f92 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php @@ -1,5 +1,7 @@ <?php +declare(strict_types=1); + namespace Sabre\DAVACL; use Sabre\DAV; @@ -7,10 +9,10 @@ use Sabre\HTTP; require_once 'Sabre/HTTP/ResponseMock.php'; -class PrincipalSearchPropertySetTest extends \PHPUnit_Framework_TestCase { - - function getServer() { - +class PrincipalSearchPropertySetTest extends \PHPUnit\Framework\TestCase +{ + public function getServer() + { $backend = new PrincipalBackend\Mock(); $dir = new DAV\SimpleCollection('root'); @@ -27,18 +29,17 @@ class PrincipalSearchPropertySetTest extends \PHPUnit_Framework_TestCase { $this->assertEquals($plugin, $fakeServer->getPlugin('acl')); return $fakeServer; - } - function testDepth1() { - + public function testDepth1() + { $xml = '<?xml version="1.0"?> <d:principal-search-property-set xmlns:d="DAV:" />'; $serverVars = [ 'REQUEST_METHOD' => 'REPORT', - 'HTTP_DEPTH' => '1', - 'REQUEST_URI' => '/principals', + 'HTTP_DEPTH' => '1', + 'REQUEST_URI' => '/principals', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); @@ -52,20 +53,19 @@ class PrincipalSearchPropertySetTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(400, $server->httpResponse->status); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $server->httpResponse->getHeaders()); - } - function testDepthIncorrectXML() { - + public function testDepthIncorrectXML() + { $xml = '<?xml version="1.0"?> <d:principal-search-property-set xmlns:d="DAV:"><d:ohell /></d:principal-search-property-set>'; $serverVars = [ 'REQUEST_METHOD' => 'REPORT', - 'HTTP_DEPTH' => '0', - 'REQUEST_URI' => '/principals', + 'HTTP_DEPTH' => '0', + 'REQUEST_URI' => '/principals', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); @@ -79,20 +79,19 @@ class PrincipalSearchPropertySetTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(400, $server->httpResponse->status, $server->httpResponse->body); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $server->httpResponse->getHeaders()); - } - function testCorrect() { - + public function testCorrect() + { $xml = '<?xml version="1.0"?> <d:principal-search-property-set xmlns:d="DAV:"/>'; $serverVars = [ 'REQUEST_METHOD' => 'REPORT', - 'HTTP_DEPTH' => '0', - 'REQUEST_URI' => '/principals', + 'HTTP_DEPTH' => '0', + 'REQUEST_URI' => '/principals', ]; $request = HTTP\Sapi::createFromServerArray($serverVars); @@ -106,35 +105,32 @@ class PrincipalSearchPropertySetTest extends \PHPUnit_Framework_TestCase { $this->assertEquals(200, $server->httpResponse->status, $server->httpResponse->body); $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], + 'Content-Type' => ['application/xml; charset=utf-8'], ], $server->httpResponse->getHeaders()); - $check = [ '/d:principal-search-property-set', - '/d:principal-search-property-set/d:principal-search-property' => 2, - '/d:principal-search-property-set/d:principal-search-property/d:prop' => 2, - '/d:principal-search-property-set/d:principal-search-property/d:prop/d:displayname' => 1, + '/d:principal-search-property-set/d:principal-search-property' => 2, + '/d:principal-search-property-set/d:principal-search-property/d:prop' => 2, + '/d:principal-search-property-set/d:principal-search-property/d:prop/d:displayname' => 1, '/d:principal-search-property-set/d:principal-search-property/d:prop/s:email-address' => 1, - '/d:principal-search-property-set/d:principal-search-property/d:description' => 2, + '/d:principal-search-property-set/d:principal-search-property/d:description' => 2, ]; $xml = simplexml_load_string($server->httpResponse->body); $xml->registerXPathNamespace('d', 'DAV:'); $xml->registerXPathNamespace('s', 'http://sabredav.org/ns'); foreach ($check as $v1 => $v2) { - $xpath = is_int($v1) ? $v2 : $v1; $result = $xml->xpath($xpath); $count = 1; - if (!is_int($v1)) $count = $v2; - - $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body); + if (!is_int($v1)) { + $count = $v2; + } + $this->assertEquals($count, count($result), 'we expected '.$count.' appearances of '.$xpath.' . We found '.count($result).'. Full response body: '.$server->httpResponse->body); } - } - } |