9a61e8fd48
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
44 lines
1 KiB
PHP
44 lines
1 KiB
PHP
<?php
|
|
|
|
use PrivateBin\Data\Filesystem;
|
|
use PrivateBin\Persistence\PurgeLimiter;
|
|
|
|
class PurgeLimiterTest extends PHPUnit_Framework_TestCase
|
|
{
|
|
private $_path;
|
|
|
|
public function setUp()
|
|
{
|
|
/* Setup Routine */
|
|
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
|
|
if (!is_dir($this->_path)) {
|
|
mkdir($this->_path);
|
|
}
|
|
PurgeLimiter::setStore(
|
|
new Filesystem(array('dir' => $this->_path))
|
|
);
|
|
}
|
|
|
|
public function tearDown()
|
|
{
|
|
/* Tear Down Routine */
|
|
Helper::rmDir($this->_path);
|
|
}
|
|
|
|
public function testLimit()
|
|
{
|
|
// initialize it
|
|
PurgeLimiter::setLimit(1);
|
|
PurgeLimiter::canPurge();
|
|
|
|
// try setting it
|
|
$this->assertEquals(false, PurgeLimiter::canPurge());
|
|
sleep(2);
|
|
$this->assertEquals(true, PurgeLimiter::canPurge());
|
|
|
|
// disable it
|
|
PurgeLimiter::setLimit(0);
|
|
PurgeLimiter::canPurge();
|
|
$this->assertEquals(true, PurgeLimiter::canPurge());
|
|
}
|
|
}
|