aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php')
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php118
1 files changed, 51 insertions, 67 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php
index fb42efba7..16d3e781e 100644
--- a/vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PluginPropertiesTest.php
@@ -1,14 +1,16 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\DAVACL;
use Sabre\DAV;
use Sabre\HTTP;
-class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
-
- function testPrincipalCollectionSet() {
-
+class PluginPropertiesTest extends \PHPUnit\Framework\TestCase
+{
+ public function testPrincipalCollectionSet()
+ {
$plugin = new Plugin();
$plugin->allowUnauthenticatedAccess = false;
$plugin->setDefaultACL([
@@ -42,14 +44,11 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
'principals2/',
];
-
$this->assertEquals($expected, $result[200]['{DAV:}principal-collection-set']->getHrefs());
-
-
}
- function testCurrentUserPrincipal() {
-
+ public function testCurrentUserPrincipal()
+ {
$fakeServer = new DAV\Server();
$plugin = new DAV\Auth\Plugin(new DAV\Auth\Backend\Mock());
$fakeServer->addPlugin($plugin);
@@ -62,7 +61,6 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
]);
$fakeServer->addPlugin($plugin);
-
$requestedProperties = [
'{DAV:}current-user-principal',
];
@@ -76,7 +74,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals(Xml\Property\Principal::UNAUTHENTICATED, $result[200]['{DAV:}current-user-principal']->getType());
// This will force the login
- $fakeServer->emit('beforeMethod', [$fakeServer->httpRequest, $fakeServer->httpResponse]);
+ $fakeServer->emit('beforeMethod:PROPFIND', [$fakeServer->httpRequest, $fakeServer->httpResponse]);
$result = $fakeServer->getPropertiesForPath('', $requestedProperties);
$result = $result[0];
@@ -86,11 +84,10 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
$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());
-
}
- function testSupportedPrivilegeSet() {
-
+ public function testSupportedPrivilegeSet()
+ {
$plugin = new Plugin();
$plugin->allowUnauthenticatedAccess = false;
$plugin->setDefaultACL([
@@ -119,28 +116,27 @@ 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' => 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' => 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: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,
];
-
// reloading because php dom sucks
$dom2 = new \DOMDocument('1.0', 'utf-8');
$dom2->loadXML($result);
@@ -148,15 +144,12 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
$dxpath = new \DOMXPath($dom2);
$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);
}
-
}
- function testACL() {
-
+ public function testACL()
+ {
$plugin = new Plugin();
$plugin->allowUnauthenticatedAccess = false;
$plugin->setDefaultACL([
@@ -171,12 +164,11 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
[
'principal' => 'principals/admin',
'privilege' => '{DAV:}read',
- ]
+ ],
]),
new DAV\SimpleCollection('principals', [
$principal = new MockPrincipal('admin', 'principals/admin'),
]),
-
];
$server = new DAV\Server($nodes);
@@ -185,7 +177,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
$server->addPlugin($authPlugin);
// Force login
- $authPlugin->beforeMethod(new HTTP\Request(), new HTTP\Response());
+ $authPlugin->beforeMethod(new HTTP\Request('GET', '/'), new HTTP\Response());
$requestedProperties = [
'{DAV:}acl',
@@ -194,14 +186,13 @@ 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->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']);
-
}
- function testACLRestrictions() {
-
+ public function testACLRestrictions()
+ {
$plugin = new Plugin();
$plugin->allowUnauthenticatedAccess = false;
@@ -210,12 +201,11 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
[
'principal' => 'principals/admin',
'privilege' => '{DAV:}read',
- ]
+ ],
]),
new DAV\SimpleCollection('principals', [
$principal = new MockPrincipal('admin', 'principals/admin'),
]),
-
];
$server = new DAV\Server($nodes);
@@ -224,7 +214,7 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
$server->addPlugin($authPlugin);
// Force login
- $authPlugin->beforeMethod(new HTTP\Request(), new HTTP\Response());
+ $authPlugin->beforeMethod(new HTTP\Request('GET', '/'), new HTTP\Response());
$requestedProperties = [
'{DAV:}acl-restrictions',
@@ -233,18 +223,17 @@ 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->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']);
-
}
- function testAlternateUriSet() {
-
+ public function testAlternateUriSet()
+ {
$tree = [
new DAV\SimpleCollection('principals', [
$principal = new MockPrincipal('user', 'principals/user'),
- ])
+ ]),
];
$fakeServer = new DAV\Server($tree);
@@ -271,11 +260,10 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
$this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $result[200]['{DAV:}alternate-URI-set']);
$this->assertEquals([], $result[200]['{DAV:}alternate-URI-set']->getHrefs());
-
}
- function testPrincipalURL() {
-
+ public function testPrincipalURL()
+ {
$tree = [
new DAV\SimpleCollection('principals', [
$principal = new MockPrincipal('user', 'principals/user'),
@@ -307,11 +295,10 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
$this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $result[200]['{DAV:}principal-URL']);
$this->assertEquals('principals/user/', $result[200]['{DAV:}principal-URL']->getHref());
-
}
- function testGroupMemberSet() {
-
+ public function testGroupMemberSet()
+ {
$tree = [
new DAV\SimpleCollection('principals', [
$principal = new MockPrincipal('user', 'principals/user'),
@@ -343,11 +330,10 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
$this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $result[200]['{DAV:}group-member-set']);
$this->assertEquals([], $result[200]['{DAV:}group-member-set']->getHrefs());
-
}
- function testGroupMemberShip() {
-
+ public function testGroupMemberShip()
+ {
$tree = [
new DAV\SimpleCollection('principals', [
$principal = new MockPrincipal('user', 'principals/user'),
@@ -377,11 +363,10 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
$this->assertInstanceOf('Sabre\\DAV\\Xml\\Property\\Href', $result[200]['{DAV:}group-membership']);
$this->assertEquals([], $result[200]['{DAV:}group-membership']->getHrefs());
-
}
- function testGetDisplayName() {
-
+ public function testGetDisplayName()
+ {
$tree = [
new DAV\SimpleCollection('principals', [
$principal = new MockPrincipal('user', 'principals/user'),
@@ -410,6 +395,5 @@ class PluginPropertiesTest extends \PHPUnit_Framework_TestCase {
$this->assertTrue(isset($result[200]['{DAV:}displayname']));
$this->assertEquals('user', $result[200]['{DAV:}displayname']);
-
}
}