mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2025-07-29 07:51:47 +00:00
Initial Release of the calendar plugin
This commit is contained in:
parent
45cc9885fc
commit
7115197a33
561 changed files with 189494 additions and 0 deletions
|
@ -0,0 +1,172 @@
|
|||
<?php
|
||||
|
||||
abstract class Sabre_DAVACL_PrincipalBackend_AbstractPDOTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
abstract function getPDO();
|
||||
|
||||
function testConstruct() {
|
||||
|
||||
$pdo = $this->getPDO();
|
||||
$backend = new Sabre_DAVACL_PrincipalBackend_PDO($pdo);
|
||||
$this->assertTrue($backend instanceof Sabre_DAVACL_PrincipalBackend_PDO);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testConstruct
|
||||
*/
|
||||
function testGetPrincipalsByPrefix() {
|
||||
|
||||
$pdo = $this->getPDO();
|
||||
$backend = new Sabre_DAVACL_PrincipalBackend_PDO($pdo);
|
||||
|
||||
$expected = array(
|
||||
array(
|
||||
'uri' => 'principals/user',
|
||||
'{http://sabredav.org/ns}email-address' => 'user@example.org',
|
||||
'{DAV:}displayname' => 'User',
|
||||
),
|
||||
array(
|
||||
'uri' => 'principals/group',
|
||||
'{http://sabredav.org/ns}email-address' => 'group@example.org',
|
||||
'{DAV:}displayname' => 'Group',
|
||||
),
|
||||
);
|
||||
|
||||
$this->assertEquals($expected, $backend->getPrincipalsByPrefix('principals'));
|
||||
$this->assertEquals(array(), $backend->getPrincipalsByPrefix('foo'));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @depends testConstruct
|
||||
*/
|
||||
function testGetPrincipalByPath() {
|
||||
|
||||
$pdo = $this->getPDO();
|
||||
$backend = new Sabre_DAVACL_PrincipalBackend_PDO($pdo);
|
||||
|
||||
$expected = array(
|
||||
'id' => 1,
|
||||
'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'));
|
||||
|
||||
}
|
||||
|
||||
function testGetGroupMemberSet() {
|
||||
|
||||
$pdo = $this->getPDO();
|
||||
$backend = new Sabre_DAVACL_PrincipalBackend_PDO($pdo);
|
||||
$expected = array('principals/user');
|
||||
|
||||
$this->assertEquals($expected,$backend->getGroupMemberSet('principals/group'));
|
||||
|
||||
}
|
||||
|
||||
function testGetGroupMembership() {
|
||||
|
||||
$pdo = $this->getPDO();
|
||||
$backend = new Sabre_DAVACL_PrincipalBackend_PDO($pdo);
|
||||
$expected = array('principals/group');
|
||||
|
||||
$this->assertEquals($expected,$backend->getGroupMembership('principals/user'));
|
||||
|
||||
}
|
||||
|
||||
function testSetGroupMemberSet() {
|
||||
|
||||
$pdo = $this->getPDO();
|
||||
|
||||
// Start situation
|
||||
$backend = new Sabre_DAVACL_PrincipalBackend_PDO($pdo);
|
||||
$this->assertEquals(array('principals/user'), $backend->getGroupMemberSet('principals/group'));
|
||||
|
||||
// Removing all principals
|
||||
$backend->setGroupMemberSet('principals/group', array());
|
||||
$this->assertEquals(array(), $backend->getGroupMemberSet('principals/group'));
|
||||
|
||||
// Adding principals again
|
||||
$backend->setGroupMemberSet('principals/group', array('principals/user'));
|
||||
$this->assertEquals(array('principals/user'), $backend->getGroupMemberSet('principals/group'));
|
||||
|
||||
|
||||
}
|
||||
|
||||
function testSearchPrincipals() {
|
||||
|
||||
$pdo = $this->getPDO();
|
||||
|
||||
$backend = new Sabre_DAVACL_PrincipalBackend_PDO($pdo);
|
||||
|
||||
$result = $backend->searchPrincipals('principals', array('{DAV:}blabla' => 'foo'));
|
||||
$this->assertEquals(array(), $result);
|
||||
|
||||
$result = $backend->searchPrincipals('principals', array('{DAV:}displayname' => 'ou'));
|
||||
$this->assertEquals(array('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('mom', array('{DAV:}displayname' => 'UsEr', '{http://sabredav.org/ns}email-address' => 'USER@EXAMPLE'));
|
||||
$this->assertEquals(array(), $result);
|
||||
|
||||
}
|
||||
|
||||
function testUpdatePrincipal() {
|
||||
|
||||
$pdo = $this->getPDO();
|
||||
$backend = new Sabre_DAVACL_PrincipalBackend_PDO($pdo);
|
||||
|
||||
$result = $backend->updatePrincipal('principals/user', array(
|
||||
'{DAV:}displayname' => 'pietje',
|
||||
'{http://sabredav.org/ns}vcard-url' => 'blabla',
|
||||
));
|
||||
|
||||
$this->assertTrue($result);
|
||||
|
||||
$this->assertEquals(array(
|
||||
'id' => 1,
|
||||
'uri' => 'principals/user',
|
||||
'{DAV:}displayname' => 'pietje',
|
||||
'{http://sabredav.org/ns}vcard-url' => 'blabla',
|
||||
'{http://sabredav.org/ns}email-address' => 'user@example.org',
|
||||
), $backend->getPrincipalByPath('principals/user'));
|
||||
|
||||
}
|
||||
|
||||
function testUpdatePrincipalUnknownField() {
|
||||
|
||||
$pdo = $this->getPDO();
|
||||
$backend = new Sabre_DAVACL_PrincipalBackend_PDO($pdo);
|
||||
|
||||
$result = $backend->updatePrincipal('principals/user', array(
|
||||
'{DAV:}displayname' => 'pietje',
|
||||
'{http://sabredav.org/ns}vcard-url' => 'blabla',
|
||||
'{DAV:}unknown' => 'foo',
|
||||
));
|
||||
|
||||
$this->assertEquals(array(
|
||||
424 => array(
|
||||
'{DAV:}displayname' => null,
|
||||
'{http://sabredav.org/ns}vcard-url' => null,
|
||||
),
|
||||
403 => array(
|
||||
'{DAV:}unknown' => null,
|
||||
),
|
||||
), $result);
|
||||
|
||||
$this->assertEquals(array(
|
||||
'id' => '1',
|
||||
'uri' => 'principals/user',
|
||||
'{DAV:}displayname' => 'User',
|
||||
'{http://sabredav.org/ns}email-address' => 'user@example.org',
|
||||
), $backend->getPrincipalByPath('principals/user'));
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
require_once 'Sabre/TestUtil.php';
|
||||
|
||||
class Sabre_DAVACL_PrincipalBackend_PDOMySQLTest extends Sabre_DAVACL_PrincipalBackend_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("
|
||||
create table principals (
|
||||
id integer unsigned not null primary key auto_increment,
|
||||
uri varchar(50),
|
||||
email varchar(80),
|
||||
displayname VARCHAR(80),
|
||||
vcardurl VARCHAR(80),
|
||||
unique(uri)
|
||||
);");
|
||||
|
||||
$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("DROP TABLE IF EXISTS groupmembers");
|
||||
$pdo->query("CREATE TABLE groupmembers (
|
||||
id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
|
||||
principal_id INTEGER UNSIGNED NOT NULL,
|
||||
member_id INTEGER UNSIGNED NOT NULL,
|
||||
UNIQUE(principal_id, member_id)
|
||||
);");
|
||||
|
||||
$pdo->query("INSERT INTO groupmembers (principal_id,member_id) VALUES (2,1)");
|
||||
|
||||
return $pdo;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
require_once 'Sabre/DAV/Auth/Backend/AbstractPDOTest.php';
|
||||
|
||||
class Sabre_DAVACL_PrincipalBackend_PDOSQLiteTest extends Sabre_DAVACL_PrincipalBackend_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), vcardurl VARCHAR(80))');
|
||||
$pdo->query('INSERT INTO principals VALUES (1, "principals/user","user@example.org","User",null)');
|
||||
$pdo->query('INSERT INTO principals VALUES (2, "principals/group","group@example.org","Group",null)');
|
||||
|
||||
$pdo->query("CREATE TABLE groupmembers (
|
||||
id INTEGER PRIMARY KEY ASC,
|
||||
principal_id INT,
|
||||
member_id INT,
|
||||
UNIQUE(principal_id, member_id)
|
||||
);");
|
||||
|
||||
$pdo->query("INSERT INTO groupmembers (principal_id,member_id) VALUES (2,1)");
|
||||
|
||||
return $pdo;
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue