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