renaming controller #342

This commit is contained in:
El RIDO 2018-07-29 15:17:35 +02:00
parent 90e83ddb30
commit f9c8441edb
No known key found for this signature in database
GPG key ID: 0F5C940A6BD81F92
10 changed files with 74 additions and 74 deletions

View file

@ -15,4 +15,4 @@ define('PATH', '');
define('PUBLIC_PATH', __DIR__); define('PUBLIC_PATH', __DIR__);
require PATH . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'; require PATH . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
new PrivateBin\PrivateBin; new PrivateBin\Controller;

View file

@ -17,11 +17,11 @@ use PrivateBin\Persistence\ServerSalt;
use PrivateBin\Persistence\TrafficLimiter; use PrivateBin\Persistence\TrafficLimiter;
/** /**
* PrivateBin * Controller
* *
* Controller, puts it all together. * Puts it all together.
*/ */
class PrivateBin class Controller
{ {
/** /**
* version * version
@ -151,7 +151,7 @@ class PrivateBin
} }
/** /**
* initialize privatebin * initialize PrivateBin
* *
* @access private * @access private
*/ */
@ -368,7 +368,7 @@ class PrivateBin
} }
/** /**
* Display PrivateBin frontend. * Display frontend.
* *
* @access private * @access private
*/ */

View file

@ -15,7 +15,7 @@ namespace PrivateBin\Data;
use Exception; use Exception;
use PDO; use PDO;
use PDOException; use PDOException;
use PrivateBin\PrivateBin; use PrivateBin\Controller;
use stdClass; use stdClass;
/** /**
@ -122,7 +122,7 @@ class Database extends AbstractData
} }
// create config table if necessary // create config table if necessary
$db_version = PrivateBin::VERSION; $db_version = Controller::VERSION;
if (!in_array(self::_sanitizeIdentifier('config'), $tables)) { if (!in_array(self::_sanitizeIdentifier('config'), $tables)) {
self::_createConfigTable(); self::_createConfigTable();
// if we only needed to create the config table, the DB is older then 0.22 // if we only needed to create the config table, the DB is older then 0.22
@ -134,7 +134,7 @@ class Database extends AbstractData
} }
// update database structure if necessary // update database structure if necessary
if (version_compare($db_version, PrivateBin::VERSION, '<')) { if (version_compare($db_version, Controller::VERSION, '<')) {
self::_upgradeDatabase($db_version); self::_upgradeDatabase($db_version);
} }
} else { } else {
@ -623,7 +623,7 @@ class Database extends AbstractData
self::_exec( self::_exec(
'INSERT INTO ' . self::_sanitizeIdentifier('config') . 'INSERT INTO ' . self::_sanitizeIdentifier('config') .
' VALUES(?,?)', ' VALUES(?,?)',
array('VERSION', PrivateBin::VERSION) array('VERSION', Controller::VERSION)
); );
} }
@ -698,7 +698,7 @@ class Database extends AbstractData
self::_exec( self::_exec(
'UPDATE ' . self::_sanitizeIdentifier('config') . 'UPDATE ' . self::_sanitizeIdentifier('config') .
' SET value = ? WHERE id = ?', ' SET value = ? WHERE id = ?',
array(PrivateBin::VERSION, 'VERSION') array(Controller::VERSION, 'VERSION')
); );
} }
} }

View file

@ -14,7 +14,7 @@ namespace PrivateBin\Model;
use Exception; use Exception;
use PrivateBin\Persistence\ServerSalt; use PrivateBin\Persistence\ServerSalt;
use PrivateBin\PrivateBin; use PrivateBin\Controller;
use PrivateBin\Sjcl; use PrivateBin\Sjcl;
/** /**
@ -35,14 +35,14 @@ class Paste extends AbstractModel
{ {
$data = $this->_store->read($this->getId()); $data = $this->_store->read($this->getId());
if ($data === false) { if ($data === false) {
throw new Exception(PrivateBin::GENERIC_ERROR, 64); throw new Exception(Controller::GENERIC_ERROR, 64);
} }
// check if paste has expired and delete it if neccessary. // check if paste has expired and delete it if neccessary.
if (property_exists($data->meta, 'expire_date')) { if (property_exists($data->meta, 'expire_date')) {
if ($data->meta->expire_date < time()) { if ($data->meta->expire_date < time()) {
$this->delete(); $this->delete();
throw new Exception(PrivateBin::GENERIC_ERROR, 63); throw new Exception(Controller::GENERIC_ERROR, 63);
} }
// We kindly provide the remaining time before expiration (in seconds) // We kindly provide the remaining time before expiration (in seconds)
$data->meta->remaining_time = $data->meta->expire_date - time(); $data->meta->remaining_time = $data->meta->expire_date - time();

View file

@ -3,9 +3,9 @@
use PrivateBin\Data\Filesystem; use PrivateBin\Data\Filesystem;
use PrivateBin\Persistence\ServerSalt; use PrivateBin\Persistence\ServerSalt;
use PrivateBin\Persistence\TrafficLimiter; use PrivateBin\Persistence\TrafficLimiter;
use PrivateBin\PrivateBin; use PrivateBin\Controller;
class PrivateBinTest extends PHPUnit_Framework_TestCase class ControllerTest extends PHPUnit_Framework_TestCase
{ {
protected $_model; protected $_model;
@ -49,7 +49,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
public function testView() public function testView()
{ {
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$this->assertContains( $this->assertContains(
@ -74,7 +74,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
Helper::createIniFile(CONF, $options); Helper::createIniFile(CONF, $options);
$_COOKIE['lang'] = 'de'; $_COOKIE['lang'] = 'de';
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$this->assertContains( $this->assertContains(
@ -95,7 +95,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
Helper::createIniFile(CONF, $options); Helper::createIniFile(CONF, $options);
$_COOKIE['lang'] = 'de'; $_COOKIE['lang'] = 'de';
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$this->assertContains( $this->assertContains(
@ -116,7 +116,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
Helper::createIniFile(CONF, $options); Helper::createIniFile(CONF, $options);
$_COOKIE['lang'] = 'de'; $_COOKIE['lang'] = 'de';
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$this->assertRegExp( $this->assertRegExp(
@ -139,7 +139,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$_SERVER['REQUEST_METHOD'] = 'POST'; $_SERVER['REQUEST_METHOD'] = 'POST';
$_SERVER['REMOTE_ADDR'] = '::1'; $_SERVER['REMOTE_ADDR'] = '::1';
ob_start(); ob_start();
new PrivateBin; new Controller;
ob_end_clean(); ob_end_clean();
$this->assertFileExists($file, 'htaccess recreated'); $this->assertFileExists($file, 'htaccess recreated');
@ -152,7 +152,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
public function testConf() public function testConf()
{ {
file_put_contents(CONF, ''); file_put_contents(CONF, '');
new PrivateBin; new Controller;
} }
/** /**
@ -168,7 +168,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$_SERVER['REQUEST_METHOD'] = 'POST'; $_SERVER['REQUEST_METHOD'] = 'POST';
$_SERVER['REMOTE_ADDR'] = '::1'; $_SERVER['REMOTE_ADDR'] = '::1';
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$response = json_decode($content, true); $response = json_decode($content, true);
@ -196,7 +196,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$_SERVER['REMOTE_ADDR'] = '::1'; $_SERVER['REMOTE_ADDR'] = '::1';
TrafficLimiter::canPass(); TrafficLimiter::canPass();
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$response = json_decode($content, true); $response = json_decode($content, true);
@ -224,7 +224,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$_SERVER['REQUEST_METHOD'] = 'POST'; $_SERVER['REQUEST_METHOD'] = 'POST';
$_SERVER['REMOTE_ADDR'] = '::1'; $_SERVER['REMOTE_ADDR'] = '::1';
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$response = json_decode($content, true); $response = json_decode($content, true);
@ -246,7 +246,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$_SERVER['REQUEST_METHOD'] = 'POST'; $_SERVER['REQUEST_METHOD'] = 'POST';
$_SERVER['REMOTE_ADDR'] = '::1'; $_SERVER['REMOTE_ADDR'] = '::1';
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$response = json_decode($content, true); $response = json_decode($content, true);
@ -274,7 +274,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$_SERVER['REQUEST_METHOD'] = 'POST'; $_SERVER['REQUEST_METHOD'] = 'POST';
$_SERVER['REMOTE_ADDR'] = '::1'; $_SERVER['REMOTE_ADDR'] = '::1';
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$response = json_decode($content, true); $response = json_decode($content, true);
@ -298,7 +298,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$_SERVER['REMOTE_ADDR'] = '::1'; $_SERVER['REMOTE_ADDR'] = '::1';
$time = time(); $time = time();
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$response = json_decode($content, true); $response = json_decode($content, true);
@ -329,7 +329,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$_SERVER['REMOTE_ADDR'] = '::1'; $_SERVER['REMOTE_ADDR'] = '::1';
$time = time(); $time = time();
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$response = json_decode($content, true); $response = json_decode($content, true);
@ -359,7 +359,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$_SERVER['REQUEST_METHOD'] = 'POST'; $_SERVER['REQUEST_METHOD'] = 'POST';
$_SERVER['REMOTE_ADDR'] = '::1'; $_SERVER['REMOTE_ADDR'] = '::1';
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$response = json_decode($content, true); $response = json_decode($content, true);
@ -387,7 +387,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$_SERVER['REQUEST_METHOD'] = 'POST'; $_SERVER['REQUEST_METHOD'] = 'POST';
$_SERVER['REMOTE_ADDR'] = '::1'; $_SERVER['REMOTE_ADDR'] = '::1';
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$response = json_decode($content, true); $response = json_decode($content, true);
@ -409,7 +409,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$_SERVER['REQUEST_METHOD'] = 'POST'; $_SERVER['REQUEST_METHOD'] = 'POST';
$_SERVER['REMOTE_ADDR'] = '::1'; $_SERVER['REMOTE_ADDR'] = '::1';
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$response = json_decode($content, true); $response = json_decode($content, true);
@ -432,7 +432,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$_SERVER['REMOTE_ADDR'] = '::1'; $_SERVER['REMOTE_ADDR'] = '::1';
$this->assertFalse($this->_model->exists(Helper::getPasteId()), 'paste does not exists before posting data'); $this->assertFalse($this->_model->exists(Helper::getPasteId()), 'paste does not exists before posting data');
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$response = json_decode($content, true); $response = json_decode($content, true);
@ -469,7 +469,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$_SERVER['REMOTE_ADDR'] = '::1'; $_SERVER['REMOTE_ADDR'] = '::1';
$this->assertFalse($this->_model->exists(Helper::getPasteId()), 'paste does not exists before posting data'); $this->assertFalse($this->_model->exists(Helper::getPasteId()), 'paste does not exists before posting data');
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$response = json_decode($content, true); $response = json_decode($content, true);
@ -487,11 +487,11 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$_SERVER['REQUEST_METHOD'] = 'POST'; $_SERVER['REQUEST_METHOD'] = 'POST';
$_SERVER['REMOTE_ADDR'] = '::1'; $_SERVER['REMOTE_ADDR'] = '::1';
ob_start(); ob_start();
new PrivateBin; new Controller;
ob_end_clean(); ob_end_clean();
$this->_model->delete(Helper::getPasteId()); $this->_model->delete(Helper::getPasteId());
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$response = json_decode($content, true); $response = json_decode($content, true);
@ -513,7 +513,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$_SERVER['REQUEST_METHOD'] = 'POST'; $_SERVER['REQUEST_METHOD'] = 'POST';
$_SERVER['REMOTE_ADDR'] = '::1'; $_SERVER['REMOTE_ADDR'] = '::1';
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$response = json_decode($content, true); $response = json_decode($content, true);
@ -544,7 +544,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$_SERVER['REMOTE_ADDR'] = '::1'; $_SERVER['REMOTE_ADDR'] = '::1';
$this->_model->create(Helper::getPasteId(), Helper::getPaste()); $this->_model->create(Helper::getPasteId(), Helper::getPaste());
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$response = json_decode($content, true); $response = json_decode($content, true);
@ -568,7 +568,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$_SERVER['REMOTE_ADDR'] = '::1'; $_SERVER['REMOTE_ADDR'] = '::1';
$this->_model->create(Helper::getPasteId(), Helper::getPaste()); $this->_model->create(Helper::getPasteId(), Helper::getPaste());
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$response = json_decode($content, true); $response = json_decode($content, true);
@ -592,7 +592,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$_SERVER['REMOTE_ADDR'] = '::1'; $_SERVER['REMOTE_ADDR'] = '::1';
$this->_model->create(Helper::getPasteId(), Helper::getPaste()); $this->_model->create(Helper::getPasteId(), Helper::getPaste());
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$response = json_decode($content, true); $response = json_decode($content, true);
@ -617,7 +617,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$paste = Helper::getPaste(array('opendiscussion' => false)); $paste = Helper::getPaste(array('opendiscussion' => false));
$this->_model->create(Helper::getPasteId(), $paste); $this->_model->create(Helper::getPasteId(), $paste);
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$response = json_decode($content, true); $response = json_decode($content, true);
@ -640,7 +640,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$_SERVER['REQUEST_METHOD'] = 'POST'; $_SERVER['REQUEST_METHOD'] = 'POST';
$_SERVER['REMOTE_ADDR'] = '::1'; $_SERVER['REMOTE_ADDR'] = '::1';
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$response = json_decode($content, true); $response = json_decode($content, true);
@ -666,7 +666,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$_SERVER['REQUEST_METHOD'] = 'POST'; $_SERVER['REQUEST_METHOD'] = 'POST';
$_SERVER['REMOTE_ADDR'] = '::1'; $_SERVER['REMOTE_ADDR'] = '::1';
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$response = json_decode($content, true); $response = json_decode($content, true);
@ -682,7 +682,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$_SERVER['QUERY_STRING'] = 'foo'; $_SERVER['QUERY_STRING'] = 'foo';
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest'; $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$response = json_decode($content, true); $response = json_decode($content, true);
@ -698,7 +698,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$_SERVER['QUERY_STRING'] = Helper::getPasteId(); $_SERVER['QUERY_STRING'] = Helper::getPasteId();
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest'; $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$response = json_decode($content, true); $response = json_decode($content, true);
@ -716,7 +716,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$_SERVER['QUERY_STRING'] = Helper::getPasteId(); $_SERVER['QUERY_STRING'] = Helper::getPasteId();
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest'; $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$response = json_decode($content, true); $response = json_decode($content, true);
@ -734,7 +734,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$_SERVER['QUERY_STRING'] = Helper::getPasteId(); $_SERVER['QUERY_STRING'] = Helper::getPasteId();
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest'; $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$response = json_decode($content, true); $response = json_decode($content, true);
@ -762,7 +762,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$_SERVER['QUERY_STRING'] = Helper::getPasteId(); $_SERVER['QUERY_STRING'] = Helper::getPasteId();
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest'; $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$response = json_decode($content, true); $response = json_decode($content, true);
@ -792,7 +792,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$_SERVER['QUERY_STRING'] = Helper::getPasteId(); $_SERVER['QUERY_STRING'] = Helper::getPasteId();
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest'; $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$response = json_decode($content, true); $response = json_decode($content, true);
@ -818,7 +818,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$_GET['pasteid'] = Helper::getPasteId(); $_GET['pasteid'] = Helper::getPasteId();
$_GET['deletetoken'] = hash_hmac('sha256', Helper::getPasteId(), $paste->meta->salt); $_GET['deletetoken'] = hash_hmac('sha256', Helper::getPasteId(), $paste->meta->salt);
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$this->assertRegExp( $this->assertRegExp(
@ -838,7 +838,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$_GET['pasteid'] = 'foo'; $_GET['pasteid'] = 'foo';
$_GET['deletetoken'] = 'bar'; $_GET['deletetoken'] = 'bar';
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$this->assertRegExp( $this->assertRegExp(
@ -857,7 +857,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$_GET['pasteid'] = Helper::getPasteId(); $_GET['pasteid'] = Helper::getPasteId();
$_GET['deletetoken'] = 'bar'; $_GET['deletetoken'] = 'bar';
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$this->assertRegExp( $this->assertRegExp(
@ -876,7 +876,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$_GET['pasteid'] = Helper::getPasteId(); $_GET['pasteid'] = Helper::getPasteId();
$_GET['deletetoken'] = 'bar'; $_GET['deletetoken'] = 'bar';
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$this->assertRegExp( $this->assertRegExp(
@ -900,7 +900,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest'; $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
$_SERVER['REQUEST_METHOD'] = 'POST'; $_SERVER['REQUEST_METHOD'] = 'POST';
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$response = json_decode($content, true); $response = json_decode($content, true);
@ -920,7 +920,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest'; $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
$_SERVER['REQUEST_METHOD'] = 'POST'; $_SERVER['REQUEST_METHOD'] = 'POST';
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$response = json_decode($content, true); $response = json_decode($content, true);
@ -940,7 +940,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$_GET['pasteid'] = Helper::getPasteId(); $_GET['pasteid'] = Helper::getPasteId();
$_GET['deletetoken'] = 'does not matter in this context, but has to be set'; $_GET['deletetoken'] = 'does not matter in this context, but has to be set';
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$this->assertRegExp( $this->assertRegExp(
@ -963,7 +963,7 @@ class PrivateBinTest extends PHPUnit_Framework_TestCase
$_GET['pasteid'] = Helper::getPasteId(); $_GET['pasteid'] = Helper::getPasteId();
$_GET['deletetoken'] = hash_hmac('sha256', Helper::getPasteId(), ServerSalt::get()); $_GET['deletetoken'] = hash_hmac('sha256', Helper::getPasteId(), ServerSalt::get());
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$this->assertRegExp( $this->assertRegExp(

View file

@ -2,9 +2,9 @@
use PrivateBin\Data\Database; use PrivateBin\Data\Database;
require_once 'PrivateBinTest.php'; require_once 'ControllerTest.php';
class PrivateBinWithDbTest extends PrivateBinTest class ControllerWithDbTest extends ControllerTest
{ {
private $_options = array( private $_options = array(
'usr' => null, 'usr' => null,

View file

@ -1,7 +1,7 @@
<?php <?php
use PrivateBin\Data\Database; use PrivateBin\Data\Database;
use PrivateBin\PrivateBin; use PrivateBin\Controller;
class DatabaseTest extends PHPUnit_Framework_TestCase class DatabaseTest extends PHPUnit_Framework_TestCase
{ {
@ -318,7 +318,7 @@ class DatabaseTest extends PHPUnit_Framework_TestCase
$statement->execute(array('VERSION')); $statement->execute(array('VERSION'));
$result = $statement->fetch(PDO::FETCH_ASSOC); $result = $statement->fetch(PDO::FETCH_ASSOC);
$statement->closeCursor(); $statement->closeCursor();
$this->assertEquals(PrivateBin::VERSION, $result['value']); $this->assertEquals(Controller::VERSION, $result['value']);
Helper::rmDir($this->_path); Helper::rmDir($this->_path);
} }
} }

View file

@ -2,7 +2,7 @@
use PrivateBin\Data\Filesystem; use PrivateBin\Data\Filesystem;
use PrivateBin\Persistence\ServerSalt; use PrivateBin\Persistence\ServerSalt;
use PrivateBin\PrivateBin; use PrivateBin\Controller;
use PrivateBin\Request; use PrivateBin\Request;
class JsonApiTest extends PHPUnit_Framework_TestCase class JsonApiTest extends PHPUnit_Framework_TestCase
@ -53,7 +53,7 @@ class JsonApiTest extends PHPUnit_Framework_TestCase
$_SERVER['REQUEST_METHOD'] = 'POST'; $_SERVER['REQUEST_METHOD'] = 'POST';
$_SERVER['REMOTE_ADDR'] = '::1'; $_SERVER['REMOTE_ADDR'] = '::1';
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$response = json_decode($content, true); $response = json_decode($content, true);
@ -86,7 +86,7 @@ class JsonApiTest extends PHPUnit_Framework_TestCase
$_SERVER['REQUEST_METHOD'] = 'PUT'; $_SERVER['REQUEST_METHOD'] = 'PUT';
$_SERVER['REMOTE_ADDR'] = '::1'; $_SERVER['REMOTE_ADDR'] = '::1';
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
unlink($file); unlink($file);
@ -120,7 +120,7 @@ class JsonApiTest extends PHPUnit_Framework_TestCase
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest'; $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
$_SERVER['REQUEST_METHOD'] = 'DELETE'; $_SERVER['REQUEST_METHOD'] = 'DELETE';
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
unlink($file); unlink($file);
@ -144,7 +144,7 @@ class JsonApiTest extends PHPUnit_Framework_TestCase
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest'; $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
$_SERVER['REQUEST_METHOD'] = 'POST'; $_SERVER['REQUEST_METHOD'] = 'POST';
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$response = json_decode($content, true); $response = json_decode($content, true);
@ -166,7 +166,7 @@ class JsonApiTest extends PHPUnit_Framework_TestCase
$_SERVER['QUERY_STRING'] = Helper::getPasteId(); $_SERVER['QUERY_STRING'] = Helper::getPasteId();
$_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest'; $_SERVER['HTTP_X_REQUESTED_WITH'] = 'JSONHttpRequest';
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$response = json_decode($content, true); $response = json_decode($content, true);
@ -192,7 +192,7 @@ class JsonApiTest extends PHPUnit_Framework_TestCase
$this->_model->create(Helper::getPasteId(), $paste); $this->_model->create(Helper::getPasteId(), $paste);
$_GET['jsonld'] = 'paste'; $_GET['jsonld'] = 'paste';
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$this->assertEquals(str_replace( $this->assertEquals(str_replace(
@ -211,7 +211,7 @@ class JsonApiTest extends PHPUnit_Framework_TestCase
$this->_model->create(Helper::getPasteId(), $paste); $this->_model->create(Helper::getPasteId(), $paste);
$_GET['jsonld'] = 'comment'; $_GET['jsonld'] = 'comment';
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$this->assertEquals(str_replace( $this->assertEquals(str_replace(
@ -230,7 +230,7 @@ class JsonApiTest extends PHPUnit_Framework_TestCase
$this->_model->create(Helper::getPasteId(), $paste); $this->_model->create(Helper::getPasteId(), $paste);
$_GET['jsonld'] = 'pastemeta'; $_GET['jsonld'] = 'pastemeta';
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$this->assertEquals(str_replace( $this->assertEquals(str_replace(
@ -249,7 +249,7 @@ class JsonApiTest extends PHPUnit_Framework_TestCase
$this->_model->create(Helper::getPasteId(), $paste); $this->_model->create(Helper::getPasteId(), $paste);
$_GET['jsonld'] = 'commentmeta'; $_GET['jsonld'] = 'commentmeta';
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$this->assertEquals(str_replace( $this->assertEquals(str_replace(
@ -268,7 +268,7 @@ class JsonApiTest extends PHPUnit_Framework_TestCase
$this->_model->create(Helper::getPasteId(), $paste); $this->_model->create(Helper::getPasteId(), $paste);
$_GET['jsonld'] = CONF; $_GET['jsonld'] = CONF;
ob_start(); ob_start();
new PrivateBin; new Controller;
$content = ob_get_contents(); $content = ob_get_contents();
ob_end_clean(); ob_end_clean();
$this->assertEquals('{}', $content, 'does not output nasty data'); $this->assertEquals('{}', $content, 'does not output nasty data');

View file

@ -12,6 +12,7 @@ return array(
'Identicon\\Generator\\ImageMagickGenerator' => $vendorDir . '/yzalis/identicon/src/Identicon/Generator/ImageMagickGenerator.php', 'Identicon\\Generator\\ImageMagickGenerator' => $vendorDir . '/yzalis/identicon/src/Identicon/Generator/ImageMagickGenerator.php',
'Identicon\\Identicon' => $vendorDir . '/yzalis/identicon/src/Identicon/Identicon.php', 'Identicon\\Identicon' => $vendorDir . '/yzalis/identicon/src/Identicon/Identicon.php',
'PrivateBin\\Configuration' => $baseDir . '/lib/Configuration.php', 'PrivateBin\\Configuration' => $baseDir . '/lib/Configuration.php',
'PrivateBin\\Controller' => $baseDir . '/lib/Controller.php',
'PrivateBin\\Data\\AbstractData' => $baseDir . '/lib/Data/AbstractData.php', 'PrivateBin\\Data\\AbstractData' => $baseDir . '/lib/Data/AbstractData.php',
'PrivateBin\\Data\\Database' => $baseDir . '/lib/Data/Database.php', 'PrivateBin\\Data\\Database' => $baseDir . '/lib/Data/Database.php',
'PrivateBin\\Data\\Filesystem' => $baseDir . '/lib/Data/Filesystem.php', 'PrivateBin\\Data\\Filesystem' => $baseDir . '/lib/Data/Filesystem.php',
@ -27,7 +28,6 @@ return array(
'PrivateBin\\Persistence\\PurgeLimiter' => $baseDir . '/lib/Persistence/PurgeLimiter.php', 'PrivateBin\\Persistence\\PurgeLimiter' => $baseDir . '/lib/Persistence/PurgeLimiter.php',
'PrivateBin\\Persistence\\ServerSalt' => $baseDir . '/lib/Persistence/ServerSalt.php', 'PrivateBin\\Persistence\\ServerSalt' => $baseDir . '/lib/Persistence/ServerSalt.php',
'PrivateBin\\Persistence\\TrafficLimiter' => $baseDir . '/lib/Persistence/TrafficLimiter.php', 'PrivateBin\\Persistence\\TrafficLimiter' => $baseDir . '/lib/Persistence/TrafficLimiter.php',
'PrivateBin\\PrivateBin' => $baseDir . '/lib/PrivateBin.php',
'PrivateBin\\Request' => $baseDir . '/lib/Request.php', 'PrivateBin\\Request' => $baseDir . '/lib/Request.php',
'PrivateBin\\Sjcl' => $baseDir . '/lib/Sjcl.php', 'PrivateBin\\Sjcl' => $baseDir . '/lib/Sjcl.php',
'PrivateBin\\View' => $baseDir . '/lib/View.php', 'PrivateBin\\View' => $baseDir . '/lib/View.php',

View file

@ -41,6 +41,7 @@ class ComposerStaticInitDontChange
'Identicon\\Generator\\ImageMagickGenerator' => __DIR__ . '/..' . '/yzalis/identicon/src/Identicon/Generator/ImageMagickGenerator.php', 'Identicon\\Generator\\ImageMagickGenerator' => __DIR__ . '/..' . '/yzalis/identicon/src/Identicon/Generator/ImageMagickGenerator.php',
'Identicon\\Identicon' => __DIR__ . '/..' . '/yzalis/identicon/src/Identicon/Identicon.php', 'Identicon\\Identicon' => __DIR__ . '/..' . '/yzalis/identicon/src/Identicon/Identicon.php',
'PrivateBin\\Configuration' => __DIR__ . '/../..' . '/lib/Configuration.php', 'PrivateBin\\Configuration' => __DIR__ . '/../..' . '/lib/Configuration.php',
'PrivateBin\\Controller' => __DIR__ . '/../..' . '/lib/Controller.php',
'PrivateBin\\Data\\AbstractData' => __DIR__ . '/../..' . '/lib/Data/AbstractData.php', 'PrivateBin\\Data\\AbstractData' => __DIR__ . '/../..' . '/lib/Data/AbstractData.php',
'PrivateBin\\Data\\Database' => __DIR__ . '/../..' . '/lib/Data/Database.php', 'PrivateBin\\Data\\Database' => __DIR__ . '/../..' . '/lib/Data/Database.php',
'PrivateBin\\Data\\Filesystem' => __DIR__ . '/../..' . '/lib/Data/Filesystem.php', 'PrivateBin\\Data\\Filesystem' => __DIR__ . '/../..' . '/lib/Data/Filesystem.php',
@ -56,7 +57,6 @@ class ComposerStaticInitDontChange
'PrivateBin\\Persistence\\PurgeLimiter' => __DIR__ . '/../..' . '/lib/Persistence/PurgeLimiter.php', 'PrivateBin\\Persistence\\PurgeLimiter' => __DIR__ . '/../..' . '/lib/Persistence/PurgeLimiter.php',
'PrivateBin\\Persistence\\ServerSalt' => __DIR__ . '/../..' . '/lib/Persistence/ServerSalt.php', 'PrivateBin\\Persistence\\ServerSalt' => __DIR__ . '/../..' . '/lib/Persistence/ServerSalt.php',
'PrivateBin\\Persistence\\TrafficLimiter' => __DIR__ . '/../..' . '/lib/Persistence/TrafficLimiter.php', 'PrivateBin\\Persistence\\TrafficLimiter' => __DIR__ . '/../..' . '/lib/Persistence/TrafficLimiter.php',
'PrivateBin\\PrivateBin' => __DIR__ . '/../..' . '/lib/PrivateBin.php',
'PrivateBin\\Request' => __DIR__ . '/../..' . '/lib/Request.php', 'PrivateBin\\Request' => __DIR__ . '/../..' . '/lib/Request.php',
'PrivateBin\\Sjcl' => __DIR__ . '/../..' . '/lib/Sjcl.php', 'PrivateBin\\Sjcl' => __DIR__ . '/../..' . '/lib/Sjcl.php',
'PrivateBin\\View' => __DIR__ . '/../..' . '/lib/View.php', 'PrivateBin\\View' => __DIR__ . '/../..' . '/lib/View.php',