Introduce PSR-4 autoloading
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
<?php
|
||||
class autoTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testAutoloaderReturnsFalseWhenCallingNonExistingClass()
|
||||
{
|
||||
$this->assertFalse(auto::loader('foo2501bar42'), 'calling non existent class');
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
use PrivateBin\serversalt;
|
||||
|
||||
error_reporting( E_ALL | E_STRICT );
|
||||
|
||||
// change this, if your php files and data is outside of your webservers document root
|
||||
@@ -7,7 +10,7 @@ if (!defined('PATH')) define('PATH', '..' . DIRECTORY_SEPARATOR);
|
||||
if (!defined('CONF')) define('CONF', PATH . 'cfg' . DIRECTORY_SEPARATOR . 'conf.ini');
|
||||
if (!is_file(CONF)) copy(CONF . '.sample', CONF);
|
||||
|
||||
require PATH . 'lib/auto.php';
|
||||
require PATH . 'vendor/autoload.php';
|
||||
|
||||
class helper
|
||||
{
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
use PrivateBin\configuration;
|
||||
|
||||
class configurationTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $_options;
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
use PrivateBin\filter;
|
||||
|
||||
class filterTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testFilterStripsSlashesDeeply()
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
use PrivateBin\i18n;
|
||||
|
||||
class i18nTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $_translations = array();
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
<?php
|
||||
|
||||
use PrivateBin\data\data;
|
||||
use PrivateBin\privatebin;
|
||||
use PrivateBin\request;
|
||||
use PrivateBin\serversalt;
|
||||
|
||||
class jsonApiTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $_model;
|
||||
@@ -6,7 +12,7 @@ class jsonApiTest extends PHPUnit_Framework_TestCase
|
||||
public function setUp()
|
||||
{
|
||||
/* Setup Routine */
|
||||
$this->_model = privatebin_data::getInstance(array('dir' => PATH . 'data'));
|
||||
$this->_model = data::getInstance(array('dir' => PATH . 'data'));
|
||||
serversalt::setPath(PATH . 'data');
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,11 @@
|
||||
<?php
|
||||
|
||||
use PrivateBin\configuration;
|
||||
use PrivateBin\data\db;
|
||||
use PrivateBin\model;
|
||||
use PrivateBin\model\paste;
|
||||
use PrivateBin\vizhash16x16;
|
||||
|
||||
class modelTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $_conf;
|
||||
@@ -165,9 +172,9 @@ class modelTest extends PHPUnit_Framework_TestCase
|
||||
|
||||
public function testPasteIdValidation()
|
||||
{
|
||||
$this->assertTrue(model_paste::isValidId('a242ab7bdfb2581a'), 'valid paste id');
|
||||
$this->assertFalse(model_paste::isValidId('foo'), 'invalid hex values');
|
||||
$this->assertFalse(model_paste::isValidId('../bar/baz'), 'path attack');
|
||||
$this->assertTrue(paste::isValidId('a242ab7bdfb2581a'), 'valid paste id');
|
||||
$this->assertFalse(paste::isValidId('foo'), 'invalid hex values');
|
||||
$this->assertFalse(paste::isValidId('../bar/baz'), 'path attack');
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -214,7 +221,7 @@ class modelTest extends PHPUnit_Framework_TestCase
|
||||
public function testPurge()
|
||||
{
|
||||
$conf = new configuration;
|
||||
$store = privatebin_db::getInstance($conf->getSection('model_options'));
|
||||
$store = db::getInstance($conf->getSection('model_options'));
|
||||
$store->delete(helper::getPasteId());
|
||||
$expired = helper::getPaste(array('expire_date' => 1344803344));
|
||||
$paste = helper::getPaste(array('expire_date' => time() + 3600));
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<whitelist>
|
||||
<directory suffix=".php">../lib</directory>
|
||||
<exclude>
|
||||
<file>../lib/privatebin/abstract.php</file>
|
||||
<file>../lib/data/AbstractData.php</file>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
<?php
|
||||
|
||||
use PrivateBin\data\data;
|
||||
use PrivateBin\privatebin;
|
||||
use PrivateBin\serversalt;
|
||||
use PrivateBin\trafficlimiter;
|
||||
|
||||
class privatebinTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $_model;
|
||||
@@ -6,7 +12,7 @@ class privatebinTest extends PHPUnit_Framework_TestCase
|
||||
public function setUp()
|
||||
{
|
||||
/* Setup Routine */
|
||||
$this->_model = privatebin_data::getInstance(array('dir' => PATH . 'data'));
|
||||
$this->_model = data::getInstance(array('dir' => PATH . 'data'));
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
use PrivateBin\data\data;
|
||||
|
||||
class privatebin_dataTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $_model;
|
||||
@@ -9,7 +12,7 @@ class privatebin_dataTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
/* Setup Routine */
|
||||
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
|
||||
$this->_model = privatebin_data::getInstance(array('dir' => $this->_path));
|
||||
$this->_model = data::getInstance(array('dir' => $this->_path));
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
use PrivateBin\data\db;
|
||||
|
||||
class privatebin_dbTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $_model;
|
||||
@@ -13,7 +16,7 @@ class privatebin_dbTest extends PHPUnit_Framework_TestCase
|
||||
public function setUp()
|
||||
{
|
||||
/* Setup Routine */
|
||||
$this->_model = privatebin_db::getInstance($this->_options);
|
||||
$this->_model = db::getInstance($this->_options);
|
||||
}
|
||||
|
||||
public function tearDown()
|
||||
@@ -110,7 +113,7 @@ class privatebin_dbTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGetIbmInstance()
|
||||
{
|
||||
privatebin_db::getInstance(array(
|
||||
db::getInstance(array(
|
||||
'dsn' => 'ibm:', 'usr' => null, 'pwd' => null,
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
|
||||
));
|
||||
@@ -121,7 +124,7 @@ class privatebin_dbTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGetInformixInstance()
|
||||
{
|
||||
privatebin_db::getInstance(array(
|
||||
db::getInstance(array(
|
||||
'dsn' => 'informix:', 'usr' => null, 'pwd' => null,
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
|
||||
));
|
||||
@@ -132,7 +135,7 @@ class privatebin_dbTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGetMssqlInstance()
|
||||
{
|
||||
privatebin_db::getInstance(array(
|
||||
db::getInstance(array(
|
||||
'dsn' => 'mssql:', 'usr' => null, 'pwd' => null,
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
|
||||
));
|
||||
@@ -143,7 +146,7 @@ class privatebin_dbTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGetMysqlInstance()
|
||||
{
|
||||
privatebin_db::getInstance(array(
|
||||
db::getInstance(array(
|
||||
'dsn' => 'mysql:', 'usr' => null, 'pwd' => null,
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
|
||||
));
|
||||
@@ -154,7 +157,7 @@ class privatebin_dbTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGetOciInstance()
|
||||
{
|
||||
privatebin_db::getInstance(array(
|
||||
db::getInstance(array(
|
||||
'dsn' => 'oci:', 'usr' => null, 'pwd' => null,
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
|
||||
));
|
||||
@@ -165,7 +168,7 @@ class privatebin_dbTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGetPgsqlInstance()
|
||||
{
|
||||
privatebin_db::getInstance(array(
|
||||
db::getInstance(array(
|
||||
'dsn' => 'pgsql:', 'usr' => null, 'pwd' => null,
|
||||
'opt' => array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION)
|
||||
));
|
||||
@@ -177,7 +180,7 @@ class privatebin_dbTest extends PHPUnit_Framework_TestCase
|
||||
*/
|
||||
public function testGetFooInstance()
|
||||
{
|
||||
privatebin_db::getInstance(array(
|
||||
db::getInstance(array(
|
||||
'dsn' => 'foo:', 'usr' => null, 'pwd' => null, 'opt' => null
|
||||
));
|
||||
}
|
||||
@@ -190,7 +193,7 @@ class privatebin_dbTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$options = $this->_options;
|
||||
unset($options['dsn']);
|
||||
privatebin_db::getInstance($options);
|
||||
db::getInstance($options);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -201,7 +204,7 @@ class privatebin_dbTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$options = $this->_options;
|
||||
unset($options['usr']);
|
||||
privatebin_db::getInstance($options);
|
||||
db::getInstance($options);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -212,7 +215,7 @@ class privatebin_dbTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$options = $this->_options;
|
||||
unset($options['pwd']);
|
||||
privatebin_db::getInstance($options);
|
||||
db::getInstance($options);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -223,7 +226,7 @@ class privatebin_dbTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
$options = $this->_options;
|
||||
unset($options['opt']);
|
||||
privatebin_db::getInstance($options);
|
||||
db::getInstance($options);
|
||||
}
|
||||
|
||||
public function testOldAttachments()
|
||||
@@ -233,7 +236,7 @@ class privatebin_dbTest extends PHPUnit_Framework_TestCase
|
||||
@unlink($path);
|
||||
$this->_options['dsn'] = 'sqlite:' . $path;
|
||||
$this->_options['tbl'] = 'bar_';
|
||||
$model = privatebin_db::getInstance($this->_options);
|
||||
$model = db::getInstance($this->_options);
|
||||
|
||||
$original = $paste = helper::getPasteWithAttachment(array('expire_date' => 1344803344));
|
||||
$paste['meta']['attachment'] = $paste['attachment'];
|
||||
@@ -301,7 +304,7 @@ class privatebin_dbTest extends PHPUnit_Framework_TestCase
|
||||
'vizhash BLOB, ' .
|
||||
"postdate INT );"
|
||||
);
|
||||
privatebin_db::getInstance($this->_options);
|
||||
db::getInstance($this->_options);
|
||||
helper::rmdir(PATH . 'data');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
<?php
|
||||
|
||||
use PrivateBin\data\db;
|
||||
use PrivateBin\privatebin;
|
||||
use PrivateBin\serversalt;
|
||||
use PrivateBin\trafficlimiter;
|
||||
|
||||
require_once 'privatebin.php';
|
||||
|
||||
class privatebinWithDbTest extends privatebinTest
|
||||
@@ -20,7 +26,7 @@ class privatebinWithDbTest extends privatebinTest
|
||||
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
|
||||
if(!is_dir($this->_path)) mkdir($this->_path);
|
||||
$this->_options['dsn'] = 'sqlite:' . $this->_path . DIRECTORY_SEPARATOR . 'tst.sq3';
|
||||
$this->_model = privatebin_db::getInstance($this->_options);
|
||||
$this->_model = db::getInstance($this->_options);
|
||||
$this->reset();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
use PrivateBin\purgelimiter;
|
||||
|
||||
class purgelimiterTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $_path;
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
use PrivateBin\request;
|
||||
|
||||
class requestTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function setUp()
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
use PrivateBin\serversalt;
|
||||
|
||||
class serversaltTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $_path;
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
use PrivateBin\sjcl;
|
||||
|
||||
class sjclTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
public function testSjclValidatorValidatesCorrectly()
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
<?php
|
||||
|
||||
use PrivateBin\trafficlimiter;
|
||||
|
||||
class trafficlimiterTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $_path;
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<?php
|
||||
|
||||
use PrivateBin\i18n;
|
||||
use PrivateBin\view;
|
||||
|
||||
class viewTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
private static $error = 'foo bar';
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
<?php
|
||||
|
||||
use PrivateBin\serversalt;
|
||||
use PrivateBin\vizhash16x16;
|
||||
|
||||
class vizhash16x16Test extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
private $_file;
|
||||
|
||||
Reference in New Issue
Block a user