updated documentation, small cleanups
This commit is contained in:
parent
b45bef8388
commit
3fa0881c07
|
@ -13,7 +13,7 @@
|
||||||
namespace PrivateBin\Data;
|
namespace PrivateBin\Data;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* privatebin_abstract
|
* AbstractData
|
||||||
*
|
*
|
||||||
* Abstract model for PrivateBin data access, implemented as a singleton.
|
* Abstract model for PrivateBin data access, implemented as a singleton.
|
||||||
*/
|
*/
|
||||||
|
@ -24,7 +24,7 @@ abstract class AbstractData
|
||||||
*
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
* @static
|
* @static
|
||||||
* @var privatebin_abstract
|
* @var AbstractData
|
||||||
*/
|
*/
|
||||||
protected static $_instance = null;
|
protected static $_instance = null;
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,7 @@ abstract class AbstractModel
|
||||||
* Configuration.
|
* Configuration.
|
||||||
*
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
* @var configuration
|
* @var Configuration
|
||||||
*/
|
*/
|
||||||
protected $_conf;
|
protected $_conf;
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ abstract class AbstractModel
|
||||||
* Data storage.
|
* Data storage.
|
||||||
*
|
*
|
||||||
* @access protected
|
* @access protected
|
||||||
* @var privatebin_abstract
|
* @var AbstractData
|
||||||
*/
|
*/
|
||||||
protected $_store;
|
protected $_store;
|
||||||
|
|
||||||
|
@ -61,11 +61,11 @@ abstract class AbstractModel
|
||||||
* Instance constructor.
|
* Instance constructor.
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
* @param configuration $configuration
|
* @param Configuration $configuration
|
||||||
* @param privatebin_abstract $storage
|
* @param AbstractData $storage
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function __construct(configuration $configuration, AbstractData $storage)
|
public function __construct(Configuration $configuration, AbstractData $storage)
|
||||||
{
|
{
|
||||||
$this->_conf = $configuration;
|
$this->_conf = $configuration;
|
||||||
$this->_store = $storage;
|
$this->_store = $storage;
|
||||||
|
|
|
@ -74,12 +74,9 @@ class PurgeLimiter extends AbstractPersistence
|
||||||
|
|
||||||
$file = 'purge_limiter.php';
|
$file = 'purge_limiter.php';
|
||||||
$now = time();
|
$now = time();
|
||||||
|
$content = '<?php' . PHP_EOL . '$GLOBALS[\'purge_limiter\'] = ' . $now . ';' . PHP_EOL;
|
||||||
if (!self::_exists($file)) {
|
if (!self::_exists($file)) {
|
||||||
self::_store(
|
self::_store($file, $content);
|
||||||
$file,
|
|
||||||
'<?php' . PHP_EOL .
|
|
||||||
'$GLOBALS[\'purge_limiter\'] = ' . $now . ';' . PHP_EOL
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$path = self::getPath($file);
|
$path = self::getPath($file);
|
||||||
|
@ -90,11 +87,7 @@ class PurgeLimiter extends AbstractPersistence
|
||||||
$result = false;
|
$result = false;
|
||||||
} else {
|
} else {
|
||||||
$result = true;
|
$result = true;
|
||||||
self::_store(
|
self::_store($file, $content);
|
||||||
$file,
|
|
||||||
'<?php' . PHP_EOL .
|
|
||||||
'$GLOBALS[\'purge_limiter\'] = ' . $now . ';' . PHP_EOL
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ use PrivateBin\Configuration;
|
||||||
use PrivateBin\Data\Database;
|
use PrivateBin\Data\Database;
|
||||||
use PrivateBin\Model;
|
use PrivateBin\Model;
|
||||||
use PrivateBin\Model\Paste;
|
use PrivateBin\Model\Paste;
|
||||||
|
use PrivateBin\Persistence\ServerSalt;
|
||||||
use PrivateBin\Vizhash16x16;
|
use PrivateBin\Vizhash16x16;
|
||||||
|
|
||||||
class ModelTest extends PHPUnit_Framework_TestCase
|
class ModelTest extends PHPUnit_Framework_TestCase
|
||||||
|
@ -12,10 +13,15 @@ class ModelTest extends PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
private $_model;
|
private $_model;
|
||||||
|
|
||||||
|
protected $_path;
|
||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
/* Setup Routine */
|
/* Setup Routine */
|
||||||
Helper::confRestore();
|
Helper::confRestore();
|
||||||
|
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
|
||||||
|
if (!is_dir($this->_path)) mkdir($this->_path);
|
||||||
|
ServerSalt::setPath($this->_path);
|
||||||
$options = parse_ini_file(CONF, true);
|
$options = parse_ini_file(CONF, true);
|
||||||
$options['purge']['limit'] = 0;
|
$options['purge']['limit'] = 0;
|
||||||
$options['model'] = array(
|
$options['model'] = array(
|
||||||
|
@ -37,6 +43,8 @@ class ModelTest extends PHPUnit_Framework_TestCase
|
||||||
public function tearDown()
|
public function tearDown()
|
||||||
{
|
{
|
||||||
/* Tear Down Routine */
|
/* Tear Down Routine */
|
||||||
|
Helper::confRestore();
|
||||||
|
Helper::rmDir($this->_path);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testBasicWorkflow()
|
public function testBasicWorkflow()
|
||||||
|
|
Loading…
Reference in New Issue