started script for storage backend migrations
todo: GCS added GCS, no GLOBALS, two methods for saving pastes and comments use GLOBALS for verbosity again added getAllPastes() to all storage providers moved to bin, added --delete options, make use of $store->getAllPastes() added --delete-* options to help longopts without -- *sigh* fixed arguments drop singleton behaviour to allow multiple backends of the same type simultaneously remove singleton from Model, collapse loop in migrate.php comments is not indexed tests without data singleton fix exit if scandir() fails extended meta doc
This commit is contained in:
@@ -22,7 +22,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/* Setup Routine */
|
||||
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
|
||||
$this->_model = Database::getInstance($this->_options);
|
||||
$this->_model = new Database($this->_options);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
@@ -35,7 +35,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
public function testSaltMigration()
|
||||
{
|
||||
ServerSalt::setStore(Filesystem::getInstance(array('dir' => 'data')));
|
||||
ServerSalt::setStore(new Filesystem(array('dir' => 'data')));
|
||||
$salt = ServerSalt::get();
|
||||
$file = 'data' . DIRECTORY_SEPARATOR . 'salt.php';
|
||||
$this->assertFileExists($file, 'ServerSalt got initialized and stored on disk');
|
||||
@@ -141,7 +141,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGetIbmInstance()
|
||||
{
|
||||
Database::getInstance(array(
|
||||
new Database(array(
|
||||
'dsn' => 'ibm:', 'usr' => null, 'pwd' => null,
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION),
|
||||
));
|
||||
@@ -152,7 +152,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGetInformixInstance()
|
||||
{
|
||||
Database::getInstance(array(
|
||||
new Database(array(
|
||||
'dsn' => 'informix:', 'usr' => null, 'pwd' => null,
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION),
|
||||
));
|
||||
@@ -163,7 +163,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGetMssqlInstance()
|
||||
{
|
||||
Database::getInstance(array(
|
||||
new Database(array(
|
||||
'dsn' => 'mssql:', 'usr' => null, 'pwd' => null,
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION),
|
||||
));
|
||||
@@ -174,7 +174,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGetMysqlInstance()
|
||||
{
|
||||
Database::getInstance(array(
|
||||
new Database(array(
|
||||
'dsn' => 'mysql:', 'usr' => null, 'pwd' => null,
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION),
|
||||
));
|
||||
@@ -185,7 +185,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGetOciInstance()
|
||||
{
|
||||
Database::getInstance(array(
|
||||
new Database(array(
|
||||
'dsn' => 'oci:', 'usr' => null, 'pwd' => null,
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION),
|
||||
));
|
||||
@@ -196,7 +196,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGetPgsqlInstance()
|
||||
{
|
||||
Database::getInstance(array(
|
||||
new Database(array(
|
||||
'dsn' => 'pgsql:', 'usr' => null, 'pwd' => null,
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION),
|
||||
));
|
||||
@@ -208,7 +208,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGetFooInstance()
|
||||
{
|
||||
Database::getInstance(array(
|
||||
new Database(array(
|
||||
'dsn' => 'foo:', 'usr' => null, 'pwd' => null, 'opt' => null,
|
||||
));
|
||||
}
|
||||
@@ -221,7 +221,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$options = $this->_options;
|
||||
unset($options['dsn']);
|
||||
Database::getInstance($options);
|
||||
new Database($options);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -232,7 +232,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$options = $this->_options;
|
||||
unset($options['usr']);
|
||||
Database::getInstance($options);
|
||||
new Database($options);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -243,7 +243,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$options = $this->_options;
|
||||
unset($options['pwd']);
|
||||
Database::getInstance($options);
|
||||
new Database($options);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -254,7 +254,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$options = $this->_options;
|
||||
unset($options['opt']);
|
||||
Database::getInstance($options);
|
||||
new Database($options);
|
||||
}
|
||||
|
||||
public function testOldAttachments()
|
||||
@@ -266,7 +266,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
$this->_options['dsn'] = 'sqlite:' . $path;
|
||||
$this->_options['tbl'] = 'bar_';
|
||||
$model = Database::getInstance($this->_options);
|
||||
$model = new Database($this->_options);
|
||||
|
||||
$original = $paste = Helper::getPasteWithAttachment(1, array('expire_date' => 1344803344));
|
||||
$meta = $paste['meta'];
|
||||
@@ -311,7 +311,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
$this->_options['dsn'] = 'sqlite:' . $path;
|
||||
$this->_options['tbl'] = 'baz_';
|
||||
$model = Database::getInstance($this->_options);
|
||||
$model = new Database($this->_options);
|
||||
$paste = Helper::getPaste(1, array('expire_date' => 1344803344));
|
||||
unset($paste['meta']['formatter'], $paste['meta']['opendiscussion'], $paste['meta']['salt']);
|
||||
$model->delete(Helper::getPasteId());
|
||||
@@ -378,7 +378,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
|
||||
'vizhash BLOB, ' .
|
||||
'postdate INT );'
|
||||
);
|
||||
$this->assertInstanceOf('PrivateBin\\Data\\Database', Database::getInstance($this->_options));
|
||||
$this->assertInstanceOf('PrivateBin\\Data\\Database', new Database($this->_options));
|
||||
|
||||
// check if version number was upgraded in created configuration table
|
||||
$statement = $db->prepare('SELECT value FROM foo_config WHERE id LIKE ?');
|
||||
|
||||
@@ -15,7 +15,7 @@ class FilesystemTest extends PHPUnit_Framework_TestCase
|
||||
/* Setup Routine */
|
||||
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
|
||||
$this->_invalidPath = $this->_path . DIRECTORY_SEPARATOR . 'bar';
|
||||
$this->_model = Filesystem::getInstance(array('dir' => $this->_path));
|
||||
$this->_model = new Filesystem(array('dir' => $this->_path));
|
||||
if (!is_dir($this->_path)) {
|
||||
mkdir($this->_path);
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ class GoogleCloudStorageTest extends PHPUnit_Framework_TestCase
|
||||
public function setUp()
|
||||
{
|
||||
ini_set('error_log', stream_get_meta_data(tmpfile())['uri']);
|
||||
$this->_model = GoogleCloudStorage::getInstance(array(
|
||||
$this->_model = new GoogleCloudStorage(array(
|
||||
'bucket' => self::$_bucket->name(),
|
||||
'prefix' => 'pastes',
|
||||
));
|
||||
|
||||
Reference in New Issue
Block a user