aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend')
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/AbstractPDOTest.php107
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/Mock.php107
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOMySQLTest.php7
-rw-r--r--vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOSqliteTest.php7
4 files changed, 103 insertions, 125 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/AbstractPDOTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/AbstractPDOTest.php
index 9fef3018d..89f69b10a 100644
--- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/AbstractPDOTest.php
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/AbstractPDOTest.php
@@ -1,16 +1,17 @@
<?php
+declare(strict_types=1);
+
namespace Sabre\DAVACL\PrincipalBackend;
use Sabre\DAV;
-use Sabre\HTTP;
-
-abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
+abstract class AbstractPDOTest extends \PHPUnit\Framework\TestCase
+{
use DAV\DbTestHelperTrait;
- function setUp() {
-
+ public function setUp()
+ {
$this->dropTables(['principals', 'groupmembers']);
$this->createSchema('principals');
@@ -19,92 +20,85 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
$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)");
-
+ $pdo->query('INSERT INTO groupmembers (principal_id,member_id) VALUES (5,4)');
}
-
- function testConstruct() {
-
+ public function testConstruct()
+ {
$pdo = $this->getPDO();
$backend = new PDO($pdo);
$this->assertTrue($backend instanceof PDO);
-
}
/**
* @depends testConstruct
*/
- function testGetPrincipalsByPrefix() {
-
+ public function testGetPrincipalsByPrefix()
+ {
$pdo = $this->getPDO();
$backend = new PDO($pdo);
$expected = [
[
- 'uri' => 'principals/admin',
+ 'uri' => 'principals/admin',
'{http://sabredav.org/ns}email-address' => 'admin@example.org',
- '{DAV:}displayname' => 'Administrator',
+ '{DAV:}displayname' => 'Administrator',
],
[
- 'uri' => 'principals/user',
+ 'uri' => 'principals/user',
'{http://sabredav.org/ns}email-address' => 'user@example.org',
- '{DAV:}displayname' => 'User',
+ '{DAV:}displayname' => 'User',
],
[
- 'uri' => 'principals/group',
+ '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([], $backend->getPrincipalsByPrefix('foo'));
-
}
/**
* @depends testConstruct
*/
- function testGetPrincipalByPath() {
-
+ public function testGetPrincipalByPath()
+ {
$pdo = $this->getPDO();
$backend = new PDO($pdo);
$expected = [
- 'id' => 4,
- 'uri' => 'principals/user',
+ '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'));
-
}
- function testGetGroupMemberSet() {
-
+ public function testGetGroupMemberSet()
+ {
$pdo = $this->getPDO();
$backend = new PDO($pdo);
$expected = ['principals/user'];
$this->assertEquals($expected, $backend->getGroupMemberSet('principals/group'));
-
}
- function testGetGroupMembership() {
-
+ public function testGetGroupMembership()
+ {
$pdo = $this->getPDO();
$backend = new PDO($pdo);
$expected = ['principals/group'];
$this->assertEquals($expected, $backend->getGroupMembership('principals/user'));
-
}
- function testSetGroupMemberSet() {
-
+ public function testSetGroupMemberSet()
+ {
$pdo = $this->getPDO();
// Start situation
@@ -118,12 +112,10 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
// Adding principals again
$backend->setGroupMemberSet('principals/group', ['principals/user']);
$this->assertEquals(['principals/user'], $backend->getGroupMemberSet('principals/group'));
-
-
}
- function testSearchPrincipals() {
-
+ public function testSearchPrincipals()
+ {
$pdo = $this->getPDO();
$backend = new PDO($pdo);
@@ -139,11 +131,10 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
$result = $backend->searchPrincipals('mom', ['{DAV:}displayname' => 'UsEr', '{http://sabredav.org/ns}email-address' => 'USER@EXAMPLE']);
$this->assertEquals([], $result);
-
}
- function testUpdatePrincipal() {
-
+ public function testUpdatePrincipal()
+ {
$pdo = $this->getPDO();
$backend = new PDO($pdo);
@@ -157,22 +148,21 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
$this->assertTrue($result);
$this->assertEquals([
- 'id' => 4,
- 'uri' => 'principals/user',
- '{DAV:}displayname' => 'pietje',
+ 'id' => 4,
+ 'uri' => 'principals/user',
+ '{DAV:}displayname' => 'pietje',
'{http://sabredav.org/ns}email-address' => 'user@example.org',
], $backend->getPrincipalByPath('principals/user'));
-
}
- function testUpdatePrincipalUnknownField() {
-
+ public function testUpdatePrincipalUnknownField()
+ {
$pdo = $this->getPDO();
$backend = new PDO($pdo);
$propPatch = new DAV\PropPatch([
'{DAV:}displayname' => 'pietje',
- '{DAV:}unknown' => 'foo',
+ '{DAV:}unknown' => 'foo',
]);
$backend->updatePrincipal('principals/user', $propPatch);
@@ -182,36 +172,31 @@ abstract class AbstractPDOTest extends \PHPUnit_Framework_TestCase {
$this->assertEquals([
'{DAV:}displayname' => 424,
- '{DAV:}unknown' => 403
+ '{DAV:}unknown' => 403,
], $propPatch->getResult());
$this->assertEquals([
- 'id' => '4',
- 'uri' => 'principals/user',
- '{DAV:}displayname' => 'User',
+ 'id' => '4',
+ 'uri' => 'principals/user',
+ '{DAV:}displayname' => 'User',
'{http://sabredav.org/ns}email-address' => 'user@example.org',
], $backend->getPrincipalByPath('principals/user'));
-
}
- function testFindByUriUnknownScheme() {
-
+ public function testFindByUriUnknownScheme()
+ {
$pdo = $this->getPDO();
$backend = new PDO($pdo);
$this->assertNull($backend->findByUri('http://foo', 'principals'));
-
}
-
- function testFindByUri() {
-
+ public function testFindByUri()
+ {
$pdo = $this->getPDO();
$backend = new PDO($pdo);
$this->assertEquals(
'principals/user',
$backend->findByUri('mailto:user@example.org', 'principals')
);
-
}
-
}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/Mock.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/Mock.php
index 1464f4c26..551a77900 100644
--- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/Mock.php
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/Mock.php
@@ -1,121 +1,117 @@
<?php
-namespace Sabre\DAVACL\PrincipalBackend;
+declare(strict_types=1);
-class Mock extends AbstractBackend {
+namespace Sabre\DAVACL\PrincipalBackend;
+class Mock extends AbstractBackend
+{
public $groupMembers = [];
public $principals;
- function __construct(array $principals = null) {
-
+ public function __construct(array $principals = null)
+ {
$this->principals = $principals;
if (is_null($principals)) {
-
$this->principals = [
[
- 'uri' => 'principals/user1',
- '{DAV:}displayname' => 'User 1',
+ 'uri' => 'principals/user1',
+ '{DAV:}displayname' => 'User 1',
'{http://sabredav.org/ns}email-address' => 'user1.sabredav@sabredav.org',
- '{http://sabredav.org/ns}vcard-url' => 'addressbooks/user1/book1/vcard1.vcf',
+ '{http://sabredav.org/ns}vcard-url' => 'addressbooks/user1/book1/vcard1.vcf',
],
[
- 'uri' => 'principals/admin',
+ 'uri' => 'principals/admin',
'{DAV:}displayname' => 'Admin',
],
[
- 'uri' => 'principals/user2',
- '{DAV:}displayname' => 'User 2',
+ 'uri' => 'principals/user2',
+ '{DAV:}displayname' => 'User 2',
'{http://sabredav.org/ns}email-address' => 'user2.sabredav@sabredav.org',
],
];
-
}
-
}
- function getPrincipalsByPrefix($prefix) {
-
+ public function getPrincipalsByPrefix($prefix)
+ {
$prefix = trim($prefix, '/');
- if ($prefix) $prefix .= '/';
+ if ($prefix) {
+ $prefix .= '/';
+ }
$return = [];
foreach ($this->principals as $principal) {
-
- if ($prefix && strpos($principal['uri'], $prefix) !== 0) continue;
+ if ($prefix && 0 !== strpos($principal['uri'], $prefix)) {
+ continue;
+ }
$return[] = $principal;
-
}
return $return;
-
}
- function addPrincipal(array $principal) {
-
+ public function addPrincipal(array $principal)
+ {
$this->principals[] = $principal;
-
}
- function getPrincipalByPath($path) {
-
+ public function getPrincipalByPath($path)
+ {
foreach ($this->getPrincipalsByPrefix('principals') as $principal) {
- if ($principal['uri'] === $path) return $principal;
+ if ($principal['uri'] === $path) {
+ return $principal;
+ }
}
-
}
- function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof') {
-
+ public function searchPrincipals($prefixPath, array $searchProperties, $test = 'allof')
+ {
$matches = [];
foreach ($this->getPrincipalsByPrefix($prefixPath) as $principal) {
-
foreach ($searchProperties as $key => $value) {
-
if (!isset($principal[$key])) {
continue 2;
}
- if (mb_stripos($principal[$key], $value, 0, 'UTF-8') === false) {
+ if (false === mb_stripos($principal[$key], $value, 0, 'UTF-8')) {
continue 2;
}
// We have a match for this searchProperty!
- if ($test === 'allof') {
+ if ('allof' === $test) {
continue;
} else {
break;
}
-
}
$matches[] = $principal['uri'];
-
}
- return $matches;
+ return $matches;
}
- function getGroupMemberSet($path) {
-
+ public function getGroupMemberSet($path)
+ {
return isset($this->groupMembers[$path]) ? $this->groupMembers[$path] : [];
-
}
- function getGroupMembership($path) {
-
+ public function getGroupMembership($path)
+ {
$membership = [];
foreach ($this->groupMembers as $group => $members) {
- if (in_array($path, $members)) $membership[] = $group;
+ if (in_array($path, $members)) {
+ $membership[] = $group;
+ }
}
- return $membership;
+ return $membership;
}
- function setGroupMemberSet($path, array $members) {
-
+ public function setGroupMemberSet($path, array $members)
+ {
$this->groupMembers[$path] = $members;
-
}
/**
@@ -130,11 +126,11 @@ class Mock extends AbstractBackend {
*
* Read the PropPatch documentation for more info and examples.
*
- * @param string $path
+ * @param string $path
* @param \Sabre\DAV\PropPatch $propPatch
*/
- function updatePrincipal($path, \Sabre\DAV\PropPatch $propPatch) {
-
+ public function updatePrincipal($path, \Sabre\DAV\PropPatch $propPatch)
+ {
$value = null;
foreach ($this->principals as $principalIndex => $value) {
if ($value['uri'] === $path) {
@@ -142,27 +138,22 @@ class Mock extends AbstractBackend {
break;
}
}
- if (!$principal) return;
-
- $propPatch->handleRemaining(function($mutations) use ($principal, $principalIndex) {
+ if (!$principal) {
+ return;
+ }
+ $propPatch->handleRemaining(function ($mutations) use ($principal, $principalIndex) {
foreach ($mutations as $prop => $value) {
-
if (is_null($value) && isset($principal[$prop])) {
unset($principal[$prop]);
} else {
$principal[$prop] = $value;
}
-
}
$this->principals[$principalIndex] = $principal;
return true;
-
});
-
}
-
-
}
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOMySQLTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOMySQLTest.php
index 8779eb69f..54795cf4d 100644
--- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOMySQLTest.php
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOMySQLTest.php
@@ -1,9 +1,10 @@
<?php
-namespace Sabre\DAVACL\PrincipalBackend;
+declare(strict_types=1);
-class PDOMySQLTest extends AbstractPDOTest {
+namespace Sabre\DAVACL\PrincipalBackend;
+class PDOMySQLTest extends AbstractPDOTest
+{
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 48454981d..549e0bd60 100644
--- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOSqliteTest.php
+++ b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOSqliteTest.php
@@ -1,9 +1,10 @@
<?php
-namespace Sabre\DAVACL\PrincipalBackend;
+declare(strict_types=1);
-class PDOSqliteTest extends AbstractPDOTest {
+namespace Sabre\DAVACL\PrincipalBackend;
+class PDOSqliteTest extends AbstractPDOTest
+{
public $driver = 'sqlite';
-
}