moved deprecated communityhome, dav and yourls to the deprecated-addons repository

This commit is contained in:
Tobias Diekershoff 2018-06-02 11:23:11 +02:00
commit 31520f804d
675 changed files with 195144 additions and 0 deletions

View file

@ -0,0 +1,192 @@
<?php
abstract class Sabre_DAV_Locks_Backend_AbstractTest extends PHPUnit_Framework_TestCase {
/**
* @abstract
* @return Sabre_DAV_Locks_Backend_Abstract
*/
abstract function getBackend();
function testSetup() {
$backend = $this->getBackend();
$this->assertInstanceOf('Sabre_DAV_Locks_Backend_Abstract', $backend);
}
/**
* @depends testSetup
*/
function testGetLocks() {
$backend = $this->getBackend();
$lock = new Sabre_DAV_Locks_LockInfo();
$lock->owner = 'Sinterklaas';
$lock->timeout = 60;
$lock->created = time();
$lock->token = 'MY-UNIQUE-TOKEN';
$lock->uri ='someuri';
$this->assertTrue($backend->lock('someuri', $lock));
$locks = $backend->getLocks('someuri', false);
$this->assertEquals(1,count($locks));
$this->assertEquals('Sinterklaas',$locks[0]->owner);
$this->assertEquals('someuri',$locks[0]->uri);
}
/**
* @depends testGetLocks
*/
function testGetLocksParent() {
$backend = $this->getBackend();
$lock = new Sabre_DAV_Locks_LockInfo();
$lock->owner = 'Sinterklaas';
$lock->timeout = 60;
$lock->created = time();
$lock->depth = Sabre_DAV_Server::DEPTH_INFINITY;
$lock->token = 'MY-UNIQUE-TOKEN';
$this->assertTrue($backend->lock('someuri', $lock));
$locks = $backend->getLocks('someuri/child', false);
$this->assertEquals(1,count($locks));
$this->assertEquals('Sinterklaas',$locks[0]->owner);
$this->assertEquals('someuri',$locks[0]->uri);
}
/**
* @depends testGetLocks
*/
function testGetLocksParentDepth0() {
$backend = $this->getBackend();
$lock = new Sabre_DAV_Locks_LockInfo();
$lock->owner = 'Sinterklaas';
$lock->timeout = 60;
$lock->created = time();
$lock->depth = 0;
$lock->token = 'MY-UNIQUE-TOKEN';
$this->assertTrue($backend->lock('someuri', $lock));
$locks = $backend->getLocks('someuri/child', false);
$this->assertEquals(0,count($locks));
}
function testGetLocksChildren() {
$backend = $this->getBackend();
$lock = new Sabre_DAV_Locks_LockInfo();
$lock->owner = 'Sinterklaas';
$lock->timeout = 60;
$lock->created = time();
$lock->depth = 0;
$lock->token = 'MY-UNIQUE-TOKEN';
$this->assertTrue($backend->lock('someuri/child', $lock));
$locks = $backend->getLocks('someuri/child', false);
$this->assertEquals(1,count($locks));
$locks = $backend->getLocks('someuri', false);
$this->assertEquals(0,count($locks));
$locks = $backend->getLocks('someuri', true);
$this->assertEquals(1,count($locks));
}
/**
* @depends testGetLocks
*/
function testLockRefresh() {
$backend = $this->getBackend();
$lock = new Sabre_DAV_Locks_LockInfo();
$lock->owner = 'Sinterklaas';
$lock->timeout = 60;
$lock->created = time();
$lock->token = 'MY-UNIQUE-TOKEN';
$this->assertTrue($backend->lock('someuri', $lock));
/* Second time */
$lock->owner = 'Santa Clause';
$this->assertTrue($backend->lock('someuri', $lock));
$locks = $backend->getLocks('someuri', false);
$this->assertEquals(1,count($locks));
$this->assertEquals('Santa Clause',$locks[0]->owner);
$this->assertEquals('someuri',$locks[0]->uri);
}
/**
* @depends testGetLocks
*/
function testUnlock() {
$backend = $this->getBackend();
$lock = new Sabre_DAV_Locks_LockInfo();
$lock->owner = 'Sinterklaas';
$lock->timeout = 60;
$lock->created = time();
$lock->token = 'MY-UNIQUE-TOKEN';
$this->assertTrue($backend->lock('someuri', $lock));
$locks = $backend->getLocks('someuri', false);
$this->assertEquals(1,count($locks));
$this->assertTrue($backend->unlock('someuri',$lock));
$locks = $backend->getLocks('someuri', false);
$this->assertEquals(0,count($locks));
}
/**
* @depends testUnlock
*/
function testUnlockUnknownToken() {
$backend = $this->getBackend();
$lock = new Sabre_DAV_Locks_LockInfo();
$lock->owner = 'Sinterklaas';
$lock->timeout = 60;
$lock->created = time();
$lock->token = 'MY-UNIQUE-TOKEN';
$this->assertTrue($backend->lock('someuri', $lock));
$locks = $backend->getLocks('someuri', false);
$this->assertEquals(1,count($locks));
$lock->token = 'SOME-OTHER-TOKEN';
$this->assertFalse($backend->unlock('someuri',$lock));
$locks = $backend->getLocks('someuri', false);
$this->assertEquals(1,count($locks));
}
}

View file

@ -0,0 +1,29 @@
<?php
require_once 'Sabre/TestUtil.php';
class Sabre_DAV_Locks_Backend_FSTest extends Sabre_DAV_Locks_Backend_AbstractTest {
function getBackend() {
Sabre_TestUtil::clearTempDir();
mkdir(SABRE_TEMPDIR . '/locks');
$backend = new Sabre_DAV_Locks_Backend_FS(SABRE_TEMPDIR . '/locks/');
return $backend;
}
function tearDown() {
Sabre_TestUtil::clearTempDir();
}
function testGetLocksChildren() {
// We're skipping this test. This doesn't work, and it will
// never. The class is deprecated anyway.
}
}

View file

@ -0,0 +1,22 @@
<?php
require_once 'Sabre/TestUtil.php';
class Sabre_DAV_Locks_Backend_FileTest extends Sabre_DAV_Locks_Backend_AbstractTest {
function getBackend() {
Sabre_TestUtil::clearTempDir();
$backend = new Sabre_DAV_Locks_Backend_File(SABRE_TEMPDIR . '/lockdb');
return $backend;
}
function tearDown() {
Sabre_TestUtil::clearTempDir();
}
}

View file

@ -0,0 +1,30 @@
<?php
require_once 'Sabre/TestUtil.php';
class Sabre_DAV_Locks_Backend_PDOMySQLTest extends Sabre_DAV_Locks_Backend_AbstractTest {
function getBackend() {
if (!SABRE_HASMYSQL) $this->markTestSkipped('MySQL driver is not available, or it was not properly configured');
$pdo = Sabre_TestUtil::getMySQLDB();
if (!$pdo) $this->markTestSkipped('Could not connect to MySQL database');
$pdo->query('DROP TABLE IF EXISTS locks;');
$pdo->query("
CREATE TABLE locks (
id INTEGER UNSIGNED NOT NULL PRIMARY KEY AUTO_INCREMENT,
owner VARCHAR(100),
timeout INTEGER UNSIGNED,
created INTEGER,
token VARCHAR(100),
scope TINYINT,
depth TINYINT,
uri text
);");
$backend = new Sabre_DAV_Locks_Backend_PDO($pdo);
return $backend;
}
}

View file

@ -0,0 +1,27 @@
<?php
require_once 'Sabre/TestUtil.php';
require_once 'Sabre/DAV/Locks/Backend/AbstractTest.php';
class Sabre_DAV_Locks_Backend_PDOTest extends Sabre_DAV_Locks_Backend_AbstractTest {
function getBackend() {
if (!SABRE_HASSQLITE) $this->markTestSkipped('SQLite driver is not available');
Sabre_TestUtil::clearTempDir();
mkdir(SABRE_TEMPDIR . '/pdolocks');
$pdo = new PDO('sqlite:' . SABRE_TEMPDIR . '/pdolocks/db.sqlite');
$pdo->setAttribute(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION);
$pdo->query('CREATE TABLE locks ( id integer primary key asc, owner text, timeout text, created integer, token text, scope integer, depth integer, uri text)');
$backend = new Sabre_DAV_Locks_Backend_PDO($pdo);
return $backend;
}
function tearDown() {
Sabre_TestUtil::clearTempDir();
}
}