2016-07-15 23:02:59 +08:00
|
|
|
<?php
|
2016-07-21 23:09:48 +08:00
|
|
|
|
|
|
|
use PrivateBin\purgelimiter;
|
|
|
|
|
2016-07-15 23:02:59 +08:00
|
|
|
class purgelimiterTest extends PHPUnit_Framework_TestCase
|
|
|
|
{
|
|
|
|
private $_path;
|
|
|
|
|
|
|
|
public function setUp()
|
|
|
|
{
|
|
|
|
/* Setup Routine */
|
|
|
|
$this->_path = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'privatebin_data';
|
2016-07-26 14:19:35 +08:00
|
|
|
if (!is_dir($this->_path)) {
|
|
|
|
mkdir($this->_path);
|
|
|
|
}
|
2016-07-15 23:02:59 +08:00
|
|
|
purgelimiter::setPath($this->_path);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function tearDown()
|
|
|
|
{
|
|
|
|
/* Tear Down Routine */
|
|
|
|
helper::rmdir($this->_path);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testLimit()
|
|
|
|
{
|
|
|
|
// initialize it
|
|
|
|
purgelimiter::canPurge();
|
|
|
|
|
|
|
|
// try setting it
|
|
|
|
purgelimiter::setLimit(1);
|
|
|
|
$this->assertEquals(false, purgelimiter::canPurge());
|
|
|
|
sleep(2);
|
|
|
|
$this->assertEquals(true, purgelimiter::canPurge());
|
|
|
|
|
|
|
|
// disable it
|
|
|
|
purgelimiter::setLimit(0);
|
|
|
|
purgelimiter::canPurge();
|
|
|
|
$this->assertEquals(true, purgelimiter::canPurge());
|
|
|
|
}
|
|
|
|
}
|