From 66effbfe0827fc61fff6d248797a894213ad20d6 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Sat, 28 May 2016 17:46:24 +0200 Subject: upgrade to sabre32 --- .../sabre/dav/tests/Sabre/DAVACL/ACLMethodTest.php | 157 +++++------ .../dav/tests/Sabre/DAVACL/AllowAccessTest.php | 31 +-- .../dav/tests/Sabre/DAVACL/BlockAccessTest.php | 19 +- .../Sabre/DAVACL/Exception/AceConflictTest.php | 14 +- .../Exception/NeedPrivilegesExceptionTest.php | 30 +-- .../Sabre/DAVACL/Exception/NoAbstractTest.php | 14 +- .../Exception/NotRecognizedPrincipalTest.php | 14 +- .../DAVACL/Exception/NotSupportedPrivilegeTest.php | 14 +- .../tests/Sabre/DAVACL/ExpandPropertiesTest.php | 206 +++++++-------- .../sabre/dav/tests/Sabre/DAVACL/MockACLNode.php | 3 +- .../sabre/dav/tests/Sabre/DAVACL/MockPrincipal.php | 10 +- .../dav/tests/Sabre/DAVACL/PluginAdminTest.php | 27 +- .../tests/Sabre/DAVACL/PluginPropertiesTest.php | 90 ++++--- .../Sabre/DAVACL/PluginUpdatePropertiesTest.php | 67 ++--- .../DAVACL/PrincipalBackend/AbstractPDOTest.php | 117 +++++---- .../Sabre/DAVACL/PrincipalBackend/PDOMySQLTest.php | 43 +--- .../DAVACL/PrincipalBackend/PDOSqliteTest.php | 40 +-- .../tests/Sabre/DAVACL/PrincipalCollectionTest.php | 16 +- .../Sabre/DAVACL/PrincipalPropertySearchTest.php | 159 ++++++------ .../DAVACL/PrincipalSearchPropertySetTest.php | 53 ++-- .../sabre/dav/tests/Sabre/DAVACL/PrincipalTest.php | 150 +++++------ .../dav/tests/Sabre/DAVACL/SimplePluginTest.php | 286 ++++++++++----------- 22 files changed, 763 insertions(+), 797 deletions(-) (limited to 'vendor/sabre/dav/tests/Sabre/DAVACL') diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/ACLMethodTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/ACLMethodTest.php index 4ecd42717..7d7a54d06 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/ACLMethodTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/ACLMethodTest.php @@ -14,6 +14,7 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { $acl = new Plugin(); $server = new DAV\Server(); + $server->addPlugin(new DAV\Auth\Plugin()); $server->addPlugin($acl); $acl->httpAcl($server->httpRequest, $server->httpResponse); @@ -21,15 +22,14 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { } /** - - /** + /** * @expectedException Sabre\DAV\Exception\MethodNotAllowed */ function testNotSupportedByNode() { - $tree = array( + $tree = [ new DAV\SimpleCollection('test'), - ); + ]; $acl = new Plugin(); $server = new DAV\Server($tree); $server->httpRequest = new HTTP\Request(); @@ -37,6 +37,7 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { '; $server->httpRequest->setBody($body); + $server->addPlugin(new DAV\Auth\Plugin()); $server->addPlugin($acl); $acl->httpACL($server->httpRequest, $server->httpResponse); @@ -45,9 +46,9 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { function testSuccessSimple() { - $tree = array( - new MockACLNode('test',array()), - ); + $tree = [ + new MockACLNode('test', []), + ]; $acl = new Plugin(); $server = new DAV\Server($tree); $server->httpRequest = new HTTP\Request(); @@ -57,6 +58,7 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { '; $server->httpRequest->setBody($body); + $server->addPlugin(new DAV\Auth\Plugin()); $server->addPlugin($acl); $this->assertFalse($acl->httpACL($server->httpRequest, $server->httpResponse)); @@ -68,12 +70,12 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { */ function testUnrecognizedPrincipal() { - $tree = array( - new MockACLNode('test',array()), - ); + $tree = [ + new MockACLNode('test', []), + ]; $acl = new Plugin(); $server = new DAV\Server($tree); - $server->httpRequest = new HTTP\Request('ACL','/test'); + $server->httpRequest = new HTTP\Request('ACL', '/test'); $body = ' @@ -82,6 +84,7 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { '; $server->httpRequest->setBody($body); + $server->addPlugin(new DAV\Auth\Plugin()); $server->addPlugin($acl); $acl->httpACL($server->httpRequest, $server->httpResponse); @@ -93,15 +96,15 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { */ function testUnrecognizedPrincipal2() { - $tree = array( - new MockACLNode('test',array()), - new DAV\SimpleCollection('principals',array( + $tree = [ + new MockACLNode('test', []), + new DAV\SimpleCollection('principals', [ new DAV\SimpleCollection('notaprincipal'), - )), - ); + ]), + ]; $acl = new Plugin(); $server = new DAV\Server($tree); - $server->httpRequest = new HTTP\Request('ACL','/test'); + $server->httpRequest = new HTTP\Request('ACL', '/test'); $body = ' @@ -110,6 +113,7 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { '; $server->httpRequest->setBody($body); + $server->addPlugin(new DAV\Auth\Plugin()); $server->addPlugin($acl); $acl->httpACL($server->httpRequest, $server->httpResponse); @@ -121,12 +125,12 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { */ function testUnknownPrivilege() { - $tree = array( - new MockACLNode('test',array()), - ); + $tree = [ + new MockACLNode('test', []), + ]; $acl = new Plugin(); $server = new DAV\Server($tree); - $server->httpRequest = new HTTP\Request('ACL','/test'); + $server->httpRequest = new HTTP\Request('ACL', '/test'); $body = ' @@ -135,6 +139,7 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { '; $server->httpRequest->setBody($body); + $server->addPlugin(new DAV\Auth\Plugin()); $server->addPlugin($acl); $acl->httpACL($server->httpRequest, $server->httpResponse); @@ -146,20 +151,24 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { */ function testAbstractPrivilege() { - $tree = array( - new MockACLNode('test',array()), - ); + $tree = [ + new MockACLNode('test', []), + ]; $acl = new Plugin(); $server = new DAV\Server($tree); - $server->httpRequest = new HTTP\Request('ACL','/test'); + $server->on('getSupportedPrivilegeSet', function($node, &$supportedPrivilegeSet) { + $supportedPrivilegeSet['{DAV:}foo'] = ['abstract' => true]; + }); + $server->httpRequest = new HTTP\Request('ACL', '/test'); $body = ' - - /principals/notfound + + /principals/foo/ '; $server->httpRequest->setBody($body); + $server->addPlugin(new DAV\Auth\Plugin()); $server->addPlugin($acl); $acl->httpACL($server->httpRequest, $server->httpResponse); @@ -171,20 +180,20 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { */ function testUpdateProtectedPrivilege() { - $oldACL = array( - array( + $oldACL = [ + [ 'principal' => 'principals/notfound', 'privilege' => '{DAV:}write', 'protected' => true, - ), - ); + ], + ]; - $tree = array( - new MockACLNode('test',$oldACL), - ); + $tree = [ + new MockACLNode('test', $oldACL), + ]; $acl = new Plugin(); $server = new DAV\Server($tree); - $server->httpRequest = new HTTP\Request('ACL','/test'); + $server->httpRequest = new HTTP\Request('ACL', '/test'); $body = ' @@ -193,6 +202,7 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { '; $server->httpRequest->setBody($body); + $server->addPlugin(new DAV\Auth\Plugin()); $server->addPlugin($acl); $acl->httpACL($server->httpRequest, $server->httpResponse); @@ -204,20 +214,20 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { */ function testUpdateProtectedPrivilege2() { - $oldACL = array( - array( + $oldACL = [ + [ 'principal' => 'principals/notfound', 'privilege' => '{DAV:}write', 'protected' => true, - ), - ); + ], + ]; - $tree = array( - new MockACLNode('test',$oldACL), - ); + $tree = [ + new MockACLNode('test', $oldACL), + ]; $acl = new Plugin(); $server = new DAV\Server($tree); - $server->httpRequest = new HTTP\Request('ACL','/test'); + $server->httpRequest = new HTTP\Request('ACL', '/test'); $body = ' @@ -226,6 +236,7 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { '; $server->httpRequest->setBody($body); + $server->addPlugin(new DAV\Auth\Plugin()); $server->addPlugin($acl); $acl->httpACL($server->httpRequest, $server->httpResponse); @@ -237,20 +248,20 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { */ function testUpdateProtectedPrivilege3() { - $oldACL = array( - array( + $oldACL = [ + [ 'principal' => 'principals/notfound', 'privilege' => '{DAV:}write', 'protected' => true, - ), - ); + ], + ]; - $tree = array( - new MockACLNode('test',$oldACL), - ); + $tree = [ + new MockACLNode('test', $oldACL), + ]; $acl = new Plugin(); $server = new DAV\Server($tree); - $server->httpRequest = new HTTP\Request('ACL','/test'); + $server->httpRequest = new HTTP\Request('ACL', '/test'); $body = ' @@ -259,6 +270,7 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { '; $server->httpRequest->setBody($body); + $server->addPlugin(new DAV\Auth\Plugin()); $server->addPlugin($acl); $acl->httpACL($server->httpRequest, $server->httpResponse); @@ -267,28 +279,28 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { function testSuccessComplex() { - $oldACL = array( - array( + $oldACL = [ + [ 'principal' => 'principals/foo', 'privilege' => '{DAV:}write', 'protected' => true, - ), - array( + ], + [ 'principal' => 'principals/bar', 'privilege' => '{DAV:}read', - ), - ); - - $tree = array( - $node = new MockACLNode('test',$oldACL), - new DAV\SimpleCollection('principals', array( - new MockPrincipal('foo','principals/foo'), - new MockPrincipal('baz','principals/baz'), - )), - ); + ], + ]; + + $tree = [ + $node = new MockACLNode('test', $oldACL), + new DAV\SimpleCollection('principals', [ + new MockPrincipal('foo', 'principals/foo'), + new MockPrincipal('baz', 'principals/baz'), + ]), + ]; $acl = new Plugin(); $server = new DAV\Server($tree); - $server->httpRequest = new HTTP\Request('ACL','/test'); + $server->httpRequest = new HTTP\Request('ACL', '/test'); $body = ' @@ -302,23 +314,24 @@ class ACLMethodTest extends \PHPUnit_Framework_TestCase { '; $server->httpRequest->setBody($body); + $server->addPlugin(new DAV\Auth\Plugin()); $server->addPlugin($acl); $this->assertFalse($acl->httpAcl($server->httpRequest, $server->httpResponse)); - $this->assertEquals(array( - array( + $this->assertEquals([ + [ 'principal' => 'principals/foo', 'privilege' => '{DAV:}write', 'protected' => true, - ), - array( + ], + [ 'principal' => 'principals/baz', 'privilege' => '{DAV:}write', 'protected' => false, - ), - ), $node->getACL()); + ], + ], $node->getACL()); } } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/AllowAccessTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/AllowAccessTest.php index 14a80003a..f16693625 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/AllowAccessTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/AllowAccessTest.php @@ -3,7 +3,6 @@ namespace Sabre\DAVACL; use Sabre\DAV; -use Sabre\HTTP; class AllowAccessTest extends \PHPUnit_Framework_TestCase { @@ -14,13 +13,24 @@ class AllowAccessTest extends \PHPUnit_Framework_TestCase { function setUp() { - $nodes = array( - new DAV\SimpleCollection('testdir'), - ); + $nodes = [ + new DAV\Mock\Collection('testdir', [ + 'file1.txt' => 'contents', + ]), + ]; $this->server = new DAV\Server($nodes); + $this->server->addPlugin( + new DAV\Auth\Plugin( + new DAV\Auth\Backend\Mock() + ) + ); + // Login + $this->server->getPlugin('auth')->beforeMethod( + new \Sabre\HTTP\Request(), + new \Sabre\HTTP\Response() + ); $aclPlugin = new Plugin(); - $aclPlugin->allowAccessToNodesWithoutACL = true; $this->server->addPlugin($aclPlugin); } @@ -64,16 +74,7 @@ class AllowAccessTest extends \PHPUnit_Framework_TestCase { function testPUT() { $this->server->httpRequest->setMethod('PUT'); - $this->server->httpRequest->setUrl('/testdir'); - - $this->assertTrue($this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse])); - - } - - function testACL() { - - $this->server->httpRequest->setMethod('ACL'); - $this->server->httpRequest->setUrl('/testdir'); + $this->server->httpRequest->setUrl('/testdir/file1.txt'); $this->assertTrue($this->server->emit('beforeMethod', [$this->server->httpRequest, $this->server->httpResponse])); diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/BlockAccessTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/BlockAccessTest.php index be3e9dae9..ceae9aed0 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/BlockAccessTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/BlockAccessTest.php @@ -3,7 +3,6 @@ namespace Sabre\DAVACL; use Sabre\DAV; -use Sabre\HTTP; class BlockAccessTest extends \PHPUnit_Framework_TestCase { @@ -21,7 +20,17 @@ class BlockAccessTest extends \PHPUnit_Framework_TestCase { $this->server = new DAV\Server($nodes); $this->plugin = new Plugin(); - $this->plugin->allowAccessToNodesWithoutACL = false; + $this->plugin->setDefaultAcl([]); + $this->server->addPlugin( + new DAV\Auth\Plugin( + new DAV\Auth\Backend\Mock() + ) + ); + // Login + $this->server->getPlugin('auth')->beforeMethod( + new \Sabre\HTTP\Request(), + new \Sabre\HTTP\Response() + ); $this->server->addPlugin($this->plugin); } @@ -178,10 +187,10 @@ class BlockAccessTest extends \PHPUnit_Framework_TestCase { 200 => [], 404 => [], 403 => [ - '{DAV:}displayname' => null, + '{DAV:}displayname' => null, '{DAV:}getcontentlength' => null, - '{DAV:}bar' => null, - '{DAV:}owner' => null, + '{DAV:}bar' => null, + '{DAV:}owner' => null, ], ]; diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/AceConflictTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/AceConflictTest.php index fc48af67f..1cdf2949f 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/AceConflictTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/AceConflictTest.php @@ -11,24 +11,24 @@ class AceConflictTest extends \PHPUnit_Framework_TestCase { $ex = new AceConflict('message'); $server = new DAV\Server(); - $dom = new \DOMDocument('1.0','utf-8'); - $root = $dom->createElementNS('DAV:','d:root'); + $dom = new \DOMDocument('1.0', 'utf-8'); + $root = $dom->createElementNS('DAV:', 'd:root'); $dom->appendChild($root); $ex->serialize($server, $root); - $xpaths = array( - '/d:root' => 1, + $xpaths = [ + '/d:root' => 1, '/d:root/d:no-ace-conflict' => 1, - ); + ]; // Reloading because PHP DOM sucks $dom2 = new \DOMDocument('1.0', 'utf-8'); $dom2->loadXML($dom->saveXML()); $dxpath = new \DOMXPath($dom2); - $dxpath->registerNamespace('d','DAV:'); - foreach($xpaths as $xpath=>$count) { + $dxpath->registerNamespace('d', 'DAV:'); + foreach ($xpaths as $xpath => $count) { $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count); diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NeedPrivilegesExceptionTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NeedPrivilegesExceptionTest.php index 7e66adab6..b13e7722d 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NeedPrivilegesExceptionTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NeedPrivilegesExceptionTest.php @@ -4,41 +4,41 @@ namespace Sabre\DAVACL\Exception; use Sabre\DAV; -class NeedPrivilegesTest extends \PHPUnit_Framework_TestCase { +class NeedPrivilegesExceptionTest extends \PHPUnit_Framework_TestCase { function testSerialize() { $uri = 'foo'; - $privileges = array( + $privileges = [ '{DAV:}read', '{DAV:}write', - ); + ]; $ex = new NeedPrivileges($uri, $privileges); $server = new DAV\Server(); - $dom = new \DOMDocument('1.0','utf-8'); - $root = $dom->createElementNS('DAV:','d:root'); + $dom = new \DOMDocument('1.0', 'utf-8'); + $root = $dom->createElementNS('DAV:', 'd:root'); $dom->appendChild($root); $ex->serialize($server, $root); - $xpaths = array( - '/d:root' => 1, - '/d:root/d:need-privileges' => 1, - '/d:root/d:need-privileges/d:resource' => 2, - '/d:root/d:need-privileges/d:resource/d:href' => 2, - '/d:root/d:need-privileges/d:resource/d:privilege' => 2, - '/d:root/d:need-privileges/d:resource/d:privilege/d:read' => 1, + $xpaths = [ + '/d:root' => 1, + '/d:root/d:need-privileges' => 1, + '/d:root/d:need-privileges/d:resource' => 2, + '/d:root/d:need-privileges/d:resource/d:href' => 2, + '/d:root/d:need-privileges/d:resource/d:privilege' => 2, + '/d:root/d:need-privileges/d:resource/d:privilege/d:read' => 1, '/d:root/d:need-privileges/d:resource/d:privilege/d:write' => 1, - ); + ]; // Reloading because PHP DOM sucks $dom2 = new \DOMDocument('1.0', 'utf-8'); $dom2->loadXML($dom->saveXML()); $dxpath = new \DOMXPath($dom2); - $dxpath->registerNamespace('d','DAV:'); - foreach($xpaths as $xpath=>$count) { + $dxpath->registerNamespace('d', 'DAV:'); + foreach ($xpaths as $xpath => $count) { $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count); diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NoAbstractTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NoAbstractTest.php index 2406c1c38..f52b17371 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NoAbstractTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NoAbstractTest.php @@ -11,24 +11,24 @@ class NoAbstractTest extends \PHPUnit_Framework_TestCase { $ex = new NoAbstract('message'); $server = new DAV\Server(); - $dom = new \DOMDocument('1.0','utf-8'); - $root = $dom->createElementNS('DAV:','d:root'); + $dom = new \DOMDocument('1.0', 'utf-8'); + $root = $dom->createElementNS('DAV:', 'd:root'); $dom->appendChild($root); $ex->serialize($server, $root); - $xpaths = array( - '/d:root' => 1, + $xpaths = [ + '/d:root' => 1, '/d:root/d:no-abstract' => 1, - ); + ]; // Reloading because PHP DOM sucks $dom2 = new \DOMDocument('1.0', 'utf-8'); $dom2->loadXML($dom->saveXML()); $dxpath = new \DOMXPath($dom2); - $dxpath->registerNamespace('d','DAV:'); - foreach($xpaths as $xpath=>$count) { + $dxpath->registerNamespace('d', 'DAV:'); + foreach ($xpaths as $xpath => $count) { $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count); diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotRecognizedPrincipalTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotRecognizedPrincipalTest.php index 6077b0ba5..df89aaf84 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotRecognizedPrincipalTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotRecognizedPrincipalTest.php @@ -11,24 +11,24 @@ class NotRecognizedPrincipalTest extends \PHPUnit_Framework_TestCase { $ex = new NotRecognizedPrincipal('message'); $server = new DAV\Server(); - $dom = new \DOMDocument('1.0','utf-8'); - $root = $dom->createElementNS('DAV:','d:root'); + $dom = new \DOMDocument('1.0', 'utf-8'); + $root = $dom->createElementNS('DAV:', 'd:root'); $dom->appendChild($root); $ex->serialize($server, $root); - $xpaths = array( - '/d:root' => 1, + $xpaths = [ + '/d:root' => 1, '/d:root/d:recognized-principal' => 1, - ); + ]; // Reloading because PHP DOM sucks $dom2 = new \DOMDocument('1.0', 'utf-8'); $dom2->loadXML($dom->saveXML()); $dxpath = new \DOMXPath($dom2); - $dxpath->registerNamespace('d','DAV:'); - foreach($xpaths as $xpath=>$count) { + $dxpath->registerNamespace('d', 'DAV:'); + foreach ($xpaths as $xpath => $count) { $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count); diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotSupportedPrivilegeTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotSupportedPrivilegeTest.php index 8e7b3685d..50623952b 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotSupportedPrivilegeTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/Exception/NotSupportedPrivilegeTest.php @@ -11,24 +11,24 @@ class NotSupportedPrivilegeTest extends \PHPUnit_Framework_TestCase { $ex = new NotSupportedPrivilege('message'); $server = new DAV\Server(); - $dom = new \DOMDocument('1.0','utf-8'); - $root = $dom->createElementNS('DAV:','d:root'); + $dom = new \DOMDocument('1.0', 'utf-8'); + $root = $dom->createElementNS('DAV:', 'd:root'); $dom->appendChild($root); $ex->serialize($server, $root); - $xpaths = array( - '/d:root' => 1, + $xpaths = [ + '/d:root' => 1, '/d:root/d:not-supported-privilege' => 1, - ); + ]; // Reloading because PHP DOM sucks $dom2 = new \DOMDocument('1.0', 'utf-8'); $dom2->loadXML($dom->saveXML()); $dxpath = new \DOMXPath($dom2); - $dxpath->registerNamespace('d','DAV:'); - foreach($xpaths as $xpath=>$count) { + $dxpath->registerNamespace('d', 'DAV:'); + foreach ($xpaths as $xpath => $count) { $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count); diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/ExpandPropertiesTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/ExpandPropertiesTest.php index 5e99f2e73..0612b5474 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/ExpandPropertiesTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/ExpandPropertiesTest.php @@ -11,31 +11,31 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { function getServer() { - $tree = array( - new DAV\Mock\PropertiesCollection('node1', [], array( + $tree = [ + new DAV\Mock\PropertiesCollection('node1', [], [ '{http://sabredav.org/ns}simple' => 'foo', '{http://sabredav.org/ns}href' => new DAV\Xml\Property\Href('node2'), - '{DAV:}displayname' => 'Node 1', - )), - new DAV\Mock\PropertiesCollection('node2', [], array( + '{DAV:}displayname' => 'Node 1', + ]), + new DAV\Mock\PropertiesCollection('node2', [], [ + '{http://sabredav.org/ns}simple' => 'simple', + '{http://sabredav.org/ns}hreflist' => new DAV\Xml\Property\Href(['node1', 'node3']), + '{DAV:}displayname' => 'Node 2', + ]), + new DAV\Mock\PropertiesCollection('node3', [], [ '{http://sabredav.org/ns}simple' => 'simple', - '{http://sabredav.org/ns}hreflist' => new DAV\Xml\Property\Href(['node1','node3']), - '{DAV:}displayname' => 'Node 2', - )), - new DAV\Mock\PropertiesCollection('node3', [], array( - '{http://sabredav.org/ns}simple' => 'simple', - '{DAV:}displayname' => 'Node 3', - )), - ); + '{DAV:}displayname' => 'Node 3', + ]), + ]; $fakeServer = new DAV\Server($tree); $fakeServer->sapi = new HTTP\SapiMock(); $fakeServer->debugExceptions = true; $fakeServer->httpResponse = new HTTP\ResponseMock(); $plugin = new Plugin(); - $plugin->allowAccessToNodesWithoutACL = true; - + $plugin->allowUnauthenticatedAccess = false; $this->assertTrue($plugin instanceof Plugin); + $fakeServer->addPlugin($plugin); $this->assertEquals($plugin, $fakeServer->getPlugin('acl')); @@ -53,11 +53,11 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { '; - $serverVars = array( + $serverVars = [ 'REQUEST_METHOD' => 'REPORT', 'HTTP_DEPTH' => '0', 'REQUEST_URI' => '/node1', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody($xml); @@ -67,38 +67,38 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { $server->exec(); - $this->assertEquals(207, $server->httpResponse->status,'Incorrect status code received. Full body: ' . $server->httpResponse->body); - $this->assertEquals(array( + $this->assertEquals(207, $server->httpResponse->status, 'Incorrect status code received. Full body: ' . $server->httpResponse->body); + $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ), $server->httpResponse->getHeaders()); + 'Content-Type' => ['application/xml; charset=utf-8'], + ], $server->httpResponse->getHeaders()); - $check = array( + $check = [ '/d:multistatus', - '/d:multistatus/d:response' => 1, - '/d:multistatus/d:response/d:href' => 1, - '/d:multistatus/d:response/d:propstat' => 2, - '/d:multistatus/d:response/d:propstat/d:prop' => 2, + '/d:multistatus/d:response' => 1, + '/d:multistatus/d:response/d:href' => 1, + '/d:multistatus/d:response/d:propstat' => 2, + '/d:multistatus/d:response/d:propstat/d:prop' => 2, '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:simple' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:href' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:simple' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:href' => 1, '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:href' => 1, - ); + ]; $xml = simplexml_load_string($server->httpResponse->body); - $xml->registerXPathNamespace('d','DAV:'); - $xml->registerXPathNamespace('s','http://sabredav.org/ns'); - foreach($check as $v1=>$v2) { + $xml->registerXPathNamespace('d', 'DAV:'); + $xml->registerXPathNamespace('s', 'http://sabredav.org/ns'); + foreach ($check as $v1 => $v2) { - $xpath = is_int($v1)?$v2:$v1; + $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: ' . $server->httpResponse->body); + $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response: ' . $server->httpResponse->body); } @@ -116,11 +116,11 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { '; - $serverVars = array( + $serverVars = [ 'REQUEST_METHOD' => 'REPORT', 'HTTP_DEPTH' => '0', 'REQUEST_URI' => '/node1', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody($xml); @@ -131,39 +131,39 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { $server->exec(); $this->assertEquals(207, $server->httpResponse->status, 'Incorrect response status received. Full response body: ' . $server->httpResponse->body); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ), $server->httpResponse->getHeaders()); + 'Content-Type' => ['application/xml; charset=utf-8'], + ], $server->httpResponse->getHeaders()); - $check = array( + $check = [ '/d:multistatus', - '/d:multistatus/d:response' => 1, - '/d:multistatus/d:response/d:href' => 1, - '/d:multistatus/d:response/d:propstat' => 1, - '/d:multistatus/d:response/d:propstat/d:prop' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:href' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:href' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:propstat' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:propstat/d:prop' => 1, + '/d:multistatus/d:response' => 1, + '/d:multistatus/d:response/d:href' => 1, + '/d:multistatus/d:response/d:propstat' => 1, + '/d:multistatus/d:response/d:propstat/d:prop' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:href' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:href' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:propstat' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:propstat/d:prop' => 1, '/d:multistatus/d:response/d:propstat/d:prop/s:href/d:response/d:propstat/d:prop/d:displayname' => 1, - ); + ]; $xml = simplexml_load_string($server->httpResponse->body); - $xml->registerXPathNamespace('d','DAV:'); - $xml->registerXPathNamespace('s','http://sabredav.org/ns'); - foreach($check as $v1=>$v2) { + $xml->registerXPathNamespace('d', 'DAV:'); + $xml->registerXPathNamespace('s', 'http://sabredav.org/ns'); + foreach ($check as $v1 => $v2) { - $xpath = is_int($v1)?$v2:$v1; + $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->getBodyAsString()); + $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . ' Full response body: ' . $server->httpResponse->getBodyAsString()); } @@ -181,11 +181,11 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { '; - $serverVars = array( + $serverVars = [ 'REQUEST_METHOD' => 'REPORT', 'HTTP_DEPTH' => '0', 'REQUEST_URI' => '/node2', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody($xml); @@ -196,39 +196,39 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { $server->exec(); $this->assertEquals(207, $server->httpResponse->status); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ), $server->httpResponse->getHeaders()); + 'Content-Type' => ['application/xml; charset=utf-8'], + ], $server->httpResponse->getHeaders()); - $check = array( + $check = [ '/d:multistatus', - '/d:multistatus/d:response' => 1, - '/d:multistatus/d:response/d:href' => 1, - '/d:multistatus/d:response/d:propstat' => 1, - '/d:multistatus/d:response/d:propstat/d:prop' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response' => 2, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:href' => 2, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat' => 2, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop' => 2, + '/d:multistatus/d:response' => 1, + '/d:multistatus/d:response/d:href' => 1, + '/d:multistatus/d:response/d:propstat' => 1, + '/d:multistatus/d:response/d:propstat/d:prop' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:href' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop' => 2, '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/d:displayname' => 2, - ); + ]; $xml = simplexml_load_string($server->httpResponse->body); - $xml->registerXPathNamespace('d','DAV:'); - $xml->registerXPathNamespace('s','http://sabredav.org/ns'); - foreach($check as $v1=>$v2) { + $xml->registerXPathNamespace('d', 'DAV:'); + $xml->registerXPathNamespace('s', 'http://sabredav.org/ns'); + foreach ($check as $v1 => $v2) { - $xpath = is_int($v1)?$v2:$v1; + $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)); + $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result)); } @@ -249,11 +249,11 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { '; - $serverVars = array( + $serverVars = [ 'REQUEST_METHOD' => 'REPORT', 'HTTP_DEPTH' => '0', 'REQUEST_URI' => '/node2', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody($xml); @@ -264,45 +264,45 @@ class ExpandPropertiesTest extends \PHPUnit_Framework_TestCase { $server->exec(); $this->assertEquals(207, $server->httpResponse->status); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ), $server->httpResponse->getHeaders()); + 'Content-Type' => ['application/xml; charset=utf-8'], + ], $server->httpResponse->getHeaders()); - $check = array( + $check = [ '/d:multistatus', - '/d:multistatus/d:response' => 1, - '/d:multistatus/d:response/d:href' => 1, - '/d:multistatus/d:response/d:propstat' => 1, - '/d:multistatus/d:response/d:propstat/d:prop' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response' => 2, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:href' => 2, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat' => 3, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop' => 3, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/d:displayname' => 2, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href' => 2, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:href' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:propstat' => 1, - '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:propstat/d:prop' => 1, + '/d:multistatus/d:response' => 1, + '/d:multistatus/d:response/d:href' => 1, + '/d:multistatus/d:response/d:propstat' => 1, + '/d:multistatus/d:response/d:propstat/d:prop' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:href' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat' => 3, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop' => 3, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/d:displayname' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href' => 2, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:href' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:propstat' => 1, + '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:propstat/d:prop' => 1, '/d:multistatus/d:response/d:propstat/d:prop/s:hreflist/d:response/d:propstat/d:prop/s:href/d:response/d:propstat/d:prop/d:displayname' => 1, - ); + ]; $xml = simplexml_load_string($server->httpResponse->body); - $xml->registerXPathNamespace('d','DAV:'); - $xml->registerXPathNamespace('s','http://sabredav.org/ns'); - foreach($check as $v1=>$v2) { + $xml->registerXPathNamespace('d', 'DAV:'); + $xml->registerXPathNamespace('s', 'http://sabredav.org/ns'); + foreach ($check as $v1 => $v2) { - $xpath = is_int($v1)?$v2:$v1; + $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)); + $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result)); } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/MockACLNode.php b/vendor/sabre/dav/tests/Sabre/DAVACL/MockACLNode.php index 7b3e8fc12..2d9744e29 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/MockACLNode.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/MockACLNode.php @@ -3,14 +3,13 @@ namespace Sabre\DAVACL; use Sabre\DAV; -use Sabre\HTTP; class MockACLNode extends DAV\Node implements IACL { public $name; public $acl; - function __construct($name, array $acl = array()) { + function __construct($name, array $acl = []) { $this->name = $name; $this->acl = $acl; diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/MockPrincipal.php b/vendor/sabre/dav/tests/Sabre/DAVACL/MockPrincipal.php index dd8542b8d..934906802 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/MockPrincipal.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/MockPrincipal.php @@ -3,16 +3,15 @@ namespace Sabre\DAVACL; use Sabre\DAV; -use Sabre\HTTP; class MockPrincipal extends DAV\Node implements IPrincipal { public $name; public $principalUrl; - public $groupMembership = array(); - public $groupMemberSet = array(); + public $groupMembership = []; + public $groupMemberSet = []; - function __construct($name,$principalUrl,array $groupMembership = array(), array $groupMemberSet = array()) { + function __construct($name, $principalUrl, array $groupMembership = [], array $groupMemberSet = []) { $this->name = $name; $this->principalUrl = $principalUrl; @@ -35,7 +34,7 @@ class MockPrincipal extends DAV\Node implements IPrincipal { function getAlternateUriSet() { - return array(); + return []; } @@ -63,4 +62,3 @@ class MockPrincipal extends DAV\Node implements IPrincipal { } } - diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginAdminTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginAdminTest.php index fb7516a78..8552448f5 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginAdminTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginAdminTest.php @@ -5,7 +5,6 @@ namespace Sabre\DAVACL; use Sabre\DAV; use Sabre\HTTP; - require_once 'Sabre/DAVACL/MockACLNode.php'; require_once 'Sabre/HTTP/ResponseMock.php'; @@ -17,10 +16,10 @@ class PluginAdminTest extends \PHPUnit_Framework_TestCase { $principalBackend = new PrincipalBackend\Mock(); - $tree = array( - new MockACLNode('adminonly', array()), + $tree = [ + new MockACLNode('adminonly', []), new PrincipalCollection($principalBackend), - ); + ]; $this->server = new DAV\Server($tree); $this->server->sapi = new HTTP\SapiMock(); @@ -33,11 +32,11 @@ class PluginAdminTest extends \PHPUnit_Framework_TestCase { $plugin = new Plugin(); $this->server->addPlugin($plugin); - $request = HTTP\Sapi::createFromServerArray(array( + $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'OPTIONS', - 'HTTP_DEPTH' => 1, - 'REQUEST_URI' => '/adminonly', - )); + 'HTTP_DEPTH' => 1, + 'REQUEST_URI' => '/adminonly', + ]); $response = new HTTP\ResponseMock(); @@ -56,16 +55,16 @@ class PluginAdminTest extends \PHPUnit_Framework_TestCase { function testAdminAccess() { $plugin = new Plugin(); - $plugin->adminPrincipals = array( + $plugin->adminPrincipals = [ 'principals/admin', - ); + ]; $this->server->addPlugin($plugin); - $request = HTTP\Sapi::createFromServerArray(array( + $request = HTTP\Sapi::createFromServerArray([ 'REQUEST_METHOD' => 'OPTIONS', - 'HTTP_DEPTH' => 1, - 'REQUEST_URI' => '/adminonly', - )); + 'HTTP_DEPTH' => 1, + 'REQUEST_URI' => '/adminonly', + ]); $response = new HTTP\ResponseMock(); diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php index e5b7e1a3f..5762ac902 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php @@ -10,6 +10,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { function testPrincipalCollectionSet() { $plugin = new Plugin(); + $plugin->allowUnauthenticatedAccess = false; $plugin->principalCollectionSet = [ 'principals1', 'principals2', @@ -25,8 +26,8 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $result = $server->getPropertiesForPath('', $requestedProperties); $result = $result[0]; - $this->assertEquals(1,count($result[200])); - $this->assertArrayHasKey('{DAV:}principal-collection-set',$result[200]); + $this->assertEquals(1, count($result[200])); + $this->assertArrayHasKey('{DAV:}principal-collection-set', $result[200]); $this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $result[200]['{DAV:}principal-collection-set']); $expected = [ @@ -56,8 +57,8 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $result = $fakeServer->getPropertiesForPath('', $requestedProperties); $result = $result[0]; - $this->assertEquals(1,count($result[200])); - $this->assertArrayHasKey('{DAV:}current-user-principal',$result[200]); + $this->assertEquals(1, count($result[200])); + $this->assertArrayHasKey('{DAV:}current-user-principal', $result[200]); $this->assertInstanceOf('Sabre\DAVACL\Xml\Property\Principal', $result[200]['{DAV:}current-user-principal']); $this->assertEquals(Xml\Property\Principal::UNAUTHENTICATED, $result[200]['{DAV:}current-user-principal']->getType()); @@ -67,8 +68,8 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $result = $fakeServer->getPropertiesForPath('', $requestedProperties); $result = $result[0]; - $this->assertEquals(1,count($result[200])); - $this->assertArrayHasKey('{DAV:}current-user-principal',$result[200]); + $this->assertEquals(1, count($result[200])); + $this->assertArrayHasKey('{DAV:}current-user-principal', $result[200]); $this->assertInstanceOf('Sabre\DAVACL\Xml\Property\Principal', $result[200]['{DAV:}current-user-principal']); $this->assertEquals(Xml\Property\Principal::HREF, $result[200]['{DAV:}current-user-principal']->getType()); $this->assertEquals('principals/admin/', $result[200]['{DAV:}current-user-principal']->getHref()); @@ -78,6 +79,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { function testSupportedPrivilegeSet() { $plugin = new Plugin(); + $plugin->allowUnauthenticatedAccess = false; $server = new DAV\Server(); $server->addPlugin($plugin); @@ -88,8 +90,8 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $result = $server->getPropertiesForPath('', $requestedProperties); $result = $result[0]; - $this->assertEquals(1,count($result[200])); - $this->assertArrayHasKey('{DAV:}supported-privilege-set',$result[200]); + $this->assertEquals(1, count($result[200])); + $this->assertArrayHasKey('{DAV:}supported-privilege-set', $result[200]); $this->assertInstanceOf('Sabre\\DAVACL\\Xml\\Property\\SupportedPrivilegeSet', $result[200]['{DAV:}supported-privilege-set']); $server = new DAV\Server(); @@ -98,26 +100,25 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $result = $server->xml->write('{DAV:}root', $prop); $xpaths = [ - '/d:root' => 1, - '/d:root/d:supported-privilege' => 1, - '/d:root/d:supported-privilege/d:privilege' => 1, - '/d:root/d:supported-privilege/d:privilege/d:all' => 1, - '/d:root/d:supported-privilege/d:abstract' => 1, - '/d:root/d:supported-privilege/d:supported-privilege' => 2, - '/d:root/d:supported-privilege/d:supported-privilege/d:privilege' => 2, - '/d:root/d:supported-privilege/d:supported-privilege/d:privilege/d:read' => 1, - '/d:root/d:supported-privilege/d:supported-privilege/d:privilege/d:write' => 1, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege' => 8, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege' => 8, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:read-acl' => 1, + '/d:root' => 1, + '/d:root/d:supported-privilege' => 1, + '/d:root/d:supported-privilege/d:privilege' => 1, + '/d:root/d:supported-privilege/d:privilege/d:all' => 1, + '/d:root/d:supported-privilege/d:abstract' => 0, + '/d:root/d:supported-privilege/d:supported-privilege' => 2, + '/d:root/d:supported-privilege/d:supported-privilege/d:privilege' => 2, + '/d:root/d:supported-privilege/d:supported-privilege/d:privilege/d:read' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:privilege/d:write' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege' => 7, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege' => 7, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:read-acl' => 1, '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:read-current-user-privilege-set' => 1, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:write-content' => 1, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:write-properties' => 1, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:write-acl' => 1, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:bind' => 1, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:unbind' => 1, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:unlock' => 1, - '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:abstract' => 0, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:write-content' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:write-properties' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:bind' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:unbind' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:privilege/d:unlock' => 1, + '/d:root/d:supported-privilege/d:supported-privilege/d:supported-privilege/d:abstract' => 0, ]; @@ -126,10 +127,10 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $dom2->loadXML($result); $dxpath = new \DOMXPath($dom2); - $dxpath->registerNamespace('d','DAV:'); - foreach($xpaths as $xpath=>$count) { + $dxpath->registerNamespace('d', 'DAV:'); + foreach ($xpaths as $xpath => $count) { - $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count. ' Full XML: ' . $result); + $this->assertEquals($count, $dxpath->query($xpath)->length, 'Looking for : ' . $xpath . ', we could only find ' . $dxpath->query($xpath)->length . ' elements, while we expected ' . $count . ' Full XML: ' . $result); } @@ -138,6 +139,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { function testACL() { $plugin = new Plugin(); + $plugin->allowUnauthenticatedAccess = false; $nodes = [ new MockACLNode('foo', [ @@ -147,7 +149,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { ] ]), new DAV\SimpleCollection('principals', [ - $principal = new MockPrincipal('admin','principals/admin'), + $principal = new MockPrincipal('admin', 'principals/admin'), ]), ]; @@ -167,8 +169,8 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $result = $server->getPropertiesForPath('foo', $requestedProperties); $result = $result[0]; - $this->assertEquals(1,count($result[200]),'The {DAV:}acl property did not return from the list. Full list: ' . print_r($result, true)); - $this->assertArrayHasKey('{DAV:}acl',$result[200]); + $this->assertEquals(1, count($result[200]), 'The {DAV:}acl property did not return from the list. Full list: ' . print_r($result, true)); + $this->assertArrayHasKey('{DAV:}acl', $result[200]); $this->assertInstanceOf('Sabre\\DAVACL\\Xml\Property\\Acl', $result[200]['{DAV:}acl']); } @@ -176,6 +178,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { function testACLRestrictions() { $plugin = new Plugin(); + $plugin->allowUnauthenticatedAccess = false; $nodes = [ new MockACLNode('foo', [ @@ -185,7 +188,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { ] ]), new DAV\SimpleCollection('principals', [ - $principal = new MockPrincipal('admin','principals/admin'), + $principal = new MockPrincipal('admin', 'principals/admin'), ]), ]; @@ -205,8 +208,8 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $result = $server->getPropertiesForPath('foo', $requestedProperties); $result = $result[0]; - $this->assertEquals(1,count($result[200]),'The {DAV:}acl-restrictions property did not return from the list. Full list: ' . print_r($result, true)); - $this->assertArrayHasKey('{DAV:}acl-restrictions',$result[200]); + $this->assertEquals(1, count($result[200]), 'The {DAV:}acl-restrictions property did not return from the list. Full list: ' . print_r($result, true)); + $this->assertArrayHasKey('{DAV:}acl-restrictions', $result[200]); $this->assertInstanceOf('Sabre\\DAVACL\\Xml\\Property\\AclRestrictions', $result[200]['{DAV:}acl-restrictions']); } @@ -215,7 +218,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $tree = [ new DAV\SimpleCollection('principals', [ - $principal = new MockPrincipal('user','principals/user'), + $principal = new MockPrincipal('user', 'principals/user'), ]) ]; @@ -223,6 +226,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { //$plugin = new DAV\Auth\Plugin(new DAV\Auth\MockBackend()) //$fakeServer->addPlugin($plugin); $plugin = new Plugin(); + $plugin->allowUnauthenticatedAccess = false; $fakeServer->addPlugin($plugin); $requestedProperties = [ @@ -243,7 +247,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $tree = [ new DAV\SimpleCollection('principals', [ - $principal = new MockPrincipal('user','principals/user'), + $principal = new MockPrincipal('user', 'principals/user'), ]), ]; @@ -251,6 +255,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { //$plugin = new DAV\Auth\Plugin(new DAV\Auth\MockBackend()); //$fakeServer->addPlugin($plugin); $plugin = new Plugin(); + $plugin->allowUnauthenticatedAccess = false; $fakeServer->addPlugin($plugin); $requestedProperties = [ @@ -272,7 +277,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $tree = [ new DAV\SimpleCollection('principals', [ - $principal = new MockPrincipal('user','principals/user'), + $principal = new MockPrincipal('user', 'principals/user'), ]), ]; @@ -280,6 +285,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { //$plugin = new DAV\Auth\Plugin(new DAV\Auth\MockBackend()); //$fakeServer->addPlugin($plugin); $plugin = new Plugin(); + $plugin->allowUnauthenticatedAccess = false; $fakeServer->addPlugin($plugin); $requestedProperties = [ @@ -301,12 +307,13 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $tree = [ new DAV\SimpleCollection('principals', [ - $principal = new MockPrincipal('user','principals/user'), + $principal = new MockPrincipal('user', 'principals/user'), ]), ]; $fakeServer = new DAV\Server($tree); $plugin = new Plugin(); + $plugin->allowUnauthenticatedAccess = false; $fakeServer->addPlugin($plugin); $requestedProperties = [ @@ -328,12 +335,13 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase { $tree = [ new DAV\SimpleCollection('principals', [ - $principal = new MockPrincipal('user','principals/user'), + $principal = new MockPrincipal('user', 'principals/user'), ]), ]; $fakeServer = new DAV\Server($tree); $plugin = new Plugin(); + $plugin->allowUnauthenticatedAccess = false; $fakeServer->addPlugin($plugin); $requestedProperties = [ diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginUpdatePropertiesTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginUpdatePropertiesTest.php index 64cedd142..0147e6a61 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginUpdatePropertiesTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginUpdatePropertiesTest.php @@ -3,28 +3,25 @@ namespace Sabre\DAVACL; use Sabre\DAV; -use Sabre\HTTP; - - -require_once 'Sabre/DAVACL/MockPrincipal.php'; class PluginUpdatePropertiesTest extends \PHPUnit_Framework_TestCase { function testUpdatePropertiesPassthrough() { - $tree = array( + $tree = [ new DAV\SimpleCollection('foo'), - ); + ]; $server = new DAV\Server($tree); + $server->addPlugin(new DAV\Auth\Plugin()); $server->addPlugin(new Plugin()); - $result = $server->updateProperties('foo', array( + $result = $server->updateProperties('foo', [ '{DAV:}foo' => 'bar', - )); + ]); - $expected = array( + $expected = [ '{DAV:}foo' => 403, - ); + ]; $this->assertEquals($expected, $result); @@ -32,35 +29,39 @@ class PluginUpdatePropertiesTest extends \PHPUnit_Framework_TestCase { function testRemoveGroupMembers() { - $tree = array( - new MockPrincipal('foo','foo'), - ); + $tree = [ + new MockPrincipal('foo', 'foo'), + ]; $server = new DAV\Server($tree); - $server->addPlugin(new Plugin()); + $plugin = new Plugin(); + $plugin->allowUnauthenticatedAccess = false; + $server->addPlugin($plugin); - $result = $server->updateProperties('foo', array( + $result = $server->updateProperties('foo', [ '{DAV:}group-member-set' => null, - )); + ]); - $expected = array( + $expected = [ '{DAV:}group-member-set' => 204 - ); + ]; $this->assertEquals($expected, $result); - $this->assertEquals(array(),$tree[0]->getGroupMemberSet()); + $this->assertEquals([], $tree[0]->getGroupMemberSet()); } function testSetGroupMembers() { $tree = [ - new MockPrincipal('foo','foo'), + new MockPrincipal('foo', 'foo'), ]; $server = new DAV\Server($tree); - $server->addPlugin(new Plugin()); + $plugin = new Plugin(); + $plugin->allowUnauthenticatedAccess = false; + $server->addPlugin($plugin); $result = $server->updateProperties('foo', [ - '{DAV:}group-member-set' => new DAV\Xml\Property\Href(['/bar','/baz'], true), + '{DAV:}group-member-set' => new DAV\Xml\Property\Href(['/bar', '/baz'], true), ]); $expected = [ @@ -68,7 +69,7 @@ class PluginUpdatePropertiesTest extends \PHPUnit_Framework_TestCase { ]; $this->assertEquals($expected, $result); - $this->assertEquals(['bar', 'baz'],$tree[0]->getGroupMemberSet()); + $this->assertEquals(['bar', 'baz'], $tree[0]->getGroupMemberSet()); } @@ -77,15 +78,17 @@ class PluginUpdatePropertiesTest extends \PHPUnit_Framework_TestCase { */ function testSetBadValue() { - $tree = array( - new MockPrincipal('foo','foo'), - ); + $tree = [ + new MockPrincipal('foo', 'foo'), + ]; $server = new DAV\Server($tree); - $server->addPlugin(new Plugin()); + $plugin = new Plugin(); + $plugin->allowUnauthenticatedAccess = false; + $server->addPlugin($plugin); - $result = $server->updateProperties('foo', array( + $result = $server->updateProperties('foo', [ '{DAV:}group-member-set' => new \StdClass(), - )); + ]); } @@ -95,10 +98,12 @@ class PluginUpdatePropertiesTest extends \PHPUnit_Framework_TestCase { new DAV\SimpleCollection('foo'), ]; $server = new DAV\Server($tree); - $server->addPlugin(new Plugin()); + $plugin = new Plugin(); + $plugin->allowUnauthenticatedAccess = false; + $server->addPlugin($plugin); $result = $server->updateProperties('foo', [ - '{DAV:}group-member-set' => new DAV\Xml\Property\Href(['/bar','/baz'],false), + '{DAV:}group-member-set' => new DAV\Xml\Property\Href(['/bar', '/baz'], false), ]); $expected = [ diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/AbstractPDOTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/AbstractPDOTest.php index 3814ebc0d..9fef3018d 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/AbstractPDOTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/AbstractPDOTest.php @@ -5,10 +5,24 @@ namespace Sabre\DAVACL\PrincipalBackend; use Sabre\DAV; use Sabre\HTTP; - abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { - abstract function getPDO(); + use DAV\DbTestHelperTrait; + + function setUp() { + + $this->dropTables(['principals', 'groupmembers']); + $this->createSchema('principals'); + + $pdo = $this->getPDO(); + + $pdo->query("INSERT INTO principals (uri,email,displayname) VALUES ('principals/user','user@example.org','User')"); + $pdo->query("INSERT INTO principals (uri,email,displayname) VALUES ('principals/group','group@example.org','Group')"); + + $pdo->query("INSERT INTO groupmembers (principal_id,member_id) VALUES (5,4)"); + + } + function testConstruct() { @@ -26,21 +40,26 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $pdo = $this->getPDO(); $backend = new PDO($pdo); - $expected = array( - array( - 'uri' => 'principals/user', + $expected = [ + [ + 'uri' => 'principals/admin', + '{http://sabredav.org/ns}email-address' => 'admin@example.org', + '{DAV:}displayname' => 'Administrator', + ], + [ + 'uri' => 'principals/user', '{http://sabredav.org/ns}email-address' => 'user@example.org', - '{DAV:}displayname' => 'User', - ), - array( - 'uri' => 'principals/group', + '{DAV:}displayname' => 'User', + ], + [ + 'uri' => 'principals/group', '{http://sabredav.org/ns}email-address' => 'group@example.org', - '{DAV:}displayname' => 'Group', - ), - ); + '{DAV:}displayname' => 'Group', + ], + ]; $this->assertEquals($expected, $backend->getPrincipalsByPrefix('principals')); - $this->assertEquals(array(), $backend->getPrincipalsByPrefix('foo')); + $this->assertEquals([], $backend->getPrincipalsByPrefix('foo')); } @@ -52,12 +71,12 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $pdo = $this->getPDO(); $backend = new PDO($pdo); - $expected = array( - 'id' => 1, - 'uri' => 'principals/user', + $expected = [ + 'id' => 4, + 'uri' => 'principals/user', '{http://sabredav.org/ns}email-address' => 'user@example.org', - '{DAV:}displayname' => 'User', - ); + '{DAV:}displayname' => 'User', + ]; $this->assertEquals($expected, $backend->getPrincipalByPath('principals/user')); $this->assertEquals(null, $backend->getPrincipalByPath('foo')); @@ -68,9 +87,9 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $pdo = $this->getPDO(); $backend = new PDO($pdo); - $expected = array('principals/user'); + $expected = ['principals/user']; - $this->assertEquals($expected,$backend->getGroupMemberSet('principals/group')); + $this->assertEquals($expected, $backend->getGroupMemberSet('principals/group')); } @@ -78,9 +97,9 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $pdo = $this->getPDO(); $backend = new PDO($pdo); - $expected = array('principals/group'); + $expected = ['principals/group']; - $this->assertEquals($expected,$backend->getGroupMembership('principals/user')); + $this->assertEquals($expected, $backend->getGroupMembership('principals/user')); } @@ -90,15 +109,15 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { // Start situation $backend = new PDO($pdo); - $this->assertEquals(array('principals/user'), $backend->getGroupMemberSet('principals/group')); + $this->assertEquals(['principals/user'], $backend->getGroupMemberSet('principals/group')); // Removing all principals - $backend->setGroupMemberSet('principals/group', array()); - $this->assertEquals(array(), $backend->getGroupMemberSet('principals/group')); + $backend->setGroupMemberSet('principals/group', []); + $this->assertEquals([], $backend->getGroupMemberSet('principals/group')); // Adding principals again - $backend->setGroupMemberSet('principals/group', array('principals/user')); - $this->assertEquals(array('principals/user'), $backend->getGroupMemberSet('principals/group')); + $backend->setGroupMemberSet('principals/group', ['principals/user']); + $this->assertEquals(['principals/user'], $backend->getGroupMemberSet('principals/group')); } @@ -109,17 +128,17 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $backend = new PDO($pdo); - $result = $backend->searchPrincipals('principals', array('{DAV:}blabla' => 'foo')); - $this->assertEquals(array(), $result); + $result = $backend->searchPrincipals('principals', ['{DAV:}blabla' => 'foo']); + $this->assertEquals([], $result); - $result = $backend->searchPrincipals('principals', array('{DAV:}displayname' => 'ou')); - $this->assertEquals(array('principals/group'), $result); + $result = $backend->searchPrincipals('principals', ['{DAV:}displayname' => 'ou']); + $this->assertEquals(['principals/group'], $result); - $result = $backend->searchPrincipals('principals', array('{DAV:}displayname' => 'UsEr', '{http://sabredav.org/ns}email-address' => 'USER@EXAMPLE')); - $this->assertEquals(array('principals/user'), $result); + $result = $backend->searchPrincipals('principals', ['{DAV:}displayname' => 'UsEr', '{http://sabredav.org/ns}email-address' => 'USER@EXAMPLE']); + $this->assertEquals(['principals/user'], $result); - $result = $backend->searchPrincipals('mom', array('{DAV:}displayname' => 'UsEr', '{http://sabredav.org/ns}email-address' => 'USER@EXAMPLE')); - $this->assertEquals(array(), $result); + $result = $backend->searchPrincipals('mom', ['{DAV:}displayname' => 'UsEr', '{http://sabredav.org/ns}email-address' => 'USER@EXAMPLE']); + $this->assertEquals([], $result); } @@ -137,12 +156,12 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $this->assertTrue($result); - $this->assertEquals(array( - 'id' => 1, - 'uri' => 'principals/user', - '{DAV:}displayname' => 'pietje', + $this->assertEquals([ + 'id' => 4, + 'uri' => 'principals/user', + '{DAV:}displayname' => 'pietje', '{http://sabredav.org/ns}email-address' => 'user@example.org', - ), $backend->getPrincipalByPath('principals/user')); + ], $backend->getPrincipalByPath('principals/user')); } @@ -153,7 +172,7 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $propPatch = new DAV\PropPatch([ '{DAV:}displayname' => 'pietje', - '{DAV:}unknown' => 'foo', + '{DAV:}unknown' => 'foo', ]); $backend->updatePrincipal('principals/user', $propPatch); @@ -161,17 +180,17 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase { $this->assertFalse($result); - $this->assertEquals(array( + $this->assertEquals([ '{DAV:}displayname' => 424, - '{DAV:}unknown' => 403 - ), $propPatch->getResult()); + '{DAV:}unknown' => 403 + ], $propPatch->getResult()); - $this->assertEquals(array( - 'id' => '1', - 'uri' => 'principals/user', - '{DAV:}displayname' => 'User', + $this->assertEquals([ + 'id' => '4', + 'uri' => 'principals/user', + '{DAV:}displayname' => 'User', '{http://sabredav.org/ns}email-address' => 'user@example.org', - ), $backend->getPrincipalByPath('principals/user')); + ], $backend->getPrincipalByPath('principals/user')); } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOMySQLTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOMySQLTest.php index 83353c86c..8779eb69f 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOMySQLTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOMySQLTest.php @@ -2,49 +2,8 @@ namespace Sabre\DAVACL\PrincipalBackend; -use Sabre\DAV; -use Sabre\HTTP; - - -require_once 'Sabre/TestUtil.php'; - class PDOMySQLTest extends AbstractPDOTest { - function getPDO() { - - if (!SABRE_HASMYSQL) $this->markTestSkipped('MySQL driver is not available, or not properly configured'); - $pdo = \Sabre\TestUtil::getMySQLDB(); - if (!$pdo) $this->markTestSkipped('Could not connect to MySQL database'); - $pdo->query("DROP TABLE IF EXISTS principals"); - $pdo->query(<<query("INSERT INTO principals (uri,email,displayname) VALUES ('principals/user','user@example.org','User')"); - $pdo->query("INSERT INTO principals (uri,email,displayname) VALUES ('principals/group','group@example.org','Group')"); - $pdo->query("DROP TABLE IF EXISTS groupmembers"); - $pdo->query(<<query("INSERT INTO groupmembers (principal_id,member_id) VALUES (2,1)"); - - return $pdo; - - } + public $driver = 'mysql'; } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOSqliteTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOSqliteTest.php index f335ed51f..48454981d 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOSqliteTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOSqliteTest.php @@ -2,44 +2,8 @@ namespace Sabre\DAVACL\PrincipalBackend; -use Sabre\DAV; -use Sabre\HTTP; +class PDOSqliteTest extends AbstractPDOTest { - -require_once 'Sabre/DAV/Auth/Backend/AbstractPDOTest.php'; - -class PDOSQLiteTest extends AbstractPDOTest { - - function tearDown() { - - if (file_exists(SABRE_TEMPDIR . '/pdobackend')) unlink(SABRE_TEMPDIR . '/pdobackend'); - if (file_exists(SABRE_TEMPDIR . '/pdobackend2')) unlink(SABRE_TEMPDIR . '/pdobackend2'); - - } - - function getPDO() { - - if (!SABRE_HASSQLITE) $this->markTestSkipped('SQLite driver is not available'); - $pdo = new \PDO('sqlite:'.SABRE_TEMPDIR.'/pdobackend'); - $pdo->setAttribute(\PDO::ATTR_ERRMODE,\PDO::ERRMODE_EXCEPTION); - $pdo->query('CREATE TABLE principals (id INTEGER PRIMARY KEY ASC, uri TEXT, email VARCHAR(80), displayname VARCHAR(80))'); - $pdo->query('INSERT INTO principals VALUES (1, "principals/user","user@example.org","User")'); - $pdo->query('INSERT INTO principals VALUES (2, "principals/group","group@example.org","Group")'); - - $pdo->query(<<query("INSERT INTO groupmembers (principal_id,member_id) VALUES (2,1)"); - - return $pdo; - - } + public $driver = 'sqlite'; } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalCollectionTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalCollectionTest.php index f51d2dcce..bcf78821b 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalCollectionTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalCollectionTest.php @@ -2,26 +2,22 @@ namespace Sabre\DAVACL; -use Sabre\DAV; -use Sabre\HTTP; - - class PrincipalCollectionTest extends \PHPUnit_Framework_TestCase { - public function testBasic() { + function testBasic() { $backend = new PrincipalBackend\Mock(); $pc = new PrincipalCollection($backend); $this->assertTrue($pc instanceof PrincipalCollection); - $this->assertEquals('principals',$pc->getName()); + $this->assertEquals('principals', $pc->getName()); } /** * @depends testBasic */ - public function testGetChildren() { + function testGetChildren() { $backend = new PrincipalBackend\Mock(); $pc = new PrincipalCollection($backend); @@ -29,7 +25,7 @@ class PrincipalCollectionTest extends \PHPUnit_Framework_TestCase { $children = $pc->getChildren(); $this->assertTrue(is_array($children)); - foreach($children as $child) { + foreach ($children as $child) { $this->assertTrue($child instanceof IPrincipal); } @@ -39,7 +35,7 @@ class PrincipalCollectionTest extends \PHPUnit_Framework_TestCase { * @depends testBasic * @expectedException Sabre\DAV\Exception\MethodNotAllowed */ - public function testGetChildrenDisable() { + function testGetChildrenDisable() { $backend = new PrincipalBackend\Mock(); $pc = new PrincipalCollection($backend); @@ -49,7 +45,7 @@ class PrincipalCollectionTest extends \PHPUnit_Framework_TestCase { } - public function testFindByUri() { + function testFindByUri() { $backend = new PrincipalBackend\Mock(); $pc = new PrincipalCollection($backend); diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalPropertySearchTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalPropertySearchTest.php index 8e4c86782..60e156d9a 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalPropertySearchTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalPropertySearchTest.php @@ -23,6 +23,7 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $fakeServer->debugExceptions = true; $plugin = new MockPlugin(); $plugin->allowAccessToNodesWithoutACL = true; + $plugin->allowUnauthenticatedAccess = false; $this->assertTrue($plugin instanceof Plugin); $fakeServer->addPlugin($plugin); @@ -48,11 +49,11 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { '; - $serverVars = array( + $serverVars = [ 'REQUEST_METHOD' => 'REPORT', 'HTTP_DEPTH' => '1', 'REQUEST_URI' => '/principals', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody($xml); @@ -63,10 +64,10 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $server->exec(); $this->assertEquals(400, $server->httpResponse->getStatus(), $server->httpResponse->getBodyAsString()); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ), $server->httpResponse->getHeaders()); + 'Content-Type' => ['application/xml; charset=utf-8'], + ], $server->httpResponse->getHeaders()); } @@ -87,11 +88,11 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { '; - $serverVars = array( + $serverVars = [ 'REQUEST_METHOD' => 'REPORT', 'HTTP_DEPTH' => '0', 'REQUEST_URI' => '/principals', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody($xml); @@ -102,11 +103,11 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $server->exec(); $this->assertEquals(207, $server->httpResponse->getStatus(), "Full body: " . $server->httpResponse->getBodyAsString()); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - 'Vary' => ['Brief,Prefer'], - ), $server->httpResponse->getHeaders()); + 'Content-Type' => ['application/xml; charset=utf-8'], + 'Vary' => ['Brief,Prefer'], + ], $server->httpResponse->getHeaders()); } @@ -127,11 +128,11 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { '; - $serverVars = array( + $serverVars = [ 'REQUEST_METHOD' => 'REPORT', 'HTTP_DEPTH' => '0', 'REQUEST_URI' => '/', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody($xml); @@ -142,36 +143,36 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $server->exec(); $this->assertEquals(207, $server->httpResponse->status, $server->httpResponse->body); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - 'Vary' => ['Brief,Prefer'], - ), $server->httpResponse->getHeaders()); + 'Content-Type' => ['application/xml; charset=utf-8'], + 'Vary' => ['Brief,Prefer'], + ], $server->httpResponse->getHeaders()); - $check = array( + $check = [ '/d:multistatus', - '/d:multistatus/d:response' => 2, - '/d:multistatus/d:response/d:href' => 2, - '/d:multistatus/d:response/d:propstat' => 4, - '/d:multistatus/d:response/d:propstat/d:prop' => 4, - '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 2, + '/d:multistatus/d:response' => 2, + '/d:multistatus/d:response/d:href' => 2, + '/d:multistatus/d:response/d:propstat' => 4, + '/d:multistatus/d:response/d:propstat/d:prop' => 4, + '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 2, '/d:multistatus/d:response/d:propstat/d:prop/d:getcontentlength' => 2, - '/d:multistatus/d:response/d:propstat/d:status' => 4, - ); + '/d:multistatus/d:response/d:propstat/d:status' => 4, + ]; $xml = simplexml_load_string($server->httpResponse->body); - $xml->registerXPathNamespace('d','DAV:'); - foreach($check as $v1=>$v2) { + $xml->registerXPathNamespace('d', 'DAV:'); + foreach ($check as $v1 => $v2) { - $xpath = is_int($v1)?$v2:$v1; + $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); + $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body); } @@ -200,11 +201,11 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { '; - $serverVars = array( + $serverVars = [ 'REQUEST_METHOD' => 'REPORT', 'HTTP_DEPTH' => '0', 'REQUEST_URI' => '/', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody($xml); @@ -215,36 +216,36 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $server->exec(); $this->assertEquals(207, $server->httpResponse->status, $server->httpResponse->body); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - 'Vary' => ['Brief,Prefer'], - ), $server->httpResponse->getHeaders()); + 'Content-Type' => ['application/xml; charset=utf-8'], + 'Vary' => ['Brief,Prefer'], + ], $server->httpResponse->getHeaders()); - $check = array( + $check = [ '/d:multistatus', - '/d:multistatus/d:response' => 0, - '/d:multistatus/d:response/d:href' => 0, - '/d:multistatus/d:response/d:propstat' => 0, - '/d:multistatus/d:response/d:propstat/d:prop' => 0, - '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 0, + '/d:multistatus/d:response' => 0, + '/d:multistatus/d:response/d:href' => 0, + '/d:multistatus/d:response/d:propstat' => 0, + '/d:multistatus/d:response/d:propstat/d:prop' => 0, + '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 0, '/d:multistatus/d:response/d:propstat/d:prop/d:getcontentlength' => 0, - '/d:multistatus/d:response/d:propstat/d:status' => 0, - ); + '/d:multistatus/d:response/d:propstat/d:status' => 0, + ]; $xml = simplexml_load_string($server->httpResponse->body); - $xml->registerXPathNamespace('d','DAV:'); - foreach($check as $v1=>$v2) { + $xml->registerXPathNamespace('d', 'DAV:'); + foreach ($check as $v1 => $v2) { - $xpath = is_int($v1)?$v2:$v1; + $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); + $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body); } @@ -272,11 +273,11 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { '; - $serverVars = array( + $serverVars = [ 'REQUEST_METHOD' => 'REPORT', 'HTTP_DEPTH' => '0', 'REQUEST_URI' => '/', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody($xml); @@ -287,36 +288,36 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $server->exec(); $this->assertEquals(207, $server->httpResponse->status, $server->httpResponse->body); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - 'Vary' => ['Brief,Prefer'], - ), $server->httpResponse->getHeaders()); + 'Content-Type' => ['application/xml; charset=utf-8'], + 'Vary' => ['Brief,Prefer'], + ], $server->httpResponse->getHeaders()); - $check = array( + $check = [ '/d:multistatus', - '/d:multistatus/d:response' => 2, - '/d:multistatus/d:response/d:href' => 2, - '/d:multistatus/d:response/d:propstat' => 4, - '/d:multistatus/d:response/d:propstat/d:prop' => 4, - '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 2, + '/d:multistatus/d:response' => 2, + '/d:multistatus/d:response/d:href' => 2, + '/d:multistatus/d:response/d:propstat' => 4, + '/d:multistatus/d:response/d:propstat/d:prop' => 4, + '/d:multistatus/d:response/d:propstat/d:prop/d:displayname' => 2, '/d:multistatus/d:response/d:propstat/d:prop/d:getcontentlength' => 2, - '/d:multistatus/d:response/d:propstat/d:status' => 4, - ); + '/d:multistatus/d:response/d:propstat/d:status' => 4, + ]; $xml = simplexml_load_string($server->httpResponse->body); - $xml->registerXPathNamespace('d','DAV:'); - foreach($check as $v1=>$v2) { + $xml->registerXPathNamespace('d', 'DAV:'); + foreach ($check as $v1 => $v2) { - $xpath = is_int($v1)?$v2:$v1; + $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); + $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body); } @@ -337,11 +338,11 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { '; - $serverVars = array( + $serverVars = [ 'REQUEST_METHOD' => 'REPORT', 'HTTP_DEPTH' => '0', 'REQUEST_URI' => '/', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody($xml); @@ -352,30 +353,30 @@ class PrincipalPropertySearchTest extends \PHPUnit_Framework_TestCase { $server->exec(); $this->assertEquals(207, $server->httpResponse->status, $server->httpResponse->body); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - 'Vary' => ['Brief,Prefer'], - ), $server->httpResponse->getHeaders()); + 'Content-Type' => ['application/xml; charset=utf-8'], + 'Vary' => ['Brief,Prefer'], + ], $server->httpResponse->getHeaders()); - $check = array( + $check = [ '/d:multistatus', '/d:multistatus/d:response' => 0, - ); + ]; $xml = simplexml_load_string($server->httpResponse->body); - $xml->registerXPathNamespace('d','DAV:'); - foreach($check as $v1=>$v2) { + $xml->registerXPathNamespace('d', 'DAV:'); + foreach ($check as $v1 => $v2) { - $xpath = is_int($v1)?$v2:$v1; + $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); + $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body); } @@ -386,10 +387,10 @@ class MockPlugin extends Plugin { function getCurrentUserPrivilegeSet($node) { - return array( + return [ '{DAV:}read', '{DAV:}write', - ); + ]; } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php index 952dc174a..fa1314d10 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalSearchPropertySetTest.php @@ -21,6 +21,7 @@ class PrincipalSearchPropertySetTest extends \PHPUnit_Framework_TestCase { $fakeServer->sapi = new HTTP\SapiMock(); $fakeServer->httpResponse = new HTTP\ResponseMock(); $plugin = new Plugin(); + $plugin->allowUnauthenticatedAccess = false; $this->assertTrue($plugin instanceof Plugin); $fakeServer->addPlugin($plugin); $this->assertEquals($plugin, $fakeServer->getPlugin('acl')); @@ -34,11 +35,11 @@ class PrincipalSearchPropertySetTest extends \PHPUnit_Framework_TestCase { $xml = ' '; - $serverVars = array( + $serverVars = [ 'REQUEST_METHOD' => 'REPORT', 'HTTP_DEPTH' => '1', 'REQUEST_URI' => '/principals', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody($xml); @@ -49,10 +50,10 @@ class PrincipalSearchPropertySetTest extends \PHPUnit_Framework_TestCase { $server->exec(); $this->assertEquals(400, $server->httpResponse->status); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ), $server->httpResponse->getHeaders()); + 'Content-Type' => ['application/xml; charset=utf-8'], + ], $server->httpResponse->getHeaders()); } @@ -61,11 +62,11 @@ class PrincipalSearchPropertySetTest extends \PHPUnit_Framework_TestCase { $xml = ' '; - $serverVars = array( + $serverVars = [ 'REQUEST_METHOD' => 'REPORT', 'HTTP_DEPTH' => '0', 'REQUEST_URI' => '/principals', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody($xml); @@ -76,10 +77,10 @@ class PrincipalSearchPropertySetTest extends \PHPUnit_Framework_TestCase { $server->exec(); $this->assertEquals(400, $server->httpResponse->status, $server->httpResponse->body); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ), $server->httpResponse->getHeaders()); + 'Content-Type' => ['application/xml; charset=utf-8'], + ], $server->httpResponse->getHeaders()); } @@ -88,11 +89,11 @@ class PrincipalSearchPropertySetTest extends \PHPUnit_Framework_TestCase { $xml = ' '; - $serverVars = array( + $serverVars = [ 'REQUEST_METHOD' => 'REPORT', 'HTTP_DEPTH' => '0', 'REQUEST_URI' => '/principals', - ); + ]; $request = HTTP\Sapi::createFromServerArray($serverVars); $request->setBody($xml); @@ -103,34 +104,34 @@ class PrincipalSearchPropertySetTest extends \PHPUnit_Framework_TestCase { $server->exec(); $this->assertEquals(200, $server->httpResponse->status, $server->httpResponse->body); - $this->assertEquals(array( + $this->assertEquals([ 'X-Sabre-Version' => [DAV\Version::VERSION], - 'Content-Type' => ['application/xml; charset=utf-8'], - ), $server->httpResponse->getHeaders()); + 'Content-Type' => ['application/xml; charset=utf-8'], + ], $server->httpResponse->getHeaders()); - $check = array( + $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) { + $xml->registerXPathNamespace('d', 'DAV:'); + $xml->registerXPathNamespace('s', 'http://sabredav.org/ns'); + foreach ($check as $v1 => $v2) { - $xpath = is_int($v1)?$v2:$v1; + $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); + $this->assertEquals($count, count($result), 'we expected ' . $count . ' appearances of ' . $xpath . ' . We found ' . count($result) . '. Full response body: ' . $server->httpResponse->body); } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalTest.php index 03fd9d64d..20622ad17 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalTest.php @@ -7,10 +7,10 @@ use Sabre\HTTP; class PrincipalTest extends \PHPUnit_Framework_TestCase { - public function testConstruct() { + function testConstruct() { $principalBackend = new PrincipalBackend\Mock(); - $principal = new Principal($principalBackend, array('uri' => 'principals/admin')); + $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); $this->assertTrue($principal instanceof Principal); } @@ -18,65 +18,65 @@ class PrincipalTest extends \PHPUnit_Framework_TestCase { /** * @expectedException Sabre\DAV\Exception */ - public function testConstructNoUri() { + function testConstructNoUri() { $principalBackend = new PrincipalBackend\Mock(); - $principal = new Principal($principalBackend, array()); + $principal = new Principal($principalBackend, []); } - public function testGetName() { + function testGetName() { $principalBackend = new PrincipalBackend\Mock(); - $principal = new Principal($principalBackend, array('uri' => 'principals/admin')); - $this->assertEquals('admin',$principal->getName()); + $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); + $this->assertEquals('admin', $principal->getName()); } - public function testGetDisplayName() { + function testGetDisplayName() { $principalBackend = new PrincipalBackend\Mock(); - $principal = new Principal($principalBackend, array('uri' => 'principals/admin')); - $this->assertEquals('admin',$principal->getDisplayname()); + $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); + $this->assertEquals('admin', $principal->getDisplayname()); - $principal = new Principal($principalBackend, array( - 'uri' => 'principals/admin', + $principal = new Principal($principalBackend, [ + 'uri' => 'principals/admin', '{DAV:}displayname' => 'Mr. Admin' - )); - $this->assertEquals('Mr. Admin',$principal->getDisplayname()); + ]); + $this->assertEquals('Mr. Admin', $principal->getDisplayname()); } - public function testGetProperties() { + function testGetProperties() { $principalBackend = new PrincipalBackend\Mock(); - $principal = new Principal($principalBackend, array( - 'uri' => 'principals/admin', - '{DAV:}displayname' => 'Mr. Admin', + $principal = new Principal($principalBackend, [ + 'uri' => 'principals/admin', + '{DAV:}displayname' => 'Mr. Admin', '{http://www.example.org/custom}custom' => 'Custom', '{http://sabredav.org/ns}email-address' => 'admin@example.org', - )); + ]); - $keys = array( + $keys = [ '{DAV:}displayname', '{http://www.example.org/custom}custom', '{http://sabredav.org/ns}email-address', - ); + ]; $props = $principal->getProperties($keys); - foreach($keys as $key) $this->assertArrayHasKey($key,$props); + foreach ($keys as $key) $this->assertArrayHasKey($key, $props); - $this->assertEquals('Mr. Admin',$props['{DAV:}displayname']); + $this->assertEquals('Mr. Admin', $props['{DAV:}displayname']); $this->assertEquals('admin@example.org', $props['{http://sabredav.org/ns}email-address']); } - public function testUpdateProperties() { + function testUpdateProperties() { $principalBackend = new PrincipalBackend\Mock(); - $principal = new Principal($principalBackend, array('uri' => 'principals/admin')); + $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); - $propPatch = new DAV\PropPatch(array('{DAV:}yourmom' => 'test')); + $propPatch = new DAV\PropPatch(['{DAV:}yourmom' => 'test']); $result = $principal->propPatch($propPatch); $result = $propPatch->commit(); @@ -84,123 +84,123 @@ class PrincipalTest extends \PHPUnit_Framework_TestCase { } - public function testGetPrincipalUrl() { + function testGetPrincipalUrl() { $principalBackend = new PrincipalBackend\Mock(); - $principal = new Principal($principalBackend, array('uri' => 'principals/admin')); - $this->assertEquals('principals/admin',$principal->getPrincipalUrl()); + $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); + $this->assertEquals('principals/admin', $principal->getPrincipalUrl()); } - public function testGetAlternateUriSet() { + function testGetAlternateUriSet() { $principalBackend = new PrincipalBackend\Mock(); - $principal = new Principal($principalBackend, array( - 'uri' => 'principals/admin', - '{DAV:}displayname' => 'Mr. Admin', + $principal = new Principal($principalBackend, [ + 'uri' => 'principals/admin', + '{DAV:}displayname' => 'Mr. Admin', '{http://www.example.org/custom}custom' => 'Custom', '{http://sabredav.org/ns}email-address' => 'admin@example.org', - '{DAV:}alternate-URI-set' => array( + '{DAV:}alternate-URI-set' => [ 'mailto:admin+1@example.org', 'mailto:admin+2@example.org', 'mailto:admin@example.org', - ), - )); + ], + ]); - $expected = array( + $expected = [ 'mailto:admin+1@example.org', 'mailto:admin+2@example.org', 'mailto:admin@example.org', - ); + ]; - $this->assertEquals($expected,$principal->getAlternateUriSet()); + $this->assertEquals($expected, $principal->getAlternateUriSet()); } - public function testGetAlternateUriSetEmpty() { + function testGetAlternateUriSetEmpty() { $principalBackend = new PrincipalBackend\Mock(); - $principal = new Principal($principalBackend, array( + $principal = new Principal($principalBackend, [ 'uri' => 'principals/admin', - )); + ]); - $expected = array(); + $expected = []; - $this->assertEquals($expected,$principal->getAlternateUriSet()); + $this->assertEquals($expected, $principal->getAlternateUriSet()); } - public function testGetGroupMemberSet() { + function testGetGroupMemberSet() { $principalBackend = new PrincipalBackend\Mock(); - $principal = new Principal($principalBackend, array('uri' => 'principals/admin')); - $this->assertEquals(array(),$principal->getGroupMemberSet()); + $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); + $this->assertEquals([], $principal->getGroupMemberSet()); } - public function testGetGroupMembership() { + function testGetGroupMembership() { $principalBackend = new PrincipalBackend\Mock(); - $principal = new Principal($principalBackend, array('uri' => 'principals/admin')); - $this->assertEquals(array(),$principal->getGroupMembership()); + $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); + $this->assertEquals([], $principal->getGroupMembership()); } - public function testSetGroupMemberSet() { + function testSetGroupMemberSet() { $principalBackend = new PrincipalBackend\Mock(); - $principal = new Principal($principalBackend, array('uri' => 'principals/admin')); - $principal->setGroupMemberSet(array('principals/foo')); + $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); + $principal->setGroupMemberSet(['principals/foo']); - $this->assertEquals(array( - 'principals/admin' => array('principals/foo'), - ), $principalBackend->groupMembers); + $this->assertEquals([ + 'principals/admin' => ['principals/foo'], + ], $principalBackend->groupMembers); } - public function testGetOwner() { + function testGetOwner() { $principalBackend = new PrincipalBackend\Mock(); - $principal = new Principal($principalBackend, array('uri' => 'principals/admin')); - $this->assertEquals('principals/admin',$principal->getOwner()); + $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); + $this->assertEquals('principals/admin', $principal->getOwner()); } - public function testGetGroup() { + function testGetGroup() { $principalBackend = new PrincipalBackend\Mock(); - $principal = new Principal($principalBackend, array('uri' => 'principals/admin')); + $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); $this->assertNull($principal->getGroup()); } - public function testGetACl() { + function testGetACl() { $principalBackend = new PrincipalBackend\Mock(); - $principal = new Principal($principalBackend, array('uri' => 'principals/admin')); - $this->assertEquals(array( - array( - 'privilege' => '{DAV:}read', - 'principal' => '{DAV:}authenticated', + $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); + $this->assertEquals([ + [ + 'privilege' => '{DAV:}all', + 'principal' => '{DAV:}owner', 'protected' => true, - ) - ),$principal->getACL()); + ] + ], $principal->getACL()); } /** - * @expectedException Sabre\DAV\Exception\MethodNotAllowed + * @expectedException \Sabre\DAV\Exception\Forbidden */ - public function testSetACl() { + function testSetACl() { $principalBackend = new PrincipalBackend\Mock(); - $principal = new Principal($principalBackend, array('uri' => 'principals/admin')); - $principal->setACL(array()); + $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); + $principal->setACL([]); } - public function testGetSupportedPrivilegeSet() { + function testGetSupportedPrivilegeSet() { $principalBackend = new PrincipalBackend\Mock(); - $principal = new Principal($principalBackend, array('uri' => 'principals/admin')); + $principal = new Principal($principalBackend, ['uri' => 'principals/admin']); $this->assertNull($principal->getSupportedPrivilegeSet()); } diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/SimplePluginTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/SimplePluginTest.php index fb73cc16a..2de0ba6a8 100644 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/SimplePluginTest.php +++ b/vendor/sabre/dav/tests/Sabre/DAVACL/SimplePluginTest.php @@ -5,7 +5,6 @@ namespace Sabre\DAVACL; use Sabre\DAV; use Sabre\HTTP; - require_once 'Sabre/DAVACL/MockPrincipal.php'; require_once 'Sabre/DAVACL/MockACLNode.php'; @@ -14,21 +13,22 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { function testValues() { $aclPlugin = new Plugin(); - $this->assertEquals('acl',$aclPlugin->getPluginName()); + $this->assertEquals('acl', $aclPlugin->getPluginName()); $this->assertEquals( - array('access-control', 'calendarserver-principal-property-search'), + ['access-control', 'calendarserver-principal-property-search'], $aclPlugin->getFeatures() ); $this->assertEquals( - array( + [ '{DAV:}expand-property', + '{DAV:}principal-match', '{DAV:}principal-property-search', '{DAV:}principal-search-property-set' - ), + ], $aclPlugin->getSupportedReportSet('')); - $this->assertEquals(array('ACL'), $aclPlugin->getMethods('')); + $this->assertEquals(['ACL'], $aclPlugin->getMethods('')); $this->assertEquals( @@ -39,90 +39,84 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { function testGetFlatPrivilegeSet() { - $expected = array( - '{DAV:}all' => array( - 'privilege' => '{DAV:}all', - 'abstract' => true, - 'aggregates' => array( + $expected = [ + '{DAV:}all' => [ + 'privilege' => '{DAV:}all', + 'abstract' => false, + 'aggregates' => [ '{DAV:}read', '{DAV:}write', - ), - 'concrete' => null, - ), - '{DAV:}read' => array( - 'privilege' => '{DAV:}read', - 'abstract' => false, - 'aggregates' => array( + ], + 'concrete' => '{DAV:}all', + ], + '{DAV:}read' => [ + 'privilege' => '{DAV:}read', + 'abstract' => false, + 'aggregates' => [ '{DAV:}read-acl', '{DAV:}read-current-user-privilege-set', - ), + ], 'concrete' => '{DAV:}read', - ), - '{DAV:}read-acl' => array( - 'privilege' => '{DAV:}read-acl', - 'abstract' => false, - 'aggregates' => array(), - 'concrete' => '{DAV:}read-acl', - ), - '{DAV:}read-current-user-privilege-set' => array( - 'privilege' => '{DAV:}read-current-user-privilege-set', - 'abstract' => false, - 'aggregates' => array(), - 'concrete' => '{DAV:}read-current-user-privilege-set', - ), - '{DAV:}write' => array( - 'privilege' => '{DAV:}write', - 'abstract' => false, - 'aggregates' => array( - '{DAV:}write-acl', + ], + '{DAV:}read-acl' => [ + 'privilege' => '{DAV:}read-acl', + 'abstract' => false, + 'aggregates' => [], + 'concrete' => '{DAV:}read-acl', + ], + '{DAV:}read-current-user-privilege-set' => [ + 'privilege' => '{DAV:}read-current-user-privilege-set', + 'abstract' => false, + 'aggregates' => [], + 'concrete' => '{DAV:}read-current-user-privilege-set', + ], + '{DAV:}write' => [ + 'privilege' => '{DAV:}write', + 'abstract' => false, + 'aggregates' => [ '{DAV:}write-properties', '{DAV:}write-content', + '{DAV:}unlock', '{DAV:}bind', '{DAV:}unbind', - '{DAV:}unlock', - ), + ], 'concrete' => '{DAV:}write', - ), - '{DAV:}write-acl' => array( - 'privilege' => '{DAV:}write-acl', - 'abstract' => false, - 'aggregates' => array(), - 'concrete' => '{DAV:}write-acl', - ), - '{DAV:}write-properties' => array( - 'privilege' => '{DAV:}write-properties', - 'abstract' => false, - 'aggregates' => array(), - 'concrete' => '{DAV:}write-properties', - ), - '{DAV:}write-content' => array( - 'privilege' => '{DAV:}write-content', - 'abstract' => false, - 'aggregates' => array(), - 'concrete' => '{DAV:}write-content', - ), - '{DAV:}unlock' => array( - 'privilege' => '{DAV:}unlock', - 'abstract' => false, - 'aggregates' => array(), - 'concrete' => '{DAV:}unlock', - ), - '{DAV:}bind' => array( - 'privilege' => '{DAV:}bind', - 'abstract' => false, - 'aggregates' => array(), - 'concrete' => '{DAV:}bind', - ), - '{DAV:}unbind' => array( - 'privilege' => '{DAV:}unbind', - 'abstract' => false, - 'aggregates' => array(), - 'concrete' => '{DAV:}unbind', - ), - - ); + ], + '{DAV:}write-properties' => [ + 'privilege' => '{DAV:}write-properties', + 'abstract' => false, + 'aggregates' => [], + 'concrete' => '{DAV:}write-properties', + ], + '{DAV:}write-content' => [ + 'privilege' => '{DAV:}write-content', + 'abstract' => false, + 'aggregates' => [], + 'concrete' => '{DAV:}write-content', + ], + '{DAV:}unlock' => [ + 'privilege' => '{DAV:}unlock', + 'abstract' => false, + 'aggregates' => [], + 'concrete' => '{DAV:}unlock', + ], + '{DAV:}bind' => [ + 'privilege' => '{DAV:}bind', + 'abstract' => false, + 'aggregates' => [], + 'concrete' => '{DAV:}bind', + ], + '{DAV:}unbind' => [ + 'privilege' => '{DAV:}unbind', + 'abstract' => false, + 'aggregates' => [], + 'concrete' => '{DAV:}unbind', + ], + + ]; $plugin = new Plugin(); + $plugin->allowUnauthenticatedAccess = false; $server = new DAV\Server(); $server->addPlugin($plugin); $this->assertEquals($expected, $plugin->getFlatPrivilegeSet('')); @@ -132,24 +126,26 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { function testCurrentUserPrincipalsNotLoggedIn() { $acl = new Plugin(); + $acl->allowUnauthenticatedAccess = false; $server = new DAV\Server(); $server->addPlugin($acl); - $this->assertEquals(array(),$acl->getCurrentUserPrincipals()); + $this->assertEquals([], $acl->getCurrentUserPrincipals()); } function testCurrentUserPrincipalsSimple() { - $tree = array( + $tree = [ - new DAV\SimpleCollection('principals', array( - new MockPrincipal('admin','principals/admin'), - )) + new DAV\SimpleCollection('principals', [ + new MockPrincipal('admin', 'principals/admin'), + ]) - ); + ]; $acl = new Plugin(); + $acl->allowUnauthenticatedAccess = false; $server = new DAV\Server($tree); $server->addPlugin($acl); @@ -159,24 +155,25 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { //forcing login $auth->beforeMethod(new HTTP\Request(), new HTTP\Response()); - $this->assertEquals(array('principals/admin'),$acl->getCurrentUserPrincipals()); + $this->assertEquals(['principals/admin'], $acl->getCurrentUserPrincipals()); } function testCurrentUserPrincipalsGroups() { - $tree = array( + $tree = [ - new DAV\SimpleCollection('principals', array( - new MockPrincipal('admin','principals/admin',array('principals/administrators', 'principals/everyone')), - new MockPrincipal('administrators','principals/administrators',array('principals/groups'), array('principals/admin')), - new MockPrincipal('everyone','principals/everyone',array(), array('principals/admin')), - new MockPrincipal('groups','principals/groups',array(), array('principals/administrators')), - )) + new DAV\SimpleCollection('principals', [ + new MockPrincipal('admin', 'principals/admin', ['principals/administrators', 'principals/everyone']), + new MockPrincipal('administrators', 'principals/administrators', ['principals/groups'], ['principals/admin']), + new MockPrincipal('everyone', 'principals/everyone', [], ['principals/admin']), + new MockPrincipal('groups', 'principals/groups', [], ['principals/administrators']), + ]) - ); + ]; $acl = new Plugin(); + $acl->allowUnauthenticatedAccess = false; $server = new DAV\Server($tree); $server->addPlugin($acl); @@ -186,75 +183,77 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { //forcing login $auth->beforeMethod(new HTTP\Request(), new HTTP\Response()); - $expected = array( + $expected = [ 'principals/admin', 'principals/administrators', 'principals/everyone', 'principals/groups', - ); + ]; - $this->assertEquals($expected,$acl->getCurrentUserPrincipals()); + $this->assertEquals($expected, $acl->getCurrentUserPrincipals()); // The second one should trigger the cache and be identical - $this->assertEquals($expected,$acl->getCurrentUserPrincipals()); + $this->assertEquals($expected, $acl->getCurrentUserPrincipals()); } function testGetACL() { - $acl = array( - array( + $acl = [ + [ 'principal' => 'principals/admin', 'privilege' => '{DAV:}read', - ), - array( + ], + [ 'principal' => 'principals/admin', 'privilege' => '{DAV:}write', - ), - ); + ], + ]; - $tree = array( - new MockACLNode('foo',$acl), - ); + $tree = [ + new MockACLNode('foo', $acl), + ]; $server = new DAV\Server($tree); $aclPlugin = new Plugin(); + $aclPlugin->allowUnauthenticatedAccess = false; $server->addPlugin($aclPlugin); - $this->assertEquals($acl,$aclPlugin->getACL('foo')); + $this->assertEquals($acl, $aclPlugin->getACL('foo')); } function testGetCurrentUserPrivilegeSet() { - $acl = array( - array( + $acl = [ + [ 'principal' => 'principals/admin', 'privilege' => '{DAV:}read', - ), - array( + ], + [ 'principal' => 'principals/user1', 'privilege' => '{DAV:}read', - ), - array( + ], + [ 'principal' => 'principals/admin', 'privilege' => '{DAV:}write', - ), - ); + ], + ]; - $tree = array( - new MockACLNode('foo',$acl), + $tree = [ + new MockACLNode('foo', $acl), - new DAV\SimpleCollection('principals', array( - new MockPrincipal('admin','principals/admin'), - )), + new DAV\SimpleCollection('principals', [ + new MockPrincipal('admin', 'principals/admin'), + ]), - ); + ]; $server = new DAV\Server($tree); $aclPlugin = new Plugin(); + $aclPlugin->allowUnauthenticatedAccess = false; $server->addPlugin($aclPlugin); $auth = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock()); @@ -263,52 +262,51 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { //forcing login $auth->beforeMethod(new HTTP\Request(), new HTTP\Response()); - $expected = array( + $expected = [ '{DAV:}write', - '{DAV:}write-acl', '{DAV:}write-properties', '{DAV:}write-content', - '{DAV:}bind', - '{DAV:}unbind', '{DAV:}unlock', + '{DAV:}write-acl', '{DAV:}read', '{DAV:}read-acl', '{DAV:}read-current-user-privilege-set', - ); + ]; - $this->assertEquals($expected,$aclPlugin->getCurrentUserPrivilegeSet('foo')); + $this->assertEquals($expected, $aclPlugin->getCurrentUserPrivilegeSet('foo')); } function testCheckPrivileges() { - $acl = array( - array( + $acl = [ + [ 'principal' => 'principals/admin', 'privilege' => '{DAV:}read', - ), - array( + ], + [ 'principal' => 'principals/user1', 'privilege' => '{DAV:}read', - ), - array( + ], + [ 'principal' => 'principals/admin', 'privilege' => '{DAV:}write', - ), - ); + ], + ]; - $tree = array( - new MockACLNode('foo',$acl), + $tree = [ + new MockACLNode('foo', $acl), - new DAV\SimpleCollection('principals', array( - new MockPrincipal('admin','principals/admin'), - )), + new DAV\SimpleCollection('principals', [ + new MockPrincipal('admin', 'principals/admin'), + ]), - ); + ]; $server = new DAV\Server($tree); $aclPlugin = new Plugin(); + $aclPlugin->allowUnauthenticatedAccess = false; $server->addPlugin($aclPlugin); $auth = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock()); @@ -317,11 +315,7 @@ class SimplePluginTest extends \PHPUnit_Framework_TestCase { //forcing login //$auth->beforeMethod('GET','/'); - $this->assertFalse($aclPlugin->checkPrivileges('foo', array('{DAV:}read'), Plugin::R_PARENT, false)); + $this->assertFalse($aclPlugin->checkPrivileges('foo', ['{DAV:}read'], Plugin::R_PARENT, false)); } } - - - - -- cgit v1.2.3