diff options
Diffstat (limited to 'vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend')
4 files changed, 0 insertions, 397 deletions
diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/AbstractPDOTest.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/AbstractPDOTest.php deleted file mode 100644 index b18ab9488..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/AbstractPDOTest.php +++ /dev/null @@ -1,219 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAVACL\PrincipalBackend; - -use Sabre\DAV; - -abstract class AbstractPDOTest extends \PHPUnit\Framework\TestCase -{ - use DAV\DbTestHelperTrait; - - public function setup(): void - { - $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)'); - } - - public function testConstruct() - { - $pdo = $this->getPDO(); - $backend = new PDO($pdo); - $this->assertTrue($backend instanceof PDO); - } - - /** - * @depends testConstruct - */ - public function testGetPrincipalsByPrefix() - { - $pdo = $this->getPDO(); - $backend = new PDO($pdo); - - $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', - ], - [ - 'uri' => 'principals/group', - '{http://sabredav.org/ns}email-address' => 'group@example.org', - '{DAV:}displayname' => 'Group', - ], - ]; - - $this->assertEquals($expected, $backend->getPrincipalsByPrefix('principals')); - $this->assertEquals([], $backend->getPrincipalsByPrefix('foo')); - } - - /** - * @depends testConstruct - */ - public function testGetPrincipalByPath() - { - $pdo = $this->getPDO(); - $backend = new PDO($pdo); - - $expected = [ - 'id' => 4, - 'uri' => 'principals/user', - '{http://sabredav.org/ns}email-address' => 'user@example.org', - '{DAV:}displayname' => 'User', - ]; - - $this->assertEquals($expected, $backend->getPrincipalByPath('principals/user')); - $this->assertEquals(null, $backend->getPrincipalByPath('foo')); - } - - public function testGetGroupMemberSet() - { - $pdo = $this->getPDO(); - $backend = new PDO($pdo); - $expected = ['principals/user']; - - $this->assertEquals($expected, $backend->getGroupMemberSet('principals/group')); - } - - public function testGetGroupMembership() - { - $pdo = $this->getPDO(); - $backend = new PDO($pdo); - $expected = ['principals/group']; - - $this->assertEquals($expected, $backend->getGroupMembership('principals/user')); - } - - public function testSetGroupMemberSet() - { - $pdo = $this->getPDO(); - - // Start situation - $backend = new PDO($pdo); - $this->assertEquals(['principals/user'], $backend->getGroupMemberSet('principals/group')); - - // Removing all principals - $backend->setGroupMemberSet('principals/group', []); - $this->assertEquals([], $backend->getGroupMemberSet('principals/group')); - - // Adding principals again - $backend->setGroupMemberSet('principals/group', ['principals/user']); - $this->assertEquals(['principals/user'], $backend->getGroupMemberSet('principals/group')); - } - - public function testSearchPrincipals() - { - $pdo = $this->getPDO(); - - $backend = new PDO($pdo); - - $result = $backend->searchPrincipals('principals', ['{DAV:}blabla' => 'foo']); - $this->assertEquals([], $result); - - $result = $backend->searchPrincipals('principals', ['{DAV:}displayname' => 'ou']); - $this->assertEquals(['principals/group'], $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', ['{DAV:}displayname' => 'UsEr', '{http://sabredav.org/ns}email-address' => 'USER@EXAMPLE']); - $this->assertEquals([], $result); - } - - public function testUpdatePrincipal() - { - $pdo = $this->getPDO(); - $backend = new PDO($pdo); - - $propPatch = new DAV\PropPatch([ - '{DAV:}displayname' => 'pietje', - ]); - - $backend->updatePrincipal('principals/user', $propPatch); - $result = $propPatch->commit(); - - $this->assertTrue($result); - - $this->assertEquals([ - 'id' => 4, - 'uri' => 'principals/user', - '{DAV:}displayname' => 'pietje', - '{http://sabredav.org/ns}email-address' => 'user@example.org', - ], $backend->getPrincipalByPath('principals/user')); - } - - public function testUpdatePrincipalUnknownField() - { - $pdo = $this->getPDO(); - $backend = new PDO($pdo); - - $propPatch = new DAV\PropPatch([ - '{DAV:}displayname' => 'pietje', - '{DAV:}unknown' => 'foo', - ]); - - $backend->updatePrincipal('principals/user', $propPatch); - $result = $propPatch->commit(); - - $this->assertFalse($result); - - $this->assertEquals([ - '{DAV:}displayname' => 424, - '{DAV:}unknown' => 403, - ], $propPatch->getResult()); - - $this->assertEquals([ - 'id' => '4', - 'uri' => 'principals/user', - '{DAV:}displayname' => 'User', - '{http://sabredav.org/ns}email-address' => 'user@example.org', - ], $backend->getPrincipalByPath('principals/user')); - } - - public function testFindByUriUnknownScheme() - { - $pdo = $this->getPDO(); - $backend = new PDO($pdo); - $this->assertNull($backend->findByUri('http://foo', 'principals')); - } - - public function testFindByUriWithMailtoAddress() - { - $pdo = $this->getPDO(); - $backend = new PDO($pdo); - $this->assertEquals( - 'principals/user', - $backend->findByUri('mailto:user@example.org', 'principals') - ); - } - - public function testFindByUriWithUri() - { - $pdo = $this->getPDO(); - $backend = new PDO($pdo); - $this->assertEquals( - 'principals/user', - $backend->findByUri('principals/user', 'principals') - ); - } - - public function testFindByUriWithUnknownUri() - { - $pdo = $this->getPDO(); - $backend = new PDO($pdo); - $this->assertNull($backend->findByUri('principals/other', 'principals')); - } -} diff --git a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/Mock.php b/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/Mock.php deleted file mode 100644 index 5f0434579..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/Mock.php +++ /dev/null @@ -1,158 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAVACL\PrincipalBackend; - -class Mock extends AbstractBackend -{ - public $groupMembers = []; - public $principals; - - public function __construct(array $principals = null) - { - $this->principals = $principals; - - if (is_null($principals)) { - $this->principals = [ - [ - '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', - ], - [ - 'uri' => 'principals/admin', - '{DAV:}displayname' => 'Admin', - ], - [ - 'uri' => 'principals/user2', - '{DAV:}displayname' => 'User 2', - '{http://sabredav.org/ns}email-address' => 'user2.sabredav@sabredav.org', - ], - ]; - } - } - - public function getPrincipalsByPrefix($prefix) - { - $prefix = trim($prefix, '/'); - if ($prefix) { - $prefix .= '/'; - } - $return = []; - - foreach ($this->principals as $principal) { - if ($prefix && 0 !== strpos($principal['uri'], $prefix)) { - continue; - } - - $return[] = $principal; - } - - return $return; - } - - public function addPrincipal(array $principal) - { - $this->principals[] = $principal; - } - - public function getPrincipalByPath($path) - { - foreach ($this->getPrincipalsByPrefix('principals') as $principal) { - if ($principal['uri'] === $path) { - return $principal; - } - } - } - - 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 (false === mb_stripos($principal[$key], $value, 0, 'UTF-8')) { - continue 2; - } - - // We have a match for this searchProperty! - if ('allof' === $test) { - continue; - } else { - break; - } - } - $matches[] = $principal['uri']; - } - - return $matches; - } - - public function getGroupMemberSet($path) - { - return isset($this->groupMembers[$path]) ? $this->groupMembers[$path] : []; - } - - public function getGroupMembership($path) - { - $membership = []; - foreach ($this->groupMembers as $group => $members) { - if (in_array($path, $members)) { - $membership[] = $group; - } - } - - return $membership; - } - - public function setGroupMemberSet($path, array $members) - { - $this->groupMembers[$path] = $members; - } - - /** - * Updates one ore more webdav properties on a principal. - * - * The list of mutations is stored in a Sabre\DAV\PropPatch object. - * To do the actual updates, you must tell this object which properties - * you're going to process with the handle() method. - * - * Calling the handle method is like telling the PropPatch object "I - * promise I can handle updating this property". - * - * Read the PropPatch documentation for more info and examples. - * - * @param string $path - */ - public function updatePrincipal($path, \Sabre\DAV\PropPatch $propPatch) - { - $value = null; - foreach ($this->principals as $principalIndex => $value) { - if ($value['uri'] === $path) { - $principal = $value; - break; - } - } - 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 deleted file mode 100644 index 54795cf4d..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOMySQLTest.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php - -declare(strict_types=1); - -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 deleted file mode 100644 index 549e0bd60..000000000 --- a/vendor/sabre/dav/tests/Sabre/DAVACL/PrincipalBackend/PDOSqliteTest.php +++ /dev/null @@ -1,10 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace Sabre\DAVACL\PrincipalBackend; - -class PDOSqliteTest extends AbstractPDOTest -{ - public $driver = 'sqlite'; -} |